diff --git a/.circleci/config.yml b/.circleci/config.yml index f47b5634..e9889720 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: build: working_directory: /go/pkg/mod/github.com/admiral docker: - - image: circleci/golang:1.11 + - image: circleci/golang:1.16 steps: - checkout - run: @@ -54,6 +54,7 @@ jobs: MINIKUBE_WANTREPORTERRORPROMPT: false MINIKUBE_HOME: /home/circleci CHANGE_MINIKUBE_NONE_USER: true + resource_class: large steps: - attach_workspace: at: . @@ -104,7 +105,7 @@ jobs: ./run.sh "1.16.8" "1.7.6" "../out" publish-github-release: docker: - - image: circleci/golang:1.11 + - image: circleci/golang:1.16 working_directory: /go/pkg/mod/github.com/admiral steps: - attach_workspace: diff --git a/.github/workflows/golang-ci-lint.yml b/.github/workflows/golang-ci-lint.yml index 5cbef633..547e0726 100644 --- a/.github/workflows/golang-ci-lint.yml +++ b/.github/workflows/golang-ci-lint.yml @@ -16,14 +16,13 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.29 + version: latest # Optional: working directory, useful for monorepos # working-directory: somedir # Optional: golangci-lint command line arguments. args: >- - --out-format=github-actions --skip-dirs=admiral/pkg/client/clientset/versioned --tests=false --timeout=5m diff --git a/admiral/pkg/apis/admiral/routes/handlers.go b/admiral/pkg/apis/admiral/routes/handlers.go index a35b2ff4..29e4ce4d 100644 --- a/admiral/pkg/apis/admiral/routes/handlers.go +++ b/admiral/pkg/apis/admiral/routes/handlers.go @@ -52,14 +52,16 @@ func (opts *RouteOpts) GetClusters(w http.ResponseWriter, r *http.Request) { } else { if len(clusterList) == 0 { message := "No cluster is monitored by admiral" - log.Printf(message) + log.Println(message) w.WriteHeader(200) out, _ = json.Marshal(message) - w.Write(out) } else { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - w.Write(out) + } + _, err := w.Write(out) + if err != nil { + log.Println("Failed to write message: ", err) } } } @@ -87,7 +89,11 @@ func (opts *RouteOpts) GetServiceEntriesByCluster(w http.ResponseWriter, r *http if len(serviceEntriesByCluster) == 0 { log.Printf("API call get service entry by cluster failed for clustername %v with Error: %v", clusterName, "No service entries configured for cluster - "+clusterName) w.WriteHeader(200) - w.Write([]byte(fmt.Sprintf("No service entries configured for cluster - %s", clusterName))) + _, err := w.Write([]byte(fmt.Sprintf("No service entries configured for cluster - %s", clusterName))) + if err != nil { + log.Println("Error writing body: ", err) + } + } else { response = serviceEntriesByCluster out, err := json.Marshal(response) @@ -97,7 +103,10 @@ func (opts *RouteOpts) GetServiceEntriesByCluster(w http.ResponseWriter, r *http } else { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - w.Write(out) + _, err := w.Write(out) + if err != nil { + log.Println("failed to write resp body: ", err) + } } } } @@ -134,7 +143,10 @@ func (opts *RouteOpts) GetServiceEntriesByIdentity(w http.ResponseWriter, r *htt } else { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - w.Write(out) + _, err := w.Write(out) + if err != nil { + log.Println("failed to write resp body", err) + } } } else { log.Printf("Identity not provided as part of the request") diff --git a/admiral/pkg/apis/admiral/server/server.go b/admiral/pkg/apis/admiral/server/server.go index 8e766375..e8186abe 100644 --- a/admiral/pkg/apis/admiral/server/server.go +++ b/admiral/pkg/apis/admiral/server/server.go @@ -53,8 +53,6 @@ func (s *Service) Start(ctx context.Context, port int, routes Routes, filter []F log.Printf("Starting admiral api server on port=%d", port) log.Fatalln(s.server.ListenAndServe()) - return - } func (s *Service) newRouter(routes Routes, filter []Filter) *mux.Router { @@ -86,12 +84,19 @@ func (s *Service) newRouter(routes Routes, filter []Filter) *mux.Router { } func waitForStop(s *Service) { - for { - select { - case <-s.ctx.Done(): - log.Println("context done stopping server") - s.stop() - return + //for { + // select { + // case <-s.ctx.Done(): + // log.Println("context done stopping server") + // s.stop() + // return + // } + //} + for range s.ctx.Done() { + log.Println("context done stopping server") + err := s.stop() + if err != nil { + log.Println("error stopping server: ", err) } } } diff --git a/tests/create_cluster.sh b/tests/create_cluster.sh index 0779c2d3..8325a178 100755 --- a/tests/create_cluster.sh +++ b/tests/create_cluster.sh @@ -5,7 +5,7 @@ k8s_version=$1 if [[ $IS_LOCAL == "false" ]]; then - sudo -E minikube start --vm-driver=none --cpus 4 --memory 4096 --kubernetes-version=$k8s_version &> $HOME/minikube.log 2>&1 < /dev/null + sudo -E minikube start --vm-driver=none --cpus 6 --memory 6144 --kubernetes-version=$k8s_version &> $HOME/minikube.log 2>&1 < /dev/null else minikube start --memory=4096 --cpus=4 --kubernetes-version=$k8s_version --vm-driver "virtualbox" #label node for locality load balancing