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

CFE-1051: Add the webhook validation for "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/machine-api-operator #1234

Conversation

anirudhAgniRedhat
Copy link
Contributor

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.

Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@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 30, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 30, 2024

@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:

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.

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.

@JoelSpeed
Copy link
Contributor

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?

@anirudhAgniRedhat
Copy link
Contributor Author

anirudhAgniRedhat commented May 1, 2024

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 replace github.com/openshift/api => github.com/anirudhAgniRedhat/openshift-api v0.0.2 and running go mod tidy and go mod vendor

The error which has emerged as due to updating vendor that brings the latest dependency changed in openshift/api repository.

The same is the reason for failing tests in openshift/machine-api-provider-azure#107

=== RUN   TestMachineEvents
I0501 22:51:16.812722   14450 session.go:91] No existing vCenter session found, creating new session
    actuator_test.go:162: 
        Expected success, but got an error:
            <*meta.NoKindMatchError | 0xc000dafd40>: 
            no matches for kind "Infrastructure" in version "config.openshift.io/v1"
            {
                GroupKind: {
                    Group: "config.openshift.io",
                    Kind: "Infrastructure",
                },
                SearchedVersions: ["v1"],
            }
--- FAIL: TestMachineEvents (4.27s)

=== RUN   TestPatchMachine
I0501 22:51:22.937439   14450 session.go:91] No existing vCenter session found, creating new session
    machine_scope_test.go:381: 
        Expected success, but got an error:
            <*meta.NoKindMatchError | 0xc0008fa8c0>: 
            no matches for kind "Infrastructure" in version "config.openshift.io/v1"
            {
                GroupKind: {
                    Group: "config.openshift.io",
                    Kind: "Infrastructure",
                },
                SearchedVersions: ["v1"],
            }
--- FAIL: TestPatchMachine (3.23s)

Regarding pull-ci-openshift-machine-api-operator-master-verify-crds-sync it is searching for vendor/github.com/openshift/api/machine/v1beta1/0000_10_machine.crd.yaml but could not find the file in updated vendor directory thats why it is giving me error as cp: cannot stat 'vendor/github.com/openshift/api/machine/v1beta1/0000_10_machine.crd.yaml': No such file or directory

Can you suggest any fix for this?
I guess after merging openshift/api#1866 and upgrading versions could fix this?
Need your review over this.

@@ -9,6 +9,7 @@ import (
"strconv"
"strings"

_ "github.com/openshift/api/machine/v1beta1/zz_generated.crd-manifests"
Copy link
Contributor

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"),
Copy link
Contributor

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
Comment on lines 8 to 9
_ "github.com/openshift/api/config/v1/zz_generated.crd-manifests"
_ "github.com/openshift/api/machine/v1beta1/zz_generated.crd-manifests"
Copy link
Contributor

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

@JoelSpeed
Copy link
Contributor

Changes LGTM bar the replace statement for the API dep, so lets try get this tested with QE and the other 2 PRs

Comment on lines 940 to 943
if providerSpec.CapacityReservationGroupID != "" && !validateAzureImmutabilityForCapacityReservationGroupID(oldProviderSpec.CapacityReservationGroupID, providerSpec.CapacityReservationGroupID) {
errs = append(errs, field.Invalid(field.NewPath("providerSpec", "capacityReservationGroupID"),
providerSpec.CapacityReservationGroupID, "capacityReservationGroupID is immutable"))
}
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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"

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?

Copy link
Contributor Author

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.

@anirudhAgniRedhat
Copy link
Contributor Author

anirudhAgniRedhat commented May 14, 2024

@JoelSpeed I have reverted the commit for immutability
As the current code architecture is not allowing to add the the immuatbility validation inside providerSpec for machine only.

@anirudhAgniRedhat anirudhAgniRedhat changed the title [WIP] CFE-1051: Add the webhook validation for "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/machine-api-operator CFE-1051: Add the webhook validation for "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/machine-api-operator May 21, 2024
@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 May 21, 2024
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

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

openshift-ci bot commented May 22, 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 May 22, 2024
Copy link
Contributor

openshift-ci bot commented May 22, 2024

@anirudhAgniRedhat: 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/e2e-metal-ipi-ovn-dualstack 31e2a4b link false /test e2e-metal-ipi-ovn-dualstack
ci/prow/e2e-azure-operator 31e2a4b link false /test e2e-azure-operator
ci/prow/e2e-vsphere-operator 31e2a4b link false /test e2e-vsphere-operator
ci/prow/e2e-vsphere-ovn 31e2a4b link false /test e2e-vsphere-ovn
ci/prow/e2e-vsphere-ovn-upgrade 31e2a4b link false /test e2e-vsphere-ovn-upgrade
ci/prow/e2e-vsphere-ovn-serial 31e2a4b link false /test e2e-vsphere-ovn-serial

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 e5c34fe into openshift:master May 22, 2024
20 of 26 checks passed
@openshift-bot
Copy link
Contributor

[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.
All builds following this will include this PR.

dgoodwin added a commit to dgoodwin/machine-api-operator that referenced this pull request May 23, 2024
…udhAgniRedhat/capacityReservationGroupIDWebhookValidation"

This reverts commit e5c34fe, reversing
changes made to dcf1387.
DennisPeriquet pushed a commit to DennisPeriquet/machine-api-operator that referenced this pull request May 23, 2024
…udhAgniRedhat/capacityReservationGroupIDWebhookValidation"

This reverts commit e5c34fe, reversing
changes made to dcf1387.
openshift-merge-bot bot added a commit that referenced this pull request May 23, 2024
https://issues.redhat.com/browse/OCPBUGS-34391: Revert #1234 "CFE-1051: Add the webhook validation for \"CapacityReservationGroupID\" to \"AzureMachineProviderSpec\" in openshift/machine-api-operator"
anirudhAgniRedhat added a commit to anirudhAgniRedhat/openshift-machine-api-operator that referenced this pull request May 23, 2024
…ift#1234 "CFE-1051: Add the webhook validation for \"CapacityReservationGroupID\" to \"AzureMachineProviderSpec\" in openshift/machine-api-operator""
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.

None yet

5 participants