Skip to content
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

components: provide common interface #1375

Conversation

ykaliuta
Copy link
Contributor

@ykaliuta ykaliuta commented Nov 18, 2024

Decouple components and main code of operator with ComponentHandler
interface. It allows to hanle all common operations in a unique way
and add components without changing main/dsc code. At the moment
they are initialization, controller creation and fetching some
component specific values (name, management status and corresponding
CR). For the latter the code basically copy'n'paste unfortunately.

Use init() functionality to register components only. It requires
linter silencing and explicit importing them in main.go otherwise
init() is not called.

Also non-recommended approach (and linter silencing) of returning
interface is used to return component specific CR as common
client.Object to simplify the code in DSC reconciler. Otherwise one
more level of indirection is needed with passing required
functionality (closure) to the interface function.

Signed-off-by: Yauheni Kaliuta [email protected]

Description

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link

openshift-ci bot commented Nov 18, 2024

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

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Please upload report for BASE (feature-operator-refactor@e980df6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...atasciencecluster/datasciencecluster_controller.go 0.00% 15 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##             feature-operator-refactor    #1375   +/-   ##
============================================================
  Coverage                             ?   26.85%           
============================================================
  Files                                ?       55           
  Lines                                ?     4428           
  Branches                             ?        0           
============================================================
  Hits                                 ?     1189           
  Misses                               ?     3098           
  Partials                             ?      141           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@ykaliuta ykaliuta force-pushed the fold-components-iterations branch 4 times, most recently from 5769724 to eb46cb8 Compare November 19, 2024 13:32
@ykaliuta ykaliuta changed the title fold component handling with an interface components: provide common interface Nov 19, 2024
@ykaliuta ykaliuta marked this pull request as ready for review November 19, 2024 13:33
@ykaliuta
Copy link
Contributor Author

/cc @lburgazzoli

@openshift-ci openshift-ci bot requested a review from lburgazzoli November 19, 2024 13:40
}
componentErrors := cr.ForEach(func(component cr.ComponentHandler) error {
var err error
// TODO: check instance updating
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should be revisited, e2e-tests shows problem here.

main.go Outdated Show resolved Hide resolved
Decouple components and main code of operator with ComponentHandler
interface. It allows to hanle all common operations in a unique way
and add components without changing main/dsc code. At the moment
they are initialization, controller creation and fetching some
component specific values (name, management status and corresponding
CR). For the latter the code basically copy'n'paste unfortunately.

Use init() functionality to register components only. It requires
linter silencing and explicit importing them in main.go otherwise
init() is not called.

Non-recommended approach (and linter silencing) of returning
interface is used to return component specific CR as common
client.Object to simplify the code in DSC reconciler. Otherwise one
more level of inderection is needed with passing required
functionality (closure) to the interface function.

Signed-off-by: Yauheni Kaliuta <[email protected]>
@ykaliuta ykaliuta force-pushed the fold-components-iterations branch from 39a476f to c6a4c3e Compare November 20, 2024 09:35
Copy link

openshift-ci bot commented Nov 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lburgazzoli

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:

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

@lburgazzoli
Copy link
Contributor

/hold

@lburgazzoli
Copy link
Contributor

lburgazzoli commented Nov 20, 2024

@ykaliuta set to "on hold" just to avoid disruption on other components, I'll update the PR with the new component as they re merged if you agree

@ykaliuta
Copy link
Contributor Author

@ykaliuta set to "on hold" just to avoid disruption on other components, I'll update the PR with the new component as they re merged if you agree

Up to you, but I think it should go other way around. It's a pretty small change to a component to rebase on top on it.

@lburgazzoli
Copy link
Contributor

/unhold

@openshift-merge-bot openshift-merge-bot bot merged commit d044d64 into opendatahub-io:feature-operator-refactor Nov 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants