Skip to content

Commit

Permalink
feat: support disable resource periodically sync (#1685)
Browse files Browse the repository at this point in the history
Signed-off-by: Ling Samuel <[email protected]>
  • Loading branch information
lingsamuel authored Feb 24, 2023
1 parent 7a87083 commit 69fbdb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions pkg/providers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.",
Expand Down

0 comments on commit 69fbdb2

Please sign in to comment.