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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

anirudhAgniRedhat
Copy link

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

Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@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
Copy link
Contributor

openshift-ci bot commented Apr 23, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: anirudhAgniRedhat
Once this PR has been reviewed and has the lgtm label, please assign mfojtik 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

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

Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@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 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
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
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
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

Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@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
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.

Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
@JoelSpeed
Copy link
Contributor

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

@anirudhAgniRedhat
Copy link
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
Signed-off-by: anirudhAgniRedhat <aagnihot@redhat.com>
Copy link
Contributor

openshift-ci bot commented Apr 25, 2024

@anirudhAgniRedhat: all tests passed!

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/test-infra repository. I understand the commands that are listed here.

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

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. 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