diff --git a/charts/hcp-terraform-operator/README.md b/charts/hcp-terraform-operator/README.md index e02e8074..80a976cc 100644 --- a/charts/hcp-terraform-operator/README.md +++ b/charts/hcp-terraform-operator/README.md @@ -138,6 +138,7 @@ For a more detailed explanation, please refer to the [FAQ](../../docs/faq.md#gen |-----|------|---------|-------------| | controllers.agentPool.syncPeriod | string | `"30s"` | The minimum frequency at which watched Agent Pool resources are reconciled. Format: 5s, 1m, etc. | | controllers.agentPool.workers | int | `1` | The number of the Agent Pool controller workers. | +| controllers.module.syncPeriod | string | `"5m"` | The minimum frequency at which watched Module resources are reconciled. Format: 5s, 1m, etc. | | controllers.module.workers | int | `1` | The number of the Module controller workers. | | controllers.project.workers | int | `1` | The number of the Project controller workers. | | controllers.workspace.syncPeriod | string | `"5m"` | The minimum frequency at which watched Workspace resources are reconciled. Format: 5s, 1m, etc. | diff --git a/charts/hcp-terraform-operator/templates/deployment.yaml b/charts/hcp-terraform-operator/templates/deployment.yaml index ce05ce9e..96864f16 100644 --- a/charts/hcp-terraform-operator/templates/deployment.yaml +++ b/charts/hcp-terraform-operator/templates/deployment.yaml @@ -37,6 +37,7 @@ spec: - --agent-pool-workers={{ .Values.controllers.agentPool.workers }} - --agent-pool-sync-period={{ .Values.controllers.agentPool.syncPeriod }} - --module-workers={{ .Values.controllers.module.workers }} + - --module-sync-period={{ .Values.controllers.module.syncPeriod }} - --project-workers={{ .Values.controllers.project.workers }} - --workspace-workers={{ .Values.controllers.workspace.workers }} - --workspace-sync-period={{ .Values.controllers.workspace.syncPeriod }} diff --git a/charts/hcp-terraform-operator/values.yaml b/charts/hcp-terraform-operator/values.yaml index 38e9cbe3..b82ec507 100644 --- a/charts/hcp-terraform-operator/values.yaml +++ b/charts/hcp-terraform-operator/values.yaml @@ -96,6 +96,8 @@ controllers: module: # -- The number of the Module controller workers. workers: 1 + # -- The minimum frequency at which watched Module resources are reconciled. Format: 5s, 1m, etc. + syncPeriod: 5m project: # -- The number of the Project controller workers. workers: 1 diff --git a/controllers/flags.go b/controllers/flags.go index 1669931b..9b0d96af 100644 --- a/controllers/flags.go +++ b/controllers/flags.go @@ -9,5 +9,6 @@ import ( var ( AgentPoolSyncPeriod time.Duration + ModuleSyncPeriod time.Duration WorkspaceSyncPeriod time.Duration ) diff --git a/controllers/module_controller.go b/controllers/module_controller.go index 277b5065..929a8353 100644 --- a/controllers/module_controller.go +++ b/controllers/module_controller.go @@ -127,7 +127,7 @@ func (r *ModuleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr m.log.Info("Module Controller", "msg", "successfully reconcilied module") - return doNotRequeue() + return requeueAfter(ModuleSyncPeriod) } // SetupWithManager sets up the controller with the Manager. diff --git a/docs/faq.md b/docs/faq.md index 31303b4a..cd63cf32 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -76,6 +76,8 @@ The `--agent-pool-sync-period` is a `AgentPool` controller option that specifies the time interval for requeuing AgentPool resources, ensuring they will be reconciled. This time is set individually per resource and it helps avoid spike of the resources to reconcile. + The `--module-sync-period` is a `Module` controller option that specifies the time interval for requeuing Module resources, ensuring they will be reconciled. This time is set individually per resource and it helps avoid spike of the resources to reconcile. + The `--workspace-sync-period` is a `Workspace` controller option that specifies the time interval for requeuing Workspace resources, ensuring they will be reconciled. This time is set individually per resource and it helps avoid spike of the resources to reconcile. The controller synchronization period should be aligned with the number of managed Customer Resources. If the period is too low and the number of managed resources is too high, you may observe slowness in synchronization. diff --git a/main.go b/main.go index dff34b60..3e254c13 100644 --- a/main.go +++ b/main.go @@ -71,6 +71,8 @@ func main() { var moduleWorkers int flag.IntVar(&moduleWorkers, "module-workers", 1, "The number of the Module controller workers.") + flag.DurationVar(&controllers.ModuleSyncPeriod, "module-sync-period", 5*time.Minute, + "The minimum frequency at which watched workspace resources are reconciled. Format: 5s, 1m, etc.") // PROJECT CONTROLLER OPTIONS var projectWorkers int flag.IntVar(&projectWorkers, "project-workers", 1,