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

MULTIARCH-4304: Add validation for the name of the PodPlacementConfig… #72

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AnnaZivkovic
Copy link
Contributor

… so there can only be one cluster

Unfortunately, make manifests overrides manually adding validation (example here) in multiarch.openshift.io_podplacementconfigs.yaml.

The only issue with using +kubebuilder:validation:XValidation:rule is the error message is not as nicely formatted as shown
Screenshot from 2024-04-11 13-37-40

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 11, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 11, 2024

@AnnaZivkovic: This pull request references MULTIARCH-4304 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.16.0" version, but no target version was set.

In response to this:

… so there can only be one cluster

Unfortunately, make manifests overrides manually adding validation (example here) in multiarch.openshift.io_podplacementconfigs.yaml.

The only issue with using +kubebuilder:validation:XValidation:rule is the error message is not as nicely formatted as shown
Screenshot from 2024-04-11 13-37-40

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

openshift-ci bot commented Apr 11, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign prashanth684 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@aleskandro
Copy link
Member

The error doesn't look so bad to me and the solution is quick enough to cover the problem for now.

The alternative is to hack the Makefile target so that the CRD yaml is patched after all the other steps execute: we're needing it in https://github.com/openshift/multiarch-tuning-operator/pull/70/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52R291 (as per suggestions in some operator-framework threads internally), but I like that even less.

What's the field the API is considering to be <nil>? Any way we can change it?

@aleskandro
Copy link
Member

@AnnaZivkovic, remember that we also have to remove any previous code that was checking the name in the pod placement config controller.

Also, let's check the integration test cases, patch any that were already verifying the previous work, or add at least one integration/unit test that verifies CR with a wrong name cannot be created

@AnnaZivkovic AnnaZivkovic force-pushed the validate-operands-deletion-from-console branch from 6968310 to f1ec914 Compare April 16, 2024 20:40
@AnnaZivkovic
Copy link
Contributor Author

@aleskandro are you talking about removing the logic here and the stuff below it?

@aleskandro
Copy link
Member

From line 100 in particular. But yes, we could even delete that if statement that you linked as we can assume the name of the object will always be the correct one

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 19, 2024
@AnnaZivkovic AnnaZivkovic force-pushed the validate-operands-deletion-from-console branch 2 times, most recently from 8049645 to 5fa6d5b Compare April 23, 2024 19:57
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2024
@AnnaZivkovic AnnaZivkovic force-pushed the validate-operands-deletion-from-console branch from 5fa6d5b to 590fb53 Compare April 23, 2024 20:09
@AnnaZivkovic
Copy link
Contributor Author

/retest-required

@@ -179,7 +179,7 @@ var _ = Describe("Controllers/PodPlacementConfig/PodPlacementConfigReconciler",
It("should refuse to create a PodPlacementConfig with an invalid name", func() {
ppc := newPodPlacementConfig().WithName("invalid-name").Build()
err := k8sClient.Create(ctx, ppc)
Expect(err).NotTo(HaveOccurred(), "failed to create PodPlacementConfig", err)
Expect(err).NotTo(HaveOccurred(), "fcc", err)
Copy link
Member

Choose a reason for hiding this comment

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

should an error rather occur? If we try to create a PodPlacementConfig with a wrong name, the API should deny the request, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The patches dont seem to get applied until we bundle it. So it seems to be applied at a later time

Copy link
Member

Choose a reason for hiding this comment

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

g.Expect(err).To(HaveOccurred(), "An error should have been detected")
g.Expect(crclient.IgnoreNotFound(err)).NotTo(HaveOccurred(),
"The error should not be different than a NotFound error")
g.Expect(err).NotTo(HaveOccurred(), "An error should not have been detected")
Copy link
Member

Choose a reason for hiding this comment

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

And this shouldn't be needed anymore once the API reports a failure and the object is not created.

@AnnaZivkovic AnnaZivkovic force-pushed the validate-operands-deletion-from-console branch 3 times, most recently from 28f24bf to 1ec0d70 Compare April 26, 2024 22:58
@AnnaZivkovic
Copy link
Contributor Author

/retest-required

@AnnaZivkovic AnnaZivkovic force-pushed the validate-operands-deletion-from-console branch from 1ec0d70 to e7a42e9 Compare May 8, 2024 22:36
@AnnaZivkovic
Copy link
Contributor Author

/retest-required

Copy link

openshift-ci bot commented May 9, 2024

@AnnaZivkovic: 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/unit e7a42e9 link true /test unit

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants