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

Separate nm status initalization from update #123

Merged

Conversation

razo7
Copy link
Member

@razo7 razo7 commented Feb 28, 2024

What this PR does / why we need it:

Take out the nm CR update from the initMaintenanceStatus function so the function can easily be tested (and succeeded) in UTs.
to only nm status initialization and update is done afterward. It is mostly needed for UTs of the initMaintenanceStatus function

Changes made

Separation of initMaintenanceStatus logic to only nm status initialization and update is done only afterwards. It is mostly needed for UTs of the initMaintenanceStatus function

Which issue(s) this PR fixes:

Follow up for comment

Copy link
Contributor

openshift-ci bot commented Feb 28, 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

@razo7
Copy link
Member Author

razo7 commented Feb 28, 2024

/test 4.15-openshift-e2e

if err != nil {
if errUpdate := r.Client.Status().Update(ctx, nm); errUpdate != nil {
Copy link
Member

Choose a reason for hiding this comment

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

why do you update the status here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it was suggested to move the status update outside the initialization function so this function can be used in unit tests. The function fails in the unit test when the update fails.
But we don't need to update it only when there is an initialization error...

if err != nil {
if errUpdate := r.Client.Status().Update(ctx, nm); errUpdate != nil {
err = fmt.Errorf("errUpdate %w - %w", errUpdate, err)
Copy link
Member

Choose a reason for hiding this comment

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

will this result in a useful log line? 🤔

Separation of initMaintenanceStatus logic to only nm status initialization and update is done only afterwards. It is mostly needed for UTs of the initMaintenanceStatus function
@razo7 razo7 force-pushed the separate-nm-status-initalization branch from 80b4e31 to ac116be Compare February 29, 2024 06:42
@razo7
Copy link
Member Author

razo7 commented Feb 29, 2024

/test 4.15-openshift-e2e

InitMaintenanceStatus initializes the nm CR status only at the first time, when phase is empty, and it returns a bool whether we should update the CR status and an error if it can't be initialized. Without this change an update to CR will happen at the beginning of every reconcile call
@razo7 razo7 force-pushed the separate-nm-status-initalization branch from 7366dfa to b84b512 Compare March 1, 2024 06:08
Only checking the error is not good enough to verify whether the function can set/initalize the stauts
@razo7
Copy link
Member Author

razo7 commented Mar 4, 2024

/test 4.15-openshift-e2e

@openshift-ci openshift-ci bot added the lgtm label Mar 4, 2024
@razo7 razo7 marked this pull request as ready for review March 4, 2024 15:02
@openshift-ci openshift-ci bot requested review from beekhof and clobrano March 4, 2024 15:02
@razo7
Copy link
Member Author

razo7 commented Mar 4, 2024

/retest

Copy link
Contributor

openshift-ci bot commented Mar 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clobrano, razo7, slintes

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 [clobrano,razo7,slintes]

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

@razo7
Copy link
Member Author

razo7 commented Mar 5, 2024

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit aafaa8b into medik8s:main Mar 5, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants