Skip to content

Commit f13a4ee

Browse files
authored
feat: add SkipIncompleteLateInitializeCheck (#606)
Description of changes: When a field is marked for lateInitialize, the controller tries to ensure that field is never nil. If by chance the field is nil, the controller will reconcile every 5 seconds until the field is no longer nil. Although we want certain fields lateInitialized, we don't expect them to be nonNil. In the example of RDS DBInstance, DBInstance contains PerformanceInsightsKMSID, that we want to lateInitialize only when PerformanceInsights is Enabled. For now this change only allows us the incomplete check, but moving forward, we may want to add certain conditions, to skip or not to skip... By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3cc82a1 commit f13a4ee

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/config/field.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,17 @@ type LateInitializeConfig struct {
318318
// MaxBackoffSeconds provide the maximum allowed backoff when retrying late initialization after an
319319
// unsuccessful attempt.
320320
MaxBackoffSeconds int `json:"max_backoff_seconds"`
321+
// SkipIncompleteCheck skips the LateInitialization incomplete check for resources.
322+
// NOTE: (michaelhtm) This skip is best used on resource fields we're sure will be set before being synced
323+
// eg. A resource is marked as synced before the field is lateInitialized, we wouldn't want to wait until
324+
// the next drift detection for the field to be set
325+
SkipIncompleteCheck *SkipIncompleteLateInitializeCheckConfig `json:"skip_incomplete_check,omitempty"`
326+
}
327+
328+
// SkipIncompleteLateInitializeCheckConfig is a config that defines the scenarios in which
329+
// we would want to skip lateInitialization.
330+
// TODO: (michaelhtm) Populate this struct with conditions...?
331+
type SkipIncompleteLateInitializeCheckConfig struct {
321332
}
322333

323334
// ReferencesConfig contains the instructions for how to add the referenced resource

pkg/generate/code/late_initialize.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ func IncompleteLateInitialization(
276276
indent := strings.Repeat("\t", indentLevel)
277277
var lateInitFieldNames []string
278278
lateInitConfigs := cfg.GetLateInitConfigs(r.Names.Original)
279-
for fieldName := range lateInitConfigs {
279+
for fieldName, lateInitConfig := range lateInitConfigs {
280+
if lateInitConfig.SkipIncompleteCheck != nil {
281+
continue
282+
}
280283
lateInitFieldNames = append(lateInitFieldNames, fieldName)
281284
}
282285
if len(lateInitFieldNames) == 0 {

0 commit comments

Comments
 (0)