Skip to content

Add optional hook for operator specific status modifications#2101

Closed
rashmigottipati wants to merge 3 commits intoopenshift:masterfrom
rashmigottipati:add-release-version-detection
Closed

Add optional hook for operator specific status modifications#2101
rashmigottipati wants to merge 3 commits intoopenshift:masterfrom
rashmigottipati:add-release-version-detection

Conversation

@rashmigottipati
Copy link
Member

@rashmigottipati rashmigottipati commented Feb 2, 2026

Description

This PR adds an optional hook mechanism to StatusSyncer that allows operators to modify their ClusterOperator status before the update request is send to API server. The hook receives both the original status (reconcile start) and the mutated status (done by the reconcile logic), enabling operators informed decisions about additional tweaks, i.e. version that is going to send to API server.

Changes:

  • Add ClusterOperatorStatusHook function type
  • Add WithBeforeStatusUpdateHook() builder method
  • Hook is invoked in Sync() after standard status logic completes, before the API update

Motivation

Operators sometimes need custom status logic such as detecting version changes during cluster upgrades. This usually requires comparing the target version (from environment) against the current version (in ClusterOperator status). Without access to the original status from etcd, operators cannot reliably detect these transitions. This hook provides a generic mechanism for operators to implement such custom logic.

Co-authored-by: Predrag Knezevic pknezevi@redhat.com

@rashmigottipati
Copy link
Member Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 2, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rashmigottipati
Once this PR has been reviewed and has the lgtm label, please assign p0lyn0mial for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Rashmi Gottipati <rgottipa@redhat.com>
Co-authored-by: Predrag Knezevic <pknezevi@redhat.com>
@rashmigottipati rashmigottipati force-pushed the add-release-version-detection branch from 5fc35ac to 5b1dcb2 Compare February 3, 2026 13:26
Signed-off-by: Rashmi Gottipati <rgottipa@redhat.com>
Co-authored-by: Predrag Knezevic <pknezevi@redhat.com>
@rashmigottipati
Copy link
Member Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 3, 2026
@rashmigottipati rashmigottipati changed the title add version change detection and explicitly set progressing to true during an upgrade Add optional hook for operator specific status modifications Feb 3, 2026
Signed-off-by: Rashmi Gottipati <rgottipa@redhat.com>
@grokspawn
Copy link

Do you have an example PR we could use as an illustration of how this is utilized to achieve consistent upgrade signal?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

@rashmigottipati: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@jsafrane
Copy link
Contributor

jsafrane commented Feb 3, 2026

Example of usage: openshift/cluster-olm-operator#169

@jsafrane
Copy link
Contributor

jsafrane commented Feb 4, 2026

I talked to @rashmigottipati and @pedjak, this is not a good solution how to fix an operator not setting Progressing=true during upgrade.

With the last test changes, operators are allowed to stay Progressing=false if the operand image is the same as before, e.g. during upgrade between two close versions.

This PR has a good code, anyone can reopen it if they find a good reason to have hooks in the StatusController. Flipping Progressing because a tests expects so was not good enough - we fixed the test instead.

@p0lyn0mial
Copy link
Contributor

I talked to @rashmigottipati and @pedjak, this is not a good solution how to fix an operator not setting Progressing=true during upgrade.

With openshift/origin#30626, operators are allowed to stay Progressing=false if the operand image is the same as before, e.g. during upgrade between two close versions.

This PR has a good code, anyone can reopen it if they find a good reason to have hooks in the StatusController. Flipping Progressing because a tests expects so was not good enough - we fixed the test instead.

Thanks for the update. I’m going to close the PR then. As you wrote, it can be reopened when we find a good reason to have hooks in the StatusController.

/close

@openshift-ci openshift-ci bot closed this Feb 4, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 4, 2026

@p0lyn0mial: Closed this PR.

Details

In response to this:

I talked to @rashmigottipati and @pedjak, this is not a good solution how to fix an operator not setting Progressing=true during upgrade.

With openshift/origin#30626, operators are allowed to stay Progressing=false if the operand image is the same as before, e.g. during upgrade between two close versions.

This PR has a good code, anyone can reopen it if they find a good reason to have hooks in the StatusController. Flipping Progressing because a tests expects so was not good enough - we fixed the test instead.

Thanks for the update. I’m going to close the PR then. As you wrote, it can be reopened when we find a good reason to have hooks in the StatusController.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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.

4 participants