-
Notifications
You must be signed in to change notification settings - Fork 27
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
OCPCLOUD-2693: Support Capacity Reservations by adding 'CapacityReservationId' #110
OCPCLOUD-2693: Support Capacity Reservations by adding 'CapacityReservationId' #110
Conversation
42a0fa1
to
06d6c8a
Compare
Hi @athiruma. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/cc @JoelSpeed |
/ok-to-test |
@@ -1544,3 +1544,35 @@ func TestGetAvalabilityZoneTypeFromZoneName(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestGetCapacityReservationSpecification(t *testing.T) { |
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.
Ideally, all new tests would use ginkgo + gomega :)
expectedRequest: nil, | ||
}, | ||
{ | ||
name: "with a valid CapacityReservationID specified", |
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.
Is there any scenario where we may pass an invalid CapacityReservationID? Do we want some verification or testing around that?
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.
All the AWS resources start with their short resource name for example cr-***, so I thought no need for verification.
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.
You still need to verify the user input, what if they change the value to something that isn't the correct format?
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.
Done, verified that the id starts with the prefix cr-
.
Hey @athiruma, overall I think this looks good. Just a couple of comments/questions and I think it's good to go! |
1016add
to
ce5508f
Compare
pkg/actuators/machine/instances.go
Outdated
return nil, nil | ||
} | ||
|
||
if !strings.HasPrefix(capacityReservationID, "cr-") { |
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.
Are there any other validations we can apply, maximum length? Valid characters? Is there a regex we could use to validate the user input here?
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.
right resource-id will be 17char long excluding cr-
and we check regex with a mix of lower alpha
and digits
.
ce5508f
to
8d1723a
Compare
pkg/actuators/machine/instances.go
Outdated
|
||
if !re.MatchString(capacityReservationID) { | ||
// It must starts with cr-xxxxxxxxxxxxxxxxx with length of 17 characters excluding cr- | ||
return nil, mapierrors.InvalidMachineConfiguration("Invalid value for capacityReservationId: %q, it must starts with cr-", capacityReservationID) |
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.
return nil, mapierrors.InvalidMachineConfiguration("Invalid value for capacityReservationId: %q, it must starts with cr-", capacityReservationID) | |
return nil, mapierrors.InvalidMachineConfiguration("Invalid value for capacityReservationId: %q, it must starts with cr- followed by 17 lowercase hexadecimal characters", capacityReservationID) |
|
||
func TestGetCapacityReservationSpecification(t *testing.T) { | ||
mockCapacityReservationID := "cr-1234a6789d234f6f4" | ||
invalidMockCapacityReservationID := "cr-1234" |
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.
Can you try a few variations, different lengths, ones with capitals, ones with non hex digits
8d1723a
to
fd9bca8
Compare
/test golint |
fd9bca8
to
9b7869d
Compare
/test e2e-aws-operator |
name: "with invalid CapacityReservationID options specified, shorter length", | ||
capacityReservationID: capacityReservationIDShorterLength, | ||
expectedRequest: nil, | ||
expectedError: mapierrors.InvalidMachineConfiguration("Invalid value for capacityReservationId: %q, it must starts with cr-", capacityReservationIDShorterLength), |
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.
The error message here should also contain the details about the 17 characters and hexadecimal, thought I suggested that already sorry
9b7869d
to
06095c5
Compare
/approve Can you please add the relevant Jira card to the PR title please @theobarberbany can you LGTM if you're ok with this as it is now? |
[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 |
I don't have any cards. |
@athiruma You don't have any cards? What's tracking this work? There must be an epic or something so that we can co-ordinate between QE/Docs/PX about the feature. If you don't have anything, please go and make it. Who's the PM on this feature? |
@athiruma: This pull request references OCPCLOUD-2693 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 epic to target the "4.18.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. |
yup added to the title. |
/lgtm |
06095c5
to
96e5708
Compare
/test e2e-aws-serial |
/lgtm |
@athiruma: 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. |
[ART PR BUILD NOTIFIER] Distgit: ose-machine-api-provider-aws |
This PR supports the Capacity Reservation by passing the
CapaCityReservationId
to theec2. RunInstancesInput
.CapacityReservationId specifies the target Capacity Reservation into which the instance should be launched