You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "basefas (via GitHub)" <gi...@apache.org> on 2023/04/11 03:44:16 UTC

[GitHub] [apisix-ingress-controller] basefas opened a new pull request, #1779: fix: health check bug

basefas opened a new pull request, #1779:
URL: https://github.com/apache/apisix-ingress-controller/pull/1779

   Keep health checker running when health check failed. 
   Make health check function pure.
   
   ### Type of change:
   
   Bugfix
   
   ### What this PR does / why we need it:
   
   for #1760 
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #1779: fix: health check bug

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1779:
URL: https://github.com/apache/apisix-ingress-controller/pull/1779#issuecomment-1502655528

   ## [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1779?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1779](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1779?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e36fa5f) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/aad3ef6fdd7866c096b96eaa3d19fed9f8fc3335?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (aad3ef6) will **increase** coverage by `0.02%`.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head e36fa5f differs from pull request most recent head 0a431c1. Consider uploading reports for the commit 0a431c1 to get more accurate results
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1779      +/-   ##
   ==========================================
   + Coverage   39.71%   39.74%   +0.02%     
   ==========================================
     Files          91       91              
     Lines        7989     7983       -6     
   ==========================================
     Hits         3173     3173              
   + Misses       4410     4404       -6     
     Partials      406      406              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1779?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/apisix/cluster.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1779?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9jbHVzdGVyLmdv) | `28.37% <0.00%> (+0.23%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] basefas commented on a diff in pull request #1779: fix: health check bug

Posted by "basefas (via GitHub)" <gi...@apache.org>.
basefas commented on code in PR #1779:
URL: https://github.com/apache/apisix-ingress-controller/pull/1779#discussion_r1164951961


##########
pkg/providers/controller.go:
##########
@@ -570,16 +570,20 @@ func (c *Controller) checkClusterHealth(ctx context.Context, cancelFunc context.
 
 		err := c.apisix.Cluster(c.cfg.APISIX.DefaultClusterName).HealthCheck(ctx)
 		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()
 			c.apiServer.HealthState.Err = err
 			c.apiServer.HealthState.Unlock()
-
-			return
+			// Finally failed health check, then give up leader.
+			log.Warnf("failed to check health for default cluster: %s, give up leader", err)
+		} else {
+			if c.apiServer.HealthState.Err != nil {
+				c.apiServer.HealthState.Lock()
+				c.apiServer.HealthState.Err = err
+				c.apiServer.HealthState.Unlock()
+			}
+			log.Debugf("success check health for default cluster")
+			c.MetricsCollector.IncrCheckClusterHealth(c.name)

Review Comment:
   the code in if block because it will only be changed when current health state error is nil and last health state error is not nil. Otherwise,it will be changed every health check time.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1779: fix: health check bug

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on code in PR #1779:
URL: https://github.com/apache/apisix-ingress-controller/pull/1779#discussion_r1164946215


##########
pkg/providers/controller.go:
##########
@@ -570,16 +570,20 @@ func (c *Controller) checkClusterHealth(ctx context.Context, cancelFunc context.
 
 		err := c.apisix.Cluster(c.cfg.APISIX.DefaultClusterName).HealthCheck(ctx)
 		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()
 			c.apiServer.HealthState.Err = err
 			c.apiServer.HealthState.Unlock()
-
-			return
+			// Finally failed health check, then give up leader.
+			log.Warnf("failed to check health for default cluster: %s, give up leader", err)
+		} else {
+			if c.apiServer.HealthState.Err != nil {
+				c.apiServer.HealthState.Lock()
+				c.apiServer.HealthState.Err = err
+				c.apiServer.HealthState.Unlock()
+			}
+			log.Debugf("success check health for default cluster")
+			c.MetricsCollector.IncrCheckClusterHealth(c.name)

Review Comment:
   The code here can be simplified. The state change for HealthState does not need to be placed in an if/else statement.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 merged pull request #1779: fix: health check bug

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 merged PR #1779:
URL: https://github.com/apache/apisix-ingress-controller/pull/1779


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org