mayocream commented on a change in pull request #770:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/770#discussion_r767028754



##########
File path: pkg/ingress/controller.go
##########
@@ -653,6 +653,10 @@ func (c *Controller) checkClusterHealth(ctx 
context.Context, cancelFunc context.
                if err != nil {
                        // Finally failed health check, then give up leader.
                        log.Warnf("failed to check health for default cluster: 
%s, give up leader", err)
+                       c.apiServer.HealthState.Lock()
+                       defer c.apiServer.HealthState.Unlock()
+
+                       c.apiServer.HealthState.Err = err

Review comment:
       Any suggestions about it? Inserting the health state struct into 
`cluster` is kinda unnecessary I think (we had `cacheSyncErr`). 
   We might wanna add a function, be like `APISIX.Health()`, it returns the 
health state of all clusters.
   Or we can just leave it in here (`checkClusterHealth`).

##########
File path: pkg/api/router/apisix_healthz.go
##########
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package router
+
+import (
+       "net/http"
+       "sync"
+
+       "github.com/gin-gonic/gin"
+)
+
+// HealthState stores healthcheck err of APISIX
+type HealthState struct {

Review comment:
       I Put `types.go` inside the router pkg.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to