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

Fix Remediation Events Occurrences and Names #125

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

razo7
Copy link
Member

@razo7 razo7 commented Jan 24, 2024

  • Change RemediationStarted event location and occourences
  • Test RemoveFinalizer event

Fix https://issues.redhat.com/browse/ECOPROJECT-1819

Copy link
Contributor

openshift-ci bot commented Jan 24, 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
Contributor

openshift-ci bot commented Jan 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7

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

@razo7
Copy link
Member Author

razo7 commented Jan 24, 2024

/test 4.15-openshift-e2e

@razo7 razo7 force-pushed the fix-event-remediation-started branch from be40de5 to bfa13bf Compare January 24, 2024 14:59
@razo7
Copy link
Member Author

razo7 commented Jan 24, 2024

/test 4.15-openshift-e2e

DeferCleanup(cleanupFar(), context.Background(), underTestFAR)
DeferCleanup(func() {
Expect(cleanupFar(context.Background(), underTestFAR)).To(Succeed())
deleteErr := k8sClient.Get(ctx, client.ObjectKeyFromObject(underTestFAR), &v1alpha1.FenceAgentsRemediation{})
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think that this is much different that putting the verifyEvent directly inside the cleanup function.
Is this necessary for a reason? Could we instead explicitly call the appropriate verifyEvent inside the test body?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am confused. From your last comment I understood that you prefer that I won't "hide" a check (verifyEvent(...utils.EventMessageRemoveRemediationCR)) in a function, so I took it out of from the function.

I do not think that this is much different that putting the verifyEvent directly inside the cleanup function.

I think that this way is clearer for showing that we test this verifyEvent after cleaning the CR.

Is this necessary for a reason? Could we instead explicitly call the appropriate verifyEvent inside the test body?

Normally we don't verify that the CR was deleted using this event, but it looks like a good sign. We can create a test that verifies that if a CR was created and when it is deleted then the finalizer was deleted as well. Would it make sense to follow this logic or leave it as a "step" in DeferCleanup or even as one line in cleanupFar as I introduced in the beginning?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused.

I am sorry, I should have been more clear. I was concerned by the call to verifyEvent not being in the Test body as other verifyEvent calls are. So having it in the cleanup function or called after the cleanup function, but still not in the Test body looks the same to me.

We can create a test that verifies that if a CR was created

that's too much logic in a test (that should be simple to read). My idea was that inside each Test body you should know if the CR is created or not, so you can explicitly call verifyEvent or not, without any specific check. However, I was not sure whether this is easy to do or not, that's why I asked if there was a specific reason not to do so.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, now I understand your motivation about the location of the questionable verifyEvent

My idea was that inside each Test body you should know if the CR is created or not, so you can explicitly call verifyEvent or not, without any specific check.

I am trying to test the emitting of the event remove finalizer which signifies that the CR was deleted. Until now we have identified that by searching and not finding the CR, and using verifyEvent is just another way to verify that. It is a double-check, in addition to the old one. This event should be emitted whenever the CR is deleted, thus IMO it makes sense to verify that after the old check and it can be done after each deletion of the CR.

Copy link
Contributor

Choose a reason for hiding this comment

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

we can deal with this in a next PR, not urgent to fix it here

Previously, it caused some confusion as remediation started multiple times, while it could resembles reconciliation and not remediation
Seek for FAR CR deletion event only when there isn't an API 'is not found' error'
@razo7 razo7 force-pushed the fix-event-remediation-started branch from bfa13bf to 3540b62 Compare January 28, 2024 17:18
@razo7
Copy link
Member Author

razo7 commented Jan 28, 2024

/test 4.15-openshift-e2e

@clobrano
Copy link
Contributor

as per my comment here

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 30, 2024
@razo7 razo7 marked this pull request as ready for review January 30, 2024 08:00
@razo7
Copy link
Member Author

razo7 commented Jan 30, 2024

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit fd9bded into medik8s:main Jan 30, 2024
18 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