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-1063: Add PlacementGroupPartition in AWSMachineProviderConfig #1897

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

chiragkyal
Copy link
Member

@chiragkyal chiragkyal commented May 19, 2024

Add a new field PlacementGroupPartition in AWSMachineProviderConfig to allow users specify the Partition Number of placement group for AWSMachine

Related to https://issues.redhat.com/browse/CFE-1063

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2024
Copy link
Contributor

openshift-ci bot commented May 19, 2024

Hello @chiragkyal! 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.

Copy link
Contributor

openshift-ci bot commented May 19, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 19, 2024
@chiragkyal
Copy link
Member Author

/test all

@chiragkyal chiragkyal changed the title [WIP] Add PlacementGroupPartition of placement group Add PlacementGroupPartition in AWSMachineProviderConfig Jun 5, 2024
@chiragkyal chiragkyal marked this pull request as ready for review June 5, 2024 12:34
@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 Jun 5, 2024
@chiragkyal chiragkyal changed the title Add PlacementGroupPartition in AWSMachineProviderConfig CFE-1063: Add PlacementGroupPartition in AWSMachineProviderConfig Jun 5, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 5, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jun 5, 2024

@chiragkyal: This pull request references CFE-1063 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.17.0" version, but no target version was set.

In response to this:

Add a new field PlacementGroupPartition in AWSMachineProviderConfig to allow users specify the Partition Number of placement group for AWSMachine

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 requested review from deads2k and JoelSpeed June 5, 2024 12:35
@chiragkyal
Copy link
Member Author

/assign @JoelSpeed

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jun 5, 2024

@chiragkyal: This pull request references CFE-1063 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.17.0" version, but no target version was set.

In response to this:

Add a new field PlacementGroupPartition in AWSMachineProviderConfig to allow users specify the Partition Number of placement group for AWSMachine

Related to https://issues.redhat.com/browse/CFE-1063

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.

Comment on lines 87 to 89
// PlacementGroupPartition is the partition number within the placement group in which to launch the instance.
// This value is only valid if the placement group, referred in `PlacementGroupName`, was created with
// strategy set to partition.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this field exist in the upstream CAPA?

Godoc comments should start with json tag name not Go field name, so placementGroupPartition would be better.

Godoc should also explain the validations in place, so in this case, explain in the text that the value should be an integer value between 1 and 7.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we have added the field in the upstream CAPA as well. Please see: kubernetes-sigs/cluster-api-provider-aws#4883

Copy link
Member Author

Choose a reason for hiding this comment

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

Godoc comments should start with json tag name not Go field name, so placementGroupPartition would be better.

Okay. However, I observed that the existing Godoc comments for fields like PlacementGroupName, MetadataServiceOptions, etc., are also using the Go field name. The new field should be consistent with them as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer not to repeat mistakes of the past, that just adds to tech debt

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, thanks. Updated.

// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=7
// +optional
PlacementGroupPartition int64 `json:"placementGroupPartition,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why int64? Change to int32, we only need to support small numbers here

Copy link
Member Author

Choose a reason for hiding this comment

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

The aws-sdk uses pointer to int64 to specify the partition number.
https://pkg.go.dev/github.com/aws/aws-sdk-go@v1.50.0/service/ec2#Placement.PartitionNumber

xref:

	PartitionNumber *int64 `locationName:"partitionNumber" type:"integer"`

In order to match with it and CAPA PR, I chose int64 here as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general we prefer to build APIs that make sense for us, rather than being restricted by cloud provider APIs. But given the context of this and the fact that we are going to convert to CAPI in the near future, there's value in this being the same.

Do you think there's any likelihood of being able to change the upstream to int32? Since that would make more sense for the Kube API

Copy link
Member Author

Choose a reason for hiding this comment

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

Updating it to int32 would be better, making more sense to our API. We can anyway convert it to int64 in the provider code to match with aws-sdk.

For upstream, I'll try to open a PR to fix it.

// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=7
// +optional
PlacementGroupPartition int64 `json:"placementGroupPartition,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think we should add some CEL Validation?

!(has(self.placementGroupPartition) && !(has(self.placementGroupName) && size(self.placementGroupName)>0))

message="placementGroupPartition is invalid, because placementGroupName is not set"

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use CEL in this API because it is a raw extension, but, for upstream you could try to get that through yes

Signed-off-by: chiragkyal <ckyal@redhat.com>
@JoelSpeed
Copy link
Contributor

/lgtm

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

openshift-ci bot commented Jun 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chiragkyal, 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 Jun 13, 2024
Copy link
Contributor

openshift-ci bot commented Jun 13, 2024

@chiragkyal: 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-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 76a71da into openshift:master Jun 13, 2024
9 checks passed
@chiragkyal chiragkyal deleted the partition-number branch June 13, 2024 14:19
@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-cluster-config-api-container-v4.17.0-202406131541.p0.g76a71da.assembly.stream.el9 for distgit ose-cluster-config-api.
All builds following this will include this PR.

Comment on lines +90 to +91
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=7
Copy link
Member Author

Choose a reason for hiding this comment

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

@JoelSpeed I was doing some dev testing, and it turns out that these kubebuilder validations are not working as expected while creating a MachineSet object. Do we need them to be added inside the webhook?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, kubebuilder validations won't ever work on this particular API, please add them to the webhook validations

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha! Then these kubebuilder validations can be removed from here I think. Created #1942 to drop them

Copy link
Member Author

Choose a reason for hiding this comment

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

openshift/machine-api-operator#1265 to add them into webhook validations

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.

4 participants