Skip to content

Commit ce47db5

Browse files
authored
Merge pull request #910 from PavanNeerudu/user/pavanneerudu/update-the-status-of-exisitingcrs
🐛 Update existing conditions to have a non-empty Reason field
2 parents f4dc9fd + a44b0ad commit ce47db5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

internal/controller/genericprovider_controller.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ func (r *GenericProviderReconciler) Reconcile(ctx context.Context, req reconcile
193193
}
194194

195195
func patchProvider(ctx context.Context, provider operatorv1.GenericProvider, patchHelper *patch.Helper, options ...patch.Option) error {
196+
// Fix existing conditions to ensure they have required Reason field
197+
normalizeExistingConditions(provider)
198+
196199
conds := []string{
197200
operatorv1.PreflightCheckCondition,
198201
operatorv1.ProviderInstalledCondition,
@@ -203,6 +206,26 @@ func patchProvider(ctx context.Context, provider operatorv1.GenericProvider, pat
203206
return patchHelper.Patch(ctx, provider, options...)
204207
}
205208

209+
// normalizeExistingConditions ensures all existing conditions have required Reason field.
210+
func normalizeExistingConditions(provider operatorv1.GenericProvider) {
211+
conditions := provider.GetConditions()
212+
modified := false
213+
214+
for i := range conditions {
215+
condition := &conditions[i]
216+
217+
// Set reason to condition type if empty
218+
if condition.Reason == "" {
219+
condition.Reason = condition.Type
220+
modified = true
221+
}
222+
}
223+
224+
if modified {
225+
provider.SetConditions(conditions)
226+
}
227+
}
228+
206229
func (r *GenericProviderReconciler) reconcile(ctx context.Context) (*Result, error) {
207230
var res Result
208231

0 commit comments

Comments
 (0)