Skip to content

OTA-1531: [4/x] cvo: extract config informer creation #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

petr-muller
Copy link
Member

@petr-muller petr-muller commented May 7, 2025

The code to set up informers is messy so this change attempts to make it more consistent:

  • Alias all informer-related imports to somethinginformers
  • Everything made by NewSharedInformerFactory methods is now called somethingInformerFactory
  • Name factories in Context consistently: SomethingFactory
  • Document the purpose of individual factories in Context
  • Reorder code into clusters that deal with individual factory types

OTA-1531 will need the config.openshift.io group lister early in the CVO execution and outside of the Context structure, so this commit moves the necessary preparation code outside of NewControllerContext and passes these factories into it as parameters. Constructing factories at separate places is a little awkward but for now I try keeping the change small instead of trying to invent some centralized informer factory management. I think it is reasonable to treat config.openshift.io informers separately if they are actually used separately.


NewFilteredSharedInformerFactory is deprecated and can be replaced by NewSharedInformerFactoryWithOptions, where the filter is expressed as TweakListOption. The direct FieldSelector equality can be replaced with the OneTermEqualSelector helper.


Address an earlier review comment: #1188 (comment)

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 7, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 7, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 7, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

  • refactor(payload): separate tasks and metadata loading
  • refactor(payload): separate arch load from metadata and runtime
  • refactor(payload): rename loadReleaseFromMetadata->loadReleaseMetadata
  • cvo: read version from release metadata on startup
  • refactor: unify names in informer-related code
  • refactor: extract config informer factory prep

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented May 7, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2025
@petr-muller
Copy link
Member Author

/test unit lint images e2e-agnostic-operator

@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator

@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator e2e-agnostic-ovn-upgrade-into-change e2e-agnostic-ovn-upgrade-into-change-techpreview

@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch from edc4c45 to e3c7151 Compare May 9, 2025 13:46
@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator e2e-agnostic-ovn-upgrade-into-change e2e-agnostic-ovn-upgrade-into-change-techpreview

@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch from e3c7151 to 3fa96aa Compare May 12, 2025 14:58
@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator e2e-agnostic-ovn-upgrade-into-change e2e-agnostic-ovn-upgrade-into-change-techpreview lint images unit

@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch from 3fa96aa to 1fb5c12 Compare May 12, 2025 15:12
@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator e2e-agnostic-ovn-upgrade-into-change e2e-agnostic-ovn-upgrade-into-change-techpreview lint images unit

@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch from 1fb5c12 to 0c045a3 Compare May 12, 2025 15:15
@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator e2e-agnostic-ovn-upgrade-into-change e2e-agnostic-ovn-upgrade-into-change-techpreview lint images unit

@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch 4 times, most recently from 6121d53 to 5ec3e49 Compare May 13, 2025 13:31
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 13, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

The code to set up informers is messy so this change attempts to make it more consistent:

  • Alias all informer-related imports to somethinginformers
  • Everything made by NewSharedInformerFactory methods is now called somethingInformerFactory
  • Name factories in Context consistently: SomethingFactory
  • Document the purpose of individual factories in Context
  • Reorder code into clusters that deal with individual factory types

OTA-1531 will need the config.openshift.io group lister early in the CVO execution and outside of the Context structure, so this commit moves the necessary preparation code outside of NewControllerContext and passes these factories into it as parameters. Constructing factories at separate places is a little awkward but for now I try keeping the change small instead of trying to invent some centralized informer factory management. I think it is reasonable to treat config.openshift.io informers separately if they are actually used separately.


NewFilteredSharedInformerFactory is deprecated and can be replaced by NewSharedInformerFactoryWithOptions, where the filter is expressed as TweakListOption. The direct FieldSelector equality can be replaced with the OneTermEqualSelector helper.


Address an earlier review comment: #1188 (comment)

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 openshift-eng/jira-lifecycle-plugin repository.

@petr-muller petr-muller marked this pull request as ready for review May 13, 2025 13:32
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 13, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

The code to set up informers is messy so this change attempts to make it more consistent:

  • Alias all informer-related imports to somethinginformers
  • Everything made by NewSharedInformerFactory methods is now called somethingInformerFactory
  • Name factories in Context consistently: SomethingFactory
  • Document the purpose of individual factories in Context
  • Reorder code into clusters that deal with individual factory types

OTA-1531 will need the config.openshift.io group lister early in the CVO execution and outside of the Context structure, so this commit moves the necessary preparation code outside of NewControllerContext and passes these factories into it as parameters. Constructing factories at separate places is a little awkward but for now I try keeping the change small instead of trying to invent some centralized informer factory management. I think it is reasonable to treat config.openshift.io informers separately if they are actually used separately.


NewFilteredSharedInformerFactory is deprecated and can be replaced by NewSharedInformerFactoryWithOptions, where the filter is expressed as TweakListOption. The direct FieldSelector equality can be replaced with the OneTermEqualSelector helper.


