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
base: main
Are you sure you want to change the base?
MULTIARCH-4304: Add validation for the name of the PodPlacementConfig… #72
Conversation
@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:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
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 |
@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 |
6968310
to
f1ec914
Compare
@aleskandro are you talking about removing the logic here and the stuff below it? |
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 |
8049645
to
5fa6d5b
Compare
… using JSON patches
5fa6d5b
to
590fb53
Compare
/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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs some update as it can't consider patches as of now.
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") |
There was a problem hiding this comment.
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.
28f24bf
to
1ec0d70
Compare
/retest-required |
1ec0d70
to
e7a42e9
Compare
/retest-required |
@AnnaZivkovic: The following test failed, say
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. |
… 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