Skip to content

Commit

Permalink
Fix CircleCI build and Golang linting (istio-ecosystem#186)
Browse files Browse the repository at this point in the history
Signed-off-by: psikka1 <[email protected]>
  • Loading branch information
frankmariette authored and psikka1 committed Jun 15, 2022
1 parent 636887d commit c5ab72a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -54,6 +54,7 @@ jobs:
MINIKUBE_WANTREPORTERRORPROMPT: false
MINIKUBE_HOME: /home/circleci
CHANGE_MINIKUBE_NONE_USER: true
resource_class: large
steps:
- attach_workspace:
at: .
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/golang-ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions admiral/pkg/apis/admiral/routes/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
}
}
}
Expand Down Expand Up @@ -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")
Expand Down
21 changes: 13 additions & 8 deletions admiral/pkg/apis/admiral/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5ab72a

Please sign in to comment.