This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 69fbdb20 feat: support disable resource periodically sync (#1685)
69fbdb20 is described below

commit 69fbdb20fd0218bcd951c443e3b1838f27c227ca
Author: Sarasa Kisaragi <[email protected]>
AuthorDate: Fri Feb 24 10:56:05 2023 +0800

    feat: support disable resource periodically sync (#1685)
    
    Signed-off-by: Ling Samuel <[email protected]>
---
 cmd/ingress/ingress.go      | 2 +-
 pkg/providers/controller.go | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/cmd/ingress/ingress.go b/cmd/ingress/ingress.go
index c38485f8..7b84d8e3 100644
--- a/cmd/ingress/ingress.go
+++ b/cmd/ingress/ingress.go
@@ -191,7 +191,7 @@ For example, no available LB exists in the bare metal 
environment.`)
        cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterBaseURL, 
"default-apisix-cluster-base-url", "", "the base URL of admin api / manager api 
for the default APISIX cluster")
        cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterAdminKey, 
"default-apisix-cluster-admin-key", "", "admin key used for the authorization 
of admin api / manager api for the default APISIX cluster")
        cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterName, 
"default-apisix-cluster-name", "default", "name of the default apisix cluster")
-       
cmd.PersistentFlags().DurationVar(&cfg.ApisixResourceSyncInterval.Duration, 
"apisix-resource-sync-interval", 300*time.Second, "interval between syncs in 
seconds. Default value is 300s.")
+       
cmd.PersistentFlags().DurationVar(&cfg.ApisixResourceSyncInterval.Duration, 
"apisix-resource-sync-interval", 1*time.Hour, "interval between syncs in 
seconds. Default value is 1h. Set to 0 to disable.")
        cmd.PersistentFlags().StringVar(&cfg.PluginMetadataConfigMap, 
"plugin-metadata-cm", "plugin-metadata-config-map", "ConfigMap name of plugin 
metadata.")
 
        return cmd
diff --git a/pkg/providers/controller.go b/pkg/providers/controller.go
index a577063d..9a977044 100644
--- a/pkg/providers/controller.go
+++ b/pkg/providers/controller.go
@@ -560,9 +560,9 @@ func (c *Controller) checkClusterHealth(ctx 
context.Context, cancelFunc context.
                        // 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
+                       c.apiServer.HealthState.Unlock()
+
                        return
                }
                log.Debugf("success check health for default cluster")
@@ -580,6 +580,10 @@ func (c *Controller) syncAllResources() {
 }
 
 func (c *Controller) resourceSyncLoop(ctx context.Context, interval 
time.Duration) {
+       if interval == 0 {
+               log.Info("apisix-resource-sync-interval set to 0, periodically 
synchronization disabled.")
+               return
+       }
        // The interval shall not be less than 60 seconds.
        if interval < _mininumApisixResourceSyncInterval {
                log.Warnw("The apisix-resource-sync-interval shall not be less 
than 60 seconds.",

Reply via email to