Address an earlier review comment: #1188 (comment)

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2025
@petr-muller
Copy link
Member Author

/test lint

@petr-muller
Copy link
Member Author

/cc @hongkailiu

@openshift-ci openshift-ci bot requested a review from hongkailiu May 13, 2025 13:39
@DavidHurta
Copy link
Contributor

Happy to review this today/tomorrow.

/cc

@openshift-ci openshift-ci bot requested a review from DavidHurta May 13, 2025 13:57

coInformer := sharedInformers.Config().V1().ClusterOperators()
coInformer := clusterVersionConfigInformerFactory.Config().V1().ClusterOperators()
Copy link
Member Author

@petr-muller petr-muller May 13, 2025

Choose a reason for hiding this comment

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

this is wrong, this should be configInformerFactory, not the cv one

Copy link
Member Author

@petr-muller petr-muller May 13, 2025

Choose a reason for hiding this comment

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

but now the names at least make that visible

The code to set up informers is messy so this change attempts to make it
more consistent:

- Alias all informer-related imports to `somethinginformers`
- Everything made by `NewSharedInformerFactory` methods is now called `somethingInformerFactory`
- Name factories in `Context` consistently: `SomethingFactory`
- Document the purpose of individual factories in `Context`
- Reorder code into clusters that deal with individual factory types
OTA-1531 will need the config.openshift.io group lister early in the CVO
execution and outside of the `Context` structure, so this commit moves
the necessary preparation code outside of `NewControllerContext` and
passes these factories into it as parameters. Constructing factories at
separate places is a little awkward but for now I try keeping the change
small instead of trying to invent some centralized informer factory
management. I think it is reasonable to treat config.openshift.io
informers separately if they are actually used separately.
`NewFilteredSharedInformerFactory` is deprecated and can be replaced by
`NewSharedInformerFactoryWithOptions`, where the filter is expressed as
`TweakListOption`. The direct `FieldSelector` equality can be replaced
with the `OneTermEqualSelector` helper.
Address an earlier review comment: openshift#1188 (comment)
@petr-muller petr-muller force-pushed the ota-1531-04-extract-informer-factories branch from 5ec3e49 to 61ca445 Compare May 13, 2025 16:00
Copy link
Contributor

openshift-ci bot commented May 13, 2025

@petr-muller: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-agnostic-ovn-upgrade-into-change-techpreview 0c045a3 link true /test e2e-agnostic-ovn-upgrade-into-change-techpreview

Full PR test history. Your PR dashboard.

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.

@petr-muller
Copy link
Member Author

/retest

Copy link
Contributor

@DavidHurta DavidHurta left a comment

Choose a reason for hiding this comment

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

Looks good to me.

/hold

Putting on hold in case @hongkailiu is in mid-review or wanted to review these changes personally. However, two approvals are plenty for such changes, IMO. Feel free to unhold 🤷

@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 May 14, 2025
@DavidHurta
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 14, 2025
Copy link
Contributor

openshift-ci bot commented May 14, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DavidHurta, petr-muller

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [DavidHurta,petr-muller]

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

Copy link
Member

@hongkailiu hongkailiu left a comment

Choose a reason for hiding this comment

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

LGTM

OpenshiftConfigManagedInformerFactory informers.SharedInformerFactory
InformerFactory externalversions.SharedInformerFactory
OperatorInformerFactory operatorexternalversions.SharedInformerFactory
// ClusterVersionInformerFactory should be used to get informers / listers for code that works with ClusterVersion resource
Copy link
Member

@hongkailiu hongkailiu May 14, 2025

Choose a reason for hiding this comment

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

I love those comments. Thanks.

// singleton in the cluster.
ClusterVersionInformerFactory configinformers.SharedInformerFactory
// ConfigInformerFactory should be used to get informers / listers for code that works with resources from the
// config.openshift.io group, _except_ the ClusterVersion resource singleton.
Copy link
Member

Choose a reason for hiding this comment

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

I did not understand why we use another factory for CV. But this is me, need more time to read the code.
My native guess is that their configurations are different for some reason.

@hongkailiu
Copy link
Member

/hold cancel

@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 May 14, 2025
@petr-muller
Copy link
Member Author

/label no-qe

Still covered by the "will be tested on the last PR" agreement with QE

@openshift-ci openshift-ci bot added the no-qe Allows PRs to merge without qe-approved label label May 14, 2025
@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD facd6a4 and 2 for PR HEAD 61ca445 in total

@openshift-merge-bot openshift-merge-bot bot merged commit 80bd498 into openshift:main May 14, 2025
15 checks passed
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

Distgit: cluster-version-operator
This PR has been included in build cluster-version-operator-container-v4.20.0-202505151012.p0.g80bd498.assembly.stream.el9.
All builds following this will include this PR.

@petr-muller petr-muller deleted the ota-1531-04-extract-informer-factories branch May 16, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. no-qe Allows PRs to merge without qe-approved label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants