Skip to content

Commit 1783b55

Browse files
committed
feat: add SkipIncompleteLateInitializeCheck
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...
1 parent a488d4e commit 1783b55

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/config/field.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ 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+
// TODO: (michaelhtm) we might want to add a SkipOnCondition/Condition
323+
SkipIncompleteCheck bool `json:"skip_incomplete_check,omitempty"`
321324
}
322325

323326
// 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 {
281+
continue
282+
}
280283
lateInitFieldNames = append(lateInitFieldNames, fieldName)
281284
}
282285
if len(lateInitFieldNames) == 0 {

0 commit comments

Comments
 (0)