Skip to content

Commit adad76c

Browse files
authored
Complete support for resource-specific resync periods and default drift remediation period (#386)
Issue: aws-controllers-k8s/community#1367 Follow-up of aws-controllers-k8s/runtime#106 This patch completes the implementation of support for resource-specific resync periods and a default drift remediation period made in runtime repository. The resync period for each reconciler is determined by trying to retrieve it from the following sources, in this order: 1. A resource-specific period specified in the drift remediation configuration. 2. A resource-specific requeue on success period specified by the resource manager factory. 3. The default drift remediation period specified in the controller configuration. 4. The default resync period defined in the ACK runtime package. This allows users to customize the drift remediation behavior for different resources as needed, while still providing a fallback option for resources that do not have a specific period specified. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 92c80ba commit adad76c

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

templates/config/controller/deployment.yaml.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ spec:
3737
- "$(ACK_RESOURCE_TAGS)"
3838
- --watch-namespace
3939
- "$(ACK_WATCH_NAMESPACE)"
40+
- --reconcile-default-resync-seconds
41+
- "$(RECONCILE_DEFAULT_RESYNC_SECONDS)"
42+
- --reconcile-resource-resync-seconds
43+
- "$(RECONCILE_RESOURCE_RESYNC_SECONDS)"
4044
image: controller:latest
4145
name: controller
4246
ports:
@@ -66,6 +70,10 @@ spec:
6670
value: "info"
6771
- name: ACK_RESOURCE_TAGS
6872
value: "services.k8s.aws/controller-version=%CONTROLLER_SERVICE%-%CONTROLLER_VERSION%,services.k8s.aws/namespace=%K8S_NAMESPACE%"
73+
- name: RECONCILE_DEFAULT_RESYNC_SECONDS
74+
value: "0"
75+
- name: RECONCILE_RESOURCE_RESYNC_SECONDS
76+
value: ""
6977
securityContext:
7078
allowPrivilegeEscalation: false
7179
privileged: false

templates/helm/templates/deployment.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ spec:
5656
- "$(ACK_WATCH_NAMESPACE)"
5757
- --deletion-policy
5858
- "$(DELETION_POLICY)"
59+
{{- if gt .Values.reconcile.defaultResyncPeriod 0.0 }}
60+
- --reconcile-default-resync-seconds
61+
- "$(RECONCILE_DEFAULT_RESYNC_SECONDS)"
62+
{{- end }}
63+
{{- range $key, $value := .Values.reconcile.resourceResyncPeriods }}
64+
- --reconcile-resource-resync-seconds
65+
- "$(RECONCILE_RESOURCE_RESYNC_SECONDS_{{ $key | upper }})"
66+
{{- end }}
5967
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
6068
imagePullPolicy: {{ .Values.image.pullPolicy }}
6169
name: controller
@@ -83,6 +91,14 @@ spec:
8391
value: {{ .Values.log.level | quote }}
8492
- name: ACK_RESOURCE_TAGS
8593
value: {{ join "," .Values.resourceTags | quote }}
94+
{{- if gt .Values.reconcile.defaultResyncPeriod 0.0 }}
95+
- name: RECONCILE_DEFAULT_RESYNC_SECONDS
96+
value: {{ .Values.reconcile.defaultResyncPeriod | quote }}
97+
{{- end }}
98+
{{- range $key, $value := .Values.reconcile.resourceResyncPeriods }}
99+
- name: RECONCILE_RESOURCE_RESYNC_SECONDS_{{ $key | upper }}
100+
value: {{ $key }}={{ $value }}
101+
{{- end }}
86102
{{- if .Values.aws.credentials.secretName }}
87103
- name: AWS_SHARED_CREDENTIALS_FILE
88104
value: {{ include "aws.credentials.path" . }}

templates/helm/values.schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@
207207
"type": "string",
208208
"enum": ["delete", "retain"]
209209
},
210+
"reconcile": {
211+
"description": "Reconcile resync settings. Parameters to tune the controller's drift remediation period.",
212+
"properties": {
213+
"defaultResyncPeriod": {
214+
"type": "number"
215+
},
216+
"resourceResyncPeriods": {
217+
"type": "object"
218+
}
219+
},
220+
"type": "object"
221+
},
210222
"serviceAccount": {
211223
"description": "ServiceAccount settings",
212224
"properties": {

templates/helm/values.yaml.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ resourceTags:
8383
# before the K8s resource is removed.
8484
deletionPolicy: delete
8585

86+
# controller reconciliation configurations
87+
reconcile:
88+
# The default duration, in seconds, to wait before resyncing desired state of custom resources.
89+
defaultResyncPeriod: 0
90+
# An object representing the reconcile resync configuration for each specific resource.
91+
resourceResyncPeriods: {}
92+
8693
serviceAccount:
8794
# Specifies whether a service account should be created
8895
create: true

0 commit comments

Comments
 (0)