Skip to content

Commit

Permalink
Merge pull request #7471 from mttrb/fix_addon_versions
Browse files Browse the repository at this point in the history
Fix checks for updated addon versions
  • Loading branch information
yuxiang-zhang authored Feb 14, 2024
2 parents fade871 + d9d55c2 commit 647874e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
6 changes: 0 additions & 6 deletions pkg/actions/addon/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ func (a *Manager) findNewerVersions(ctx context.Context, addon *api.Addon) (stri
logger.Debug("could not parse version %q, skipping finding newer versions: %v", addon.Version, err)
return "-", nil
}
//trim off anything after x.y.z so its not used in comparison, e.g. 1.7.5-eksbuild.1 > 1.7.5
currentVersion.Build = []string{}
currentVersion.Pre = []semver.PRVersion{}

versions, err := a.describeVersions(ctx, addon)
if err != nil {
Expand All @@ -133,9 +130,6 @@ func (a *Manager) findNewerVersions(ctx context.Context, addon *api.Addon) (stri
if err != nil {
logger.Debug("could not parse version %q, skipping version comparison: %v", addon.Version, err)
} else {
//trim off anything after x.y.z and don't use in comparison, e.g. v1.7.5-eksbuild.1 > v1.7.5
version.Build = []string{}
version.Pre = []semver.PRVersion{}
if currentVersion.LT(version) {
newerVersions = append(newerVersions, *versionInfo.AddonVersion)
}
Expand Down
32 changes: 18 additions & 14 deletions pkg/actions/addon/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ var _ = Describe("Get", func() {
Type: aws.String("type"),
AddonVersions: []ekstypes.AddonVersionInfo{
{
AddonVersion: aws.String("1.0.0"),
AddonVersion: aws.String("v1.0.0-eksbuild.1"),
},
{
//not sure if all versions come with v prefix or not, so test a mix
AddonVersion: aws.String("v1.1.0"),
AddonVersion: aws.String("v1.1.0-eksbuild.1"),
},
{
AddonVersion: aws.String("1.2.0"),
AddonVersion: aws.String("v1.1.0-eksbuild.4"),
},
{
AddonVersion: aws.String("v1.2.0-eksbuild.1"),
},
},
},
Expand All @@ -66,7 +68,7 @@ var _ = Describe("Get", func() {
}).Return(&awseks.DescribeAddonOutput{
Addon: &ekstypes.Addon{
AddonName: aws.String("my-addon"),
AddonVersion: aws.String("v1.0.0"),
AddonVersion: aws.String("v1.1.0-eksbuild.1"),
ServiceAccountRoleArn: aws.String("foo"),
Status: "created",
Health: &ekstypes.AddonHealth{
Expand All @@ -87,8 +89,8 @@ var _ = Describe("Get", func() {
Expect(err).NotTo(HaveOccurred())
Expect(summary).To(Equal(addon.Summary{
Name: "my-addon",
Version: "v1.0.0",
NewerVersion: "v1.1.0,1.2.0",
Version: "v1.1.0-eksbuild.1",
NewerVersion: "v1.1.0-eksbuild.4,v1.2.0-eksbuild.1",
IAMRole: "foo",
Status: "created",
Issues: []addon.Issue{
Expand Down Expand Up @@ -135,14 +137,16 @@ var _ = Describe("Get", func() {
Type: aws.String("type"),
AddonVersions: []ekstypes.AddonVersionInfo{
{
AddonVersion: aws.String("1.0.0"),
AddonVersion: aws.String("v1.0.0-eksbuild.1"),
},
{
AddonVersion: aws.String("v1.1.0-eksbuild.1"),
},
{
//not sure if all versions come with v prefix or not, so test a mix
AddonVersion: aws.String("v1.1.0"),
AddonVersion: aws.String("v1.1.0-eksbuild.4"),
},
{
AddonVersion: aws.String("1.2.0"),
AddonVersion: aws.String("v1.2.0-eksbuild.1"),
},
},
},
Expand All @@ -164,7 +168,7 @@ var _ = Describe("Get", func() {
}).Return(&awseks.DescribeAddonOutput{
Addon: &ekstypes.Addon{
AddonName: aws.String("my-addon"),
AddonVersion: aws.String("1.0.0"),
AddonVersion: aws.String("v1.1.0-eksbuild.1"),
ServiceAccountRoleArn: aws.String("foo"),
Status: "created",
ConfigurationValues: aws.String("{\"replicaCount\":3}"),
Expand All @@ -176,8 +180,8 @@ var _ = Describe("Get", func() {
Expect(summary).To(Equal([]addon.Summary{
{
Name: "my-addon",
Version: "1.0.0",
NewerVersion: "v1.1.0,1.2.0",
Version: "v1.1.0-eksbuild.1",
NewerVersion: "v1.1.0-eksbuild.4,v1.2.0-eksbuild.1",
IAMRole: "foo",
Status: "created",
ConfigurationValues: "{\"replicaCount\":3}",
Expand Down

0 comments on commit 647874e

Please sign in to comment.