Skip to content

Commit

Permalink
Add --project-sync-period CLI option (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
arybolovlev authored Sep 4, 2024
1 parent 6127ef0 commit 3c8d66c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/FEATURES-479-20240830-090526.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.project.syncPeriod` to set the CLI option `--project-sync-period`.'
time: 2024-08-30T09:05:26.954037+02:00
custom:
PR: "479"
5 changes: 5 additions & 0 deletions .changes/unreleased/FEATURES-479-20240830-090626.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: FEATURES
body: '`Project`: Add a new CLI option called `--project-sync-period` to set the time interval for re-queuing Project resources once they are successfully reconciled.'
time: 2024-08-30T09:06:26.460931+02:00
custom:
PR: "479"
1 change: 1 addition & 0 deletions charts/hcp-terraform-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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.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. |
| controllers.workspace.syncPeriod | string | `"5m"` | The minimum frequency at which watched Workspace resources are reconciled. Format: 5s, 1m, etc. |
| controllers.workspace.workers | int | `1` | The number of the Workspace 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 @@ -38,6 +38,7 @@ spec:
- --agent-pool-sync-period={{ .Values.controllers.agentPool.syncPeriod }}
- --module-workers={{ .Values.controllers.module.workers }}
- --project-workers={{ .Values.controllers.project.workers }}
- --project-sync-period={{ .Values.controllers.project.syncPeriod }}
- --workspace-workers={{ .Values.controllers.workspace.workers }}
- --workspace-sync-period={{ .Values.controllers.workspace.syncPeriod }}
{{- range .Values.operator.watchedNamespaces }}
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 @@ -99,6 +99,8 @@ controllers:
project:
# -- The number of the Project controller workers.
workers: 1
# -- The minimum frequency at which watched Project resources are reconciled. Format: 5s, 1m, etc.
syncPeriod: 5m
workspace:
# -- The number of the Workspace 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,5 +9,6 @@ import (

var (
AgentPoolSyncPeriod time.Duration
ProjectSyncPeriod time.Duration
WorkspaceSyncPeriod time.Duration
)
2 changes: 1 addition & 1 deletion controllers/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (r *ProjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
p.log.Info("Project Controller", "msg", "successfully reconcilied project")
r.Recorder.Eventf(&p.instance, corev1.EventTypeNormal, "ReconcileProject", "Successfully reconcilied project ID %s", p.instance.Status.ID)

return doNotRequeue()
return requeueAfter(ProjectSyncPeriod)
}

func (r *ProjectReconciler) addFinalizer(ctx context.Context, instance *appv1alpha2.Project) error {
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 `--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.

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.
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func main() {
// PROJECT CONTROLLER OPTIONS
var projectWorkers int
flag.IntVar(&projectWorkers, "project-workers", 1,
"The number of the Workspace controller workers.")
"The number of the Project controller workers.")
flag.DurationVar(&controllers.ProjectSyncPeriod, "project-sync-period", 5*time.Minute,
"The minimum frequency at which watched project resources are reconciled. Format: 5s, 1m, etc.")
// WORKSPACE CONTROLLER OPTIONS
var workspaceWorkers int
flag.IntVar(&workspaceWorkers, "workspace-workers", 1,
Expand Down Expand Up @@ -168,6 +170,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("Project sync period: %s", controllers.ProjectSyncPeriod))
setupLog.Info(fmt.Sprintf("Workspace sync period: %s", controllers.WorkspaceSyncPeriod))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
Expand Down

0 comments on commit 3c8d66c

Please sign in to comment.