Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Add --module-sync-period CLI option #480

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/FEATURES-480-20240830-091412.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: FEATURES
body: '`Helm`: Add a new value called `controllers.module.syncPeriod` to set the CLI option `--module-sync-period`.'
time: 2024-08-30T09:14:12.597913+02:00
custom:
PR: "480"
5 changes: 5 additions & 0 deletions .changes/unreleased/FEATURES-480-20240830-091446.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: FEATURES
body: '`Module`: Add a new CLI option called `--module-sync-period` to set the time interval for re-queuing Module resources once they are successfully reconciled.'
time: 2024-08-30T09:14:46.812805+02:00
custom:
PR: "480"
1 change: 1 addition & 0 deletions charts/hcp-terraform-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.syncPeriod | string | `"5m"` | The minimum frequency at which watched Project resources are reconciled. Format: 5s, 1m, etc. |
| controllers.project.workers | int | `1` | The number of the Project controller workers. |
Expand Down
1 change: 1 addition & 0 deletions charts/hcp-terraform-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
- --project-sync-period={{ .Values.controllers.project.syncPeriod }}
- --workspace-workers={{ .Values.controllers.workspace.workers }}
Expand Down
2 changes: 2 additions & 0 deletions charts/hcp-terraform-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions controllers/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

var (
AgentPoolSyncPeriod time.Duration
ModuleSyncPeriod time.Duration
ProjectSyncPeriod time.Duration
WorkspaceSyncPeriod time.Duration
)
2 changes: 1 addition & 1 deletion controllers/module_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `--project-sync-period` is a `Project` controller option that specifies the time interval for requeuing Project 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.
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -86,7 +88,6 @@ func main() {

// TODO
// - Add validation that 'sync-period' has a higher value than '*-sync-period'
// - Add '*-sync-period' option for all controllers.
// - Add a new CLI option named 'status' (or consider a different name) that will print out the operator settings passed via flags.

flag.Parse()
Expand Down Expand Up @@ -170,6 +171,7 @@ func main() {

setupLog.Info(fmt.Sprintf("Operator sync period: %s", syncPeriod))
setupLog.Info(fmt.Sprintf("Agent Pool sync period: %s", controllers.AgentPoolSyncPeriod))
setupLog.Info(fmt.Sprintf("Module sync period: %s", controllers.ModuleSyncPeriod))
setupLog.Info(fmt.Sprintf("Project sync period: %s", controllers.ProjectSyncPeriod))
setupLog.Info(fmt.Sprintf("Workspace sync period: %s", controllers.WorkspaceSyncPeriod))

Expand Down
Loading