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

OCPCLOUD-2646: MachineSetSync controller: tests #230

Merged

Conversation

theobarberbany
Copy link
Contributor

@theobarberbany theobarberbany commented Nov 5, 2024

This PR adds tests outside of the happy path for the MachineSetSync controller going in the direction from capi -> mapi

#221 should merge before this.

@theobarberbany theobarberbany marked this pull request as draft November 5, 2024 13:16
@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 Nov 5, 2024
@openshift-ci openshift-ci bot requested review from elmiko and nrb November 5, 2024 13:17
@theobarberbany theobarberbany force-pushed the ms-capi2mapi-test branch 4 times, most recently from 2d774b6 to 6e83d24 Compare November 6, 2024 17:05
Comment on lines 365 to 409
// I think there may be another case here, where we have had it previously set - synchronized and then it gets unset.
// We may want to ensure that we don't change resourceVersion, and that the condition does not change?
// Changes to false with a failure reason?
//
// I'm not sure if we have an API validation that stops this.
// TODO: clarify / work out
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we have validation to say that it cannot be cleared once populated, but lets check that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have a validation currently, here's where I've looked:

https://github.com/openshift/api/blob/master/machine/v1beta1/types_machineset.go#L158-L167

looks like we've got one that forces moving through Migrating on the status.

https://github.com/openshift/api/blob/master/machine/v1beta1/types_machineset.go#L64-L77

on the spec we say it must be one of CAPI or MAPI.

I'm not sure I see anything stopping a particularly determined user from manually editing the status? Or am I missing something

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should add a validation to make sure the field cannot be removed once set 🤔

Copy link
Member

Choose a reason for hiding this comment

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

So adding something like:

// +kubebuilder:validation:XValidation:rule="self != '' || oldSelf == ''",message="Once authoritativeAPI is set, it cannot be unset."

to the API?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're very close to what we would need. But... if someone completely removes a field, then the validations do not run. So you need a validation similar to this on a higher level, nearest, absolutely required field, so that even if the field itself is attempted to be removed, the validation will still execute

Copy link
Member

@damdo damdo Nov 8, 2024

Choose a reason for hiding this comment

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

I see so setting this at the top of MachineSetStatus
and:

// +kubebuilder:validation:XValidation:rule="self.authoritativeAPI != '' || oldSelf.authoritativeAPI == ''",message="The authoritativeAPI field cannot be unset once it has been set."

?

And if this is the right approach, will this also pass validation in case of creation without authoritativeAPI set?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, something like that should work. Since it includes oldSelf, it's considered a transition rule, and therefore doesn't execute on create. So a status without a valid value on create will be accepted still, which is what we need

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 395 to 436
// Do we have another case here where we consistently want to not see a MAPI MachineSet created?
// Not sure if this is overkill

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say consistently no new MAPI MachineSets seems reasonable yes, in the future we may decide to change that behaviour so we should test it, as we have decided it for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most of a test for this in WIP commit.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2024
@theobarberbany theobarberbany changed the title MachineSetSync controller: tests OCPCLOUD-2646: MachineSetSync controller: tests Nov 7, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 7, 2024

@theobarberbany: This pull request references OCPCLOUD-2646 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.18.0" version, but no target version was set.

In response to this:

This PR adds tests outside of the happy path for the MachineSetSync controller going in the direction from capi -> mapi

#221 should merge before this.

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 7, 2024
@theobarberbany theobarberbany force-pushed the ms-capi2mapi-test branch 5 times, most recently from 92de073 to 08e22ce Compare November 7, 2024 18:27
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2024
@theobarberbany theobarberbany force-pushed the ms-capi2mapi-test branch 2 times, most recently from e2f7b4f to 0cc991e Compare November 7, 2024 22:21
@theobarberbany theobarberbany marked this pull request as ready for review November 7, 2024 22:33
@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 Nov 7, 2024
@openshift-ci openshift-ci bot requested a review from damdo November 7, 2024 22:34
Comment on lines 436 to 442
// It("should not create a MAPI MachineSet", func() {
// Consistently(k.ObjectList(&machinev1beta1.MachineSetList{}), timeout).ShouldNot(
// ContainElement(WithTransform(
// func(ms machinev1beta1.MachineSet) string {
// return ms.GetName()
// }, Equal(capiMachineSet.GetName()))))
// })
Copy link
Contributor

Choose a reason for hiding this comment

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

I think something along the lines of

Suggested change
// It("should not create a MAPI MachineSet", func() {
// Consistently(k.ObjectList(&machinev1beta1.MachineSetList{}), timeout).ShouldNot(
// ContainElement(WithTransform(
// func(ms machinev1beta1.MachineSet) string {
// return ms.GetName()
// }, Equal(capiMachineSet.GetName()))))
// })
It("should not create a MAPI MachineSet", func() {
Consistently(k.ObjectList(&machinev1beta1.MachineSetList{}), timeout).ShouldNot(
ContainElement(HaveField("ObjectMeta.Name", Equal(capiMachineSet.GetName()))),
),
)
})

Copy link
Member

Choose a reason for hiding this comment

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

Ended up with:

It("should not create a MAPI MachineSet", func() {
  Consistently(k.ObjectList(&machinev1beta1.MachineSetList{}), timeout).ShouldNot(HaveField("Items",
	  ContainElement(HaveField("ObjectMeta.Name", Equal(capiMachineSet.GetName()))),
  ))
})

@damdo
Copy link
Member

damdo commented Nov 8, 2024

@JoelSpeed I pushed, in a new commit, the changes we agreed on and slightly reorged the contexts to deduplicate some setups like the MachineSet creation. LMK if they look ok and I'll cleanup the history and get ready for labelling.

@damdo damdo force-pushed the ms-capi2mapi-test branch from 9c517ae to 393a17c Compare November 8, 2024 18:07
@JoelSpeed
Copy link
Contributor

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2024
Copy link
Contributor

openshift-ci bot commented Nov 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 8, 2024
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 3953a2a and 2 for PR HEAD 393a17c in total

@damdo
Copy link
Member

damdo commented Nov 8, 2024

/skip

Copy link
Contributor

openshift-ci bot commented Nov 9, 2024

@theobarberbany: The following tests 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/regression-clusterinfra-cucushift-rehearse-capi-aws-ipi 393a17c link false /test regression-clusterinfra-cucushift-rehearse-capi-aws-ipi
ci/prow/e2e-azure-ovn-techpreview 393a17c link false /test e2e-azure-ovn-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.

@openshift-merge-bot openshift-merge-bot bot merged commit ec9120b into openshift:main Nov 9, 2024
18 checks passed
@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

Distgit: ose-cluster-capi-operator
This PR has been included in build ose-cluster-capi-operator-container-v4.18.0-202411090139.p0.gec9120b.assembly.stream.el9.
All builds following this will include this PR.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants