-
Notifications
You must be signed in to change notification settings - Fork 38
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
Awscapi #342
base: master
Are you sure you want to change the base?
Awscapi #342
Conversation
b6329be
to
202e9ef
Compare
/retest-required |
I checked the azure failure, it should be flake, and this pr will not affect azure, so we can ignore that. |
pkg/framework/aws_client.go
Outdated
@@ -45,3 +45,41 @@ func (a *AwsClient) CancelCapacityReservation(capacityReservationID string) (boo | |||
|
|||
return ptr.Deref(result.Return, false), err | |||
} | |||
|
|||
// CreateCapacityReservation Create CapacityReservation. |
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.
should be CreatePlacementGroup
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.
updated, thank you!
pkg/capi/aws.go
Outdated
|
||
func getDefaultAWSMAPIProviderSpec(cl client.Client) (*mapiv1.MachineSet, *mapiv1.AWSMachineProviderConfig) { | ||
machineSetList := &mapiv1.MachineSetList{} | ||
Expect(cl.List(ctx, machineSetList, client.InNamespace(framework.MachineAPINamespace))).To(Succeed()) |
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.
Dam suggested use Evenutally on all cl. (client) actions instead of Expect, so we allow for retry on brief API/network hiccups. see here #337 (comment)
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.
updated, thank you!
pkg/capi/aws.go
Outdated
It("should be able to run a machine with a default provider spec", func() { | ||
awsMachineTemplate = newAWSMachineTemplate(mapiDefaultProviderSpec) | ||
if err = cl.Create(ctx, awsMachineTemplate); err != nil { | ||
Expect(err).ToNot(HaveOccurred()) |
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.
With all the .Should() and .To() (both with the Eventuallys and the Expects) could we add the optional description
#337 (comment)
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 updated, thank you!
case "us-east-1": | ||
key = "arn:aws:kms:us-east-1:301721915996:key/c471ec83-cfaf-41a2-9241-d9e99c4da344" | ||
case "us-east-2": | ||
key = "arn:aws:kms:us-east-2:301721915996:key/c228ef83-df2c-4151-84c4-d9f39f39a972" |
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 this be ran in dev's account?
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.
I checked the job result, and yes, you are right, this cannot be ran in dev's account, I just comment this case out for now and think of how to deal with it, will update in a following pr. Thank you @sunzhaohua2 PTAL again, thanks!
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.
Updated this case to skip it in dev's account.
pkg/capi/aws.go
Outdated
awsMachineSpec := awsv1.AWSMachineSpec{ | ||
UncompressedUserData: &uncompressedUserData, | ||
IAMInstanceProfile: *mapiProviderSpec.IAMInstanceProfile.ID, | ||
InstanceType: mapiProviderSpec.InstanceType, | ||
AMI: awsv1.AMIReference{ | ||
ID: mapiProviderSpec.AMI.ID, | ||
}, | ||
Ignition: &awsv1.Ignition{ | ||
Version: "3.4", | ||
StorageType: awsv1.IgnitionStorageTypeOptionUnencryptedUserData, | ||
}, | ||
Subnet: &awsv1.AWSResourceReference{ | ||
Filters: []awsv1.Filter{ | ||
{ | ||
Name: "tag:Name", | ||
Values: mapiProviderSpec.Subnet.Filters[0].Values, | ||
}, | ||
}, | ||
}, | ||
AdditionalSecurityGroups: []awsv1.AWSResourceReference{ | ||
{ | ||
Filters: []awsv1.Filter{ | ||
{ | ||
Name: "tag:Name", | ||
Values: mapiProviderSpec.SecurityGroups[0].Filters[0].Values, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
awsMachineTemplate := &awsv1.AWSMachineTemplate{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: awsMachineTemplateName, | ||
Namespace: framework.ClusterAPINamespace, | ||
}, | ||
Spec: awsv1.AWSMachineTemplateSpec{ | ||
Template: awsv1.AWSMachineTemplateResource{ | ||
Spec: awsMachineSpec, | ||
}, | ||
}, |
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.
here can use resourcebuilder https://github.com/openshift/cluster-api-actuator-pkg/tree/master/testutils/resourcebuilder
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.
Updated, thank you @sunzhaohua2 PTAL again, it passed in local.
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % ./hack/ci-integration.sh -focus "Cluster API AWS MachineSet" -v
Running Suite: Machine Suite - /Users/liuhuali/project/cluster-api-actuator-pkg/pkg
===================================================================================
Random Seed: 1732506965
Will run 2 of 44 specs
------------------------------
[BeforeSuite]
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/e2e_test.go:63
[BeforeSuite] PASSED [1.360 seconds]
------------------------------
SSSSSSSSSSSSSSSSSSSSSSSSSS
------------------------------
Cluster API AWS MachineSet should be able to run a machine with a default provider spec [capi, disruptive]
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/capi/aws.go:100
STEP: Creating core cluster @ 11/25/24 11:56:29.931
STEP: Creating AWS machine template @ 11/25/24 11:56:30.766
STEP: Creating MachineSet "aws-machineset-51071" @ 11/25/24 11:56:31.32
STEP: Waiting for MachineSet machines "aws-machineset-51071" to enter Running phase @ 11/25/24 11:56:31.602
STEP: Deleting MachineSet "aws-machineset-51071" @ 11/25/24 12:00:17.049
STEP: Waiting for MachineSet "aws-machineset-51071" to be deleted @ 11/25/24 12:00:17.327
STEP: Deleting /aws-machine-template @ 11/25/24 12:01:21.212
• [294.166 seconds]
------------------------------
Cluster API AWS MachineSet should be able to run a machine with cluster placement group [capi, disruptive]
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/capi/aws.go:112
I1125 12:01:24.951211 28912 aws_client.go:72] The created placementGroupID is pg-0b86fc1ccb6aa9742
STEP: Creating AWS machine template @ 11/25/24 12:01:24.951
STEP: Creating MachineSet "aws-machineset-75395" @ 11/25/24 12:01:25.238
STEP: Waiting for MachineSet machines "aws-machineset-75395" to enter Running phase @ 11/25/24 12:01:25.521
STEP: Deleting MachineSet "aws-machineset-75395" @ 11/25/24 12:05:51.76
STEP: Waiting for MachineSet "aws-machineset-75395" to be deleted @ 11/25/24 12:05:52.055
STEP: Deleting /aws-machine-template @ 11/25/24 12:06:55.93
• [336.224 seconds]
------------------------------
SSSSSSSSSSSSSSSS
------------------------------
[ReportAfterSuite] Autogenerated ReportAfterSuite for --junit-report
autogenerated by Ginkgo
[ReportAfterSuite] PASSED [0.003 seconds]
------------------------------
Ran 2 of 44 Specs in 631.752 seconds
SUCCESS! -- 2 Passed | 0 Failed | 0 Pending | 42 Skipped
PASS
Ginkgo ran 1 suite in 10m52.059989621s
Test Suite Passed
The azure job failed should be flake, and this pr will not affect azure, so we can ignore that. |
Thank you! @huali9 |
/assign @JoelSpeed @damdo |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
cc @RadekManak for review. Thank you! |
pkg/framework/aws_client.go
Outdated
placementGroupID := ptr.Deref(result.PlacementGroup.GroupId, "") | ||
klog.Infof("The created placementGroupID is %s", placementGroupID) | ||
|
||
return placementGroupID, err |
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.
err
will always be nil here, better to return nil
return placementGroupID, err | |
return placementGroupID, nil |
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.
updated, thank you!
pkg/framework/aws_client.go
Outdated
result, err := a.Svc.DeletePlacementGroup(input) | ||
|
||
return result.String(), err |
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.
Prefer to check the error explicitly
result, err := a.Svc.DeletePlacementGroup(input) | |
return result.String(), err | |
result, err := a.Svc.DeletePlacementGroup(input) | |
if err != nil { | |
return "", fmt.Errorf("could not delete placement group: %w", err) | |
} | |
return result.String(), nil |
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.
updated, thank you!
pkg/capi/aws.go
Outdated
var ( | ||
cl client.Client | ||
ctx = context.Background() | ||
platform configv1.PlatformType | ||
clusterName string | ||
oc *gatherer.CLI | ||
) |
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.
Need these be exposed at this scope, or could they be within the Describe on L38?
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.
moved to within the Describe, thank you!
pkg/capi/aws.go
Outdated
if platform != configv1.AWSPlatformType { | ||
Skip("Skipping AWS E2E tests") | ||
} | ||
oc, _ = framework.NewCLI() |
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.
What is the second return variable here and why are we ignoring it?
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 second return variable is error, updated, thank you!
pkg/capi/aws.go
Outdated
if platform != configv1.AWSPlatformType { | ||
// Because AfterEach always runs, even when tests are skipped, we have to | ||
// explicitly skip it here for other platforms. | ||
Skip("Skipping AWS E2E tests") | ||
} |
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.
Would they not have skipped in the BeforeAll?
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 are right, they should have skipped in the BeforeAll, deleted here, thank you!
pkg/capi/aws.go
Outdated
Skip("Skipping AWS E2E tests") | ||
} | ||
if !deleted { | ||
framework.DeleteCAPIMachineSets(ctx, cl, machineSet) |
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.
If this framework tolerated the object not existing, you wouldn't need to track whether the test expected to delete the machineset or not.
Are there cases where you want to be sure it did delete?
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.
I think we should delete the objects we created in the test, right?
pkg/capi/aws.go
Outdated
placementGroupID, err := awsClient.CreatePlacementGroup(placementGroupName, "cluster") | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create placementgroup") | ||
Expect(placementGroupID).ToNot(Equal(""), "expected the placementGroupID to not be empty string") | ||
defer func() { |
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.
I think if you were to leverage DeferCleanup
you might be able to avoid some complexity 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.
yeah, great, updated, thank you!
pkg/capi/aws.go
Outdated
framework.DeleteCAPIMachineSets(ctx, cl, machineSet) | ||
framework.WaitForCAPIMachineSetsDeleted(ctx, cl, machineSet) | ||
framework.DeleteObjects(ctx, cl, awsMachineTemplate) |
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 it possible for these to cause the defer to exit prior to deleting the placement group?
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 are right, that may occur, updated to use DeferCleanup, thank you!
pkg/capi/aws.go
Outdated
if err != nil { | ||
Skip(fmt.Sprintf("Skip because cannot get the key %v", err)) | ||
} |
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.
Skipping because of errors is likely to mean this test gets skipped when we don't want it to. Is there a better way to skip tests when we are in the dev account, vs QE account? Perhaps using labels?
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.
skipped for errors is a temporary solution, using labels should be better way, but we don't have that labels at present, and that's what we are discussing on slack https://redhat-internal.slack.com/archives/GE2HQ9QP4/p1732789329032099, we need identify which cases run in DEV CI, which cases run in QE CI, then add labels for them, then update all the DEV jobs to only run the cases chosen for DEV CI. Currently all the cases in this repo are run in DEV CI.
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.
Thank you @JoelSpeed I added a new label qe-account-only
and updated Makefile to exclude use cases with such labels. And all other comments also updated, PLAT again, thanks!
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.
Does this new label align with the plan @sunzhaohua2 has proposed?
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.
Yes, the meaning is the same, just the name is different, Zhaohua named it qe-only
and I named it qe-account-only
, I can update the name when we make a decision.
pkg/capi/aws.go
Outdated
if err := cl.Create(ctx, awsMachineTemplate); err != nil { | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create awsmachinetemplate") | ||
} |
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.
What about
if err := cl.Create(ctx, awsMachineTemplate); err != nil { | |
Expect(err).ToNot(HaveOccurred(), "Failed to create awsmachinetemplate") | |
} | |
Expect(cl.Create(ctx, awsMachineTemplate)).To(Succeed(), "Failed to create awsmachinetemplate") |
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.
updated, thank you!
4e20177
to
d5e1c87
Compare
@huali9: The following test failed, say
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. |
Auto 3 capi case:
OCP-51071 - [CAPI] Create machineset with CAPI on aws
OCP-75395 - [CAPI] AWS Placement group support
OCP-75396 - [CAPI] Creating machines using KMS keys from AWS
@sunzhaohua2 @miyadav @shellyyang1989 PTAL, thanks!