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-1047: Add the field "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/api #1866

Conversation

anirudhAgniRedhat
Copy link
Contributor

@anirudhAgniRedhat anirudhAgniRedhat commented Apr 23, 2024

This PR adds the support of capacity reservation group in AzureMachineProviderSpec. A new field, CapacityReservationGroupID, is added. This ID is used while creating the corresponding Azure VM and the VM is added to the capacity reservation group.

The capacity reservation group should already exist. Once the VM is created and associated to the capacity reservation group it cannot be removed from the group. Similarly, if a VM is created without any association to a capacity reservation group then it cannot be associated to one later on. Thus, CapacityReservationGroupID field is made immutable.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 23, 2024

@anirudhAgniRedhat: This pull request references CFE-1046 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 spike to target the "4.16.0" version, but no target version was set.

In response to this:

This PR adds the support of capacity reservation group in AzureMachineSpec. A new field, CapacityReservationGroupID, is added. This ID is used while creating the corresponding Azure VM and the VM is added to the capacity reservation group.

The capacity reservation group should already exist. Once the VM is created and associated to the capacity reservation group it cannot be removed from the group. Similarly, if a VM is created without any association to a capacity reservation group then it cannot be associated to one later on. Thus, CapacityReservationGroupID field is made immutable.

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 Apr 23, 2024
Copy link
Contributor

openshift-ci bot commented Apr 23, 2024

Hello @anirudhAgniRedhat! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 23, 2024
@anirudhAgniRedhat anirudhAgniRedhat changed the title CFE-1046: Add the field "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/api CFE-1047: Add the field "CapacityReservationGroupID" to "AzureMachineProviderSpec" in openshift/api Apr 23, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 23, 2024

@anirudhAgniRedhat: This pull request references CFE-1047 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:

This PR adds the support of capacity reservation group in AzureMachineSpec. A new field, CapacityReservationGroupID, is added. This ID is used while creating the corresponding Azure VM and the VM is added to the capacity reservation group.

The capacity reservation group should already exist. Once the VM is created and associated to the capacity reservation group it cannot be removed from the group. Similarly, if a VM is created without any association to a capacity reservation group then it cannot be associated to one later on. Thus, CapacityReservationGroupID field is made immutable.

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 openshift-ci bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 23, 2024
@arkadeepsen
Copy link
Contributor

This PR adds the support of capacity reservation group in AzureMachineSpec.

AzureMachineSpec -> AzureMachineProviderSpec

machine/v1beta1/types_azureprovider.go Outdated Show resolved Hide resolved
machine/v1beta1/types_azureprovider.go Outdated Show resolved Hide resolved
// used for allocating the virtual machine.
// +kubebuilder:validation:XValidation:rule="oldSelf == '' || self == oldSelf",message="CapacityReservationGroupID is immutable once set"
// +optional
CapacityReservationGroupID string `json:"capacityReservationGroupID,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the format of the reservation group ID? What characters are valid? What is the minimal and maximal length?

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 I found this is the format for Capacity reservation Group ID

I guess resourceGroupName and CapacityReservationGroupName may vary on differen Users.
subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/<CapacityReservationGroupName>

Also didn't found maximum and minimum length for ID in AzureDocs.

Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/capacity-reservation-create?tabs=cli1%2Capi1%2Capi2#create-a-capacity-reservation-1

Copy link
Contributor

Choose a reason for hiding this comment

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

In the upstream implementation, there is a validation implemented via a webhook, can you explain what that validation is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if err := webhookutils.ValidateImmutable(
		field.NewPath("spec", "capacityReservationGroupID"),
		old.Spec.CapacityReservationGroupID,
		m.Spec.CapacityReservationGroupID); err != nil {
		allErrs = append(allErrs, err)
	}

this insures that the field is immutable and cannot be updated once set.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's also a validation that it is a valid azure ID no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there is a validation on pattern, that the input must be string having length more than 0,
Also the string should start with "/".

The keys which are used should be among "subscriptions", "providers" and "resourcegroups" following by valid ID or names respectively.

the ideal format for ID is /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/<CapacityReservationGroupName>

I did not find check that the input provided is valid ID. It Just checks for the format of the input provided, does not insure the IDs or names provides are correct.

https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/4698/files#diff-222a5b91649bbd8b784ec4d5476460390cc2f7e5839e63a968d719b3484ace68R467

@JoelSpeed I have added the commit to call out validations in doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah so I think we want to use the ParseResourceID as well, but, for that to pass, I need to understand, as an end user, what a valid input is. So, I'd like to have some text that explains what a valid input to that validation is

Copy link
Contributor

Choose a reason for hiding this comment

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

I see you've updated the description, looks good

@openshift-ci openshift-ci bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 23, 2024
@anirudhAgniRedhat
Copy link
Contributor Author

/retest-required

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 24, 2024

@anirudhAgniRedhat: This pull request references CFE-1047 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:

This PR adds the support of capacity reservation group in AzureMachineProviderSpec. A new field, CapacityReservationGroupID, is added. This ID is used while creating the corresponding Azure VM and the VM is added to the capacity reservation group.

The capacity reservation group should already exist. Once the VM is created and associated to the capacity reservation group it cannot be removed from the group. Similarly, if a VM is created without any association to a capacity reservation group then it cannot be associated to one later on. Thus, CapacityReservationGroupID field is made immutable.

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

@anirudhAgniRedhat Do you have an implementation for this API that's ready to merge shortly after?

@anirudhAgniRedhat
Copy link
Contributor Author

@JoelSpeed I will start working on its implementation from now onwards as we merge this PR.

Copy link
Contributor

@arkadeepsen arkadeepsen left a comment

Choose a reason for hiding this comment

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

@JoelSpeed do these nits look good to be added?

machine/v1beta1/types_azureprovider.go Outdated Show resolved Hide resolved
machine/v1beta1/types_azureprovider.go Outdated Show resolved Hide resolved
@JoelSpeed
Copy link
Contributor

Yeah lets get those added

Also, since we are close to the feature freeze date, I'd like to see the feature tested end to end by QE before we merge the API, else we risk shipping an API in one release with no implementation. Please link a WIP PR here once you have it

@arkadeepsen
Copy link
Contributor

Yeah lets get those added

Also, since we are close to the feature freeze date, I'd like to see the feature tested end to end by QE before we merge the API, else we risk shipping an API in one release with no implementation. Please link a WIP PR here once you have it

Sure @JoelSpeed

@anirudhAgniRedhat
Copy link
Contributor Author

Yeah lets get those added

Also, since we are close to the feature freeze date, I'd like to see the feature tested end to end by QE before we merge the API, else we risk shipping an API in one release with no implementation. Please link a WIP PR here once you have it

@JoelSpeed This is WIP PR for its implementation openshift/machine-api-provider-azure#107

Comment on lines 153 to 154
// It is optional but may not be changed once set.
// +kubebuilder:validation:XValidation:rule="oldSelf == '' || self == oldSelf",message="CapacityReservationGroupID is immutable once set"
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop these, they won't be able to be implemented within MAPI

@openshift-ci openshift-ci bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 14, 2024
@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 14, 2024
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@anirudhAgniRedhat anirudhAgniRedhat force-pushed the anirudh/CapcityReservationGroupID branch from daa4568 to d551387 Compare May 14, 2024 13:40
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.

/lgtm

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

openshift-ci bot commented May 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anirudhAgniRedhat, 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 14, 2024
@anirudhAgniRedhat
Copy link
Contributor Author

@JoelSpeed The PR requireacknowledge-critical-fixes-only label to merge it before 4.16 release If you feel we Should merge it Could you please add the label?

@JoelSpeed
Copy link
Contributor

Considering proximity to the release branch cut off, and the fact that TRT have had to introduce the critical fixes requirement. I'm inclined to say we should slip this feature to 4.17, do you see that causing an issue?

@anirudhAgniRedhat
Copy link
Contributor Author

Considering proximity to the release branch cut off, and the fact that TRT have had to introduce the critical fixes requirement. I'm inclined to say we should slip this feature to 4.17, do you see that causing an issue?

As this feature is anyway planed for 4.17, we should be good.

@openshift-merge-bot openshift-merge-bot bot merged commit 8af21b7 into openshift:master May 21, 2024
9 checks passed
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants