diff --git a/cmd/ingress/ingress.go b/cmd/ingress/ingress.go index c38485f8f4..7b84d8e3ea 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 a577063ddd..9a9770443f 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.",