Skip to content

fix: make service instance reconciler ignore status changes - #59

Open
Diaphteiros wants to merge 4 commits into
mainfrom
reconcile-fix
Open

fix: make service instance reconciler ignore status changes#59
Diaphteiros wants to merge 4 commits into
mainfrom
reconcile-fix

Conversation

@Diaphteiros

@Diaphteiros Diaphteiros commented Sep 4, 2026

Copy link
Copy Markdown

What this PR does / why we need it:
Service providers are usually the only controller modifying a service instance resource's status, which means that they don't need to react to status changes, as they caused them themselves.

Excluding status changes from triggering reconciliations reduces the chance for infinite reconciliation loops, which will otherwise happen if the service resource's status changes with every reconciliation.

Which issue(s) this PR fixes:
Fixed a problem with the service provider ODG.

Special notes for your reviewer:
Currently a draft because we want to add the option to overwrite the default predicates.

Release note:

Exclude status changes from triggering reconcilations.

Note: Service Providers that require status updates can override the default set of predicates by passing the new `serviceprovider.WithForPredicates` controller option to the `SetupWithManager` call.

Signed-off-by: Johannes Aubart <johannes.aubart@sap.com>
Signed-off-by: Johannes Aubart <johannes.aubart@sap.com>
@christophrj
christophrj self-requested a review September 4, 2026 16:16
On-behalf-of: @SAP christopher.junk@sap.com
Signed-off-by: Christopher Junk <christopher.junk@sap.com>
On-behalf-of: @SAP christopher.junk@sap.com
Signed-off-by: Christopher Junk <christopher.junk@sap.com>
@christophrj

Copy link
Copy Markdown
Member

@Diaphteiros added a new WithForPredicates controller option to override the default set of predicates.

@Diaphteiros
Diaphteiros marked this pull request as ready for review September 7, 2026 12:38
@Diaphteiros
Diaphteiros requested a review from reshnm September 7, 2026 12:38
@christophrj
christophrj removed their request for review September 7, 2026 12:39
@christophrj

Copy link
Copy Markdown
Member

@reshnm This is probably also the root cause of your observation in #44. I would still like leave that one open to add the SmartRequeue to the runtime.

Comment on lines +408 to +424
func defaultControllerConfig() *controllerConfig {
return &controllerConfig{
forPredicates: builder.WithPredicates(
predicate.And(
predicate.Or(
predicate.GenerationChangedPredicate{},
controllerutil2.DeletionTimestampChangedPredicate{},
predicate.LabelChangedPredicate{},
predicate.AnnotationChangedPredicate{},
),
predicate.Not(
controllerutil2.HasAnnotationPredicate(apiconst.OperationAnnotation, apiconst.OperationAnnotationValueIgnore),
),
),
),
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a resource has the ignore annotation and will be deleted, the resource will be stuck in termination until the ignore annotation will be removed.
The question is, shall the ignore annotatation also prevent the deletion from happening? If not, the Not(HasAnnotation(ignore) needs to handle deletion timestamp events.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I never thought of that. This is close to my 'default' predicate template which I use in most controllers I build.

However, I don't think that this will be a big issue in reality: The ignore annotation is meant to be a quick means for operators to temporarily prevent a controller from reconciling a resource. It is not expected to be on resources for a long time, and whoever set the annotation should be aware that this might cause issues.

Since the annotation's purpose is basically to mark the resource as 'don't reconcile this', I would argue that the resource being stuck in deletion because its deletion flow is not triggered is actually the expected (and a completely valid) result.

TL;DR: Didn't think of this, but also don't think we need to do anything here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it would be fine to remove the (And +) Not part but imo the main point is the helpful log entry that we essentially remove otherwise #59 (comment)

Comment thread pkg/serviceprovider/apireconciler_test.go
predicate.AnnotationChangedPredicate{},
),
predicate.Not(
controllerutil2.HasAnnotationPredicate(apiconst.OperationAnnotation, apiconst.OperationAnnotationValueIgnore),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Events with ignore annotation present will now be filtered before reaching the reconcile handler.
This is ok, but any logs that would have been emitted previously are now silenced which could now be confusing when debugging a problem.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I see more the positive aspect of this: Most controllers log something when starting a reconciliation. Checking for the ignore annotation only later will result in some 'wrong' logs - 'wrong' in the sense that the controller logs a reconciliation, but that reconciliation is actually not happening (aborted at the first opportunity).

Using this predicate therefore prevents some confusing logs. Missing reconciliations, which should only happen if the predicates are unfit (should not happen with our defaults), can still be detected by the absence of the aforementioned 'Starting reconcile' log message.

@reshnm reshnm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants