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
CFE-1051: Add the webhook validation for "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/machine-api-operator #1234
Conversation
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@anirudhAgniRedhat: This pull request references CFE-1051 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. |
This is looking good code wise, but we should be able to get the unit and crds sync checks green, can you take a look at why those are currently not passing? |
@JoelSpeed I checked the tests are failing because I have updated the go.mod file by adding The error which has emerged as due to updating vendor that brings the latest dependency changed in The same is the reason for failing tests in openshift/machine-api-provider-azure#107
Regarding Can you suggest any fix for this? |
pkg/webhooks/machine_webhook.go
Outdated
@@ -9,6 +9,7 @@ import ( | |||
"strconv" | |||
"strings" | |||
|
|||
_ "github.com/openshift/api/machine/v1beta1/zz_generated.crd-manifests" |
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.
This goes in the tools.go
file
@@ -62,7 +62,7 @@ func TestMachineEvents(t *testing.T) { | |||
testEnv := &envtest.Environment{ | |||
CRDDirectoryPaths: []string{ | |||
filepath.Join("..", "..", "..", "install"), | |||
filepath.Join("..", "..", "..", "vendor", "github.com", "openshift", "api", "config", "v1"), | |||
filepath.Join("..", "..", "..", "tools", "vendor", "github.com", "openshift", "api", "config", "v1", "zz_generated.crd-manifests"), |
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.
Didn't expect this to be in tools
, why do we have 2 tools.go
in this repo, odd 🤔
tools/tools.go
Outdated
_ "github.com/openshift/api/config/v1/zz_generated.crd-manifests" | ||
_ "github.com/openshift/api/machine/v1beta1/zz_generated.crd-manifests" |
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.
Move these to the root tools.go
not this version, not sure why they are separate but it will be cleaner in that top level one. It will remove the need to have two o/api
dependencies that could drift
This reverts commit f7ecd28.
Changes LGTM bar the replace statement for the API dep, so lets try get this tested with QE and the other 2 PRs |
pkg/webhooks/machine_webhook.go
Outdated
if providerSpec.CapacityReservationGroupID != "" && !validateAzureImmutabilityForCapacityReservationGroupID(oldProviderSpec.CapacityReservationGroupID, providerSpec.CapacityReservationGroupID) { | ||
errs = append(errs, field.Invalid(field.NewPath("providerSpec", "capacityReservationGroupID"), | ||
providerSpec.CapacityReservationGroupID, "capacityReservationGroupID is immutable")) | ||
} |
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.
Will this execute on only Machines or also MachineSets?
We don't typically validate immutability inside providerSpecs since the type is re-used across the Machines and MachineSets and I don't believe we distinguish between the two when this validation code is called
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.
@JoelSpeed This is used in both machine and machineset
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.
It shouldn't validate machinesets?
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.
We don't want to validate this as immutable here, since it would affect both machines and machinesets. Lets drop this. With most fields in the machine provider spec, they can be updated, but take no effect, this is standard
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.
So should we remove the immutability validation from everywhere? or this validation should be added somewhere else?
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.
Only downstream, for this feature yes. Where else is it?
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.
it is written in openshift/api#1866 in godocs should be remove it from there as well.
@@ -22,7 +22,7 @@ import ( | |||
|
|||
const ( | |||
globalInfrastuctureName = "cluster" | |||
openshiftConfigNamespace = "openshift-config" | |||
openshiftConfigNamespace = "openshift-config-1" |
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.
What is significance of this new namespace?
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.
@TrilokGeer Have to update this because the existing suite test was failing because the old namespace is forbidden to delete.
This reverts commit 41c1c37.
@JoelSpeed I have reverted the commit for immutability |
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.
/approve
/lgtm
[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 |
@anirudhAgniRedhat: The following tests 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. |
e5c34fe
into
openshift:master
[ART PR BUILD NOTIFIER] This PR has been included in build ose-machine-api-operator-container-v4.17.0-202405221910.p0.ge5c34fe.assembly.stream.el9 for distgit ose-machine-api-operator. |
https://issues.redhat.com/browse/OCPBUGS-34391: Revert #1234 "CFE-1051: Add the webhook validation for \"CapacityReservationGroupID\" to \"AzureMachineProviderSpec\" in openshift/machine-api-operator"
add the webhook validation for the "CapacityReservationGroupID" field of "AzureMachineProviderSpec" in openshift/machine-api-operator so that Azure capacity reservation can be supported
This is follow-up PR for openshift/api#1866
I have to update the go.mod file to replace openshift/api dependency as the api PR is not merged yet.
I will update the vendor and go.mod file once the reviewers are good with the implementations.
we can merge API PR and remove dependency.