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
ci: Find all of instance-profiles in the CI account #6137
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for karpenter-docs-prod ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Pull Request Test Coverage Report for Build 8947840975Details
💛 - Coveralls |
c28f317
to
ecdba4f
Compare
ecdba4f
to
3b6bc84
Compare
}) | ||
if err != nil { | ||
errs[i] = err | ||
continue | ||
} | ||
|
||
clusterName, _ := lo.Find(profiles.Tags, func(tag iamtypes.Tag) bool { | ||
clusterName, foundClusterName := lo.Find(profiles.Tags, func(tag iamtypes.Tag) bool { |
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.
nit: I can't remember. Maybe not a huge deal, but I recalled that we said we were fine with not doing the "found" check since the result of lo.FromPtr
was going to be an empty string anyways, which isn't valid for a cluster name or for a region name
continue | ||
} | ||
|
||
for _, t := range profiles.Tags { | ||
// Since we can only get the date of the instance profile (not the exact time the instance profile was created) | ||
// we add a day to the time that it was created to account for the worst-case of the instance profile being created | ||
// at 23:59:59 and being marked with a time of 00:00:00 due to only capturing the date and not the time | ||
if lo.FromPtr(t.Key) == karpenterTestingTag && out.InstanceProfiles[i].CreateDate.Add(time.Hour*24).Before(expirationTime) { | ||
names = append(names, lo.FromPtr(out.InstanceProfiles[i].InstanceProfileName)) | ||
if lo.FromPtr(t.Key) == karpenterTestingTag && instanceProfiles[i].CreateDate.Add(time.Hour*24).Before(expirationTime) { |
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.
Seems like we're doing a bit of double-work here. We first already check whether the cluster name is in our set of excluded clusters which means we should have been able to validate that this is a "karpenter-owned" resource above, so we really don't need to check this again here. We could really avoid all of the iteration through this tags section and just reduce all of this to a few "found" checks.
func (ip *InstanceProfile) getAllInstanceProfiles(ctx context.Context) (instanceprofile []iamtypes.InstanceProfile, err error) { | ||
var nextToken *string | ||
for { | ||
out, err := ip.iamClient.ListInstanceProfiles(ctx, &iam.ListInstanceProfilesInput{ |
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.
optional: Consider looking at aws-sdk-go-v2 pagination
Fixes #N/A
Description
How was this change tested?
Does this change impact docs?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.