From ddc84a8f1cfcb6f0f10efea11e59287131eb0031 Mon Sep 17 00:00:00 2001 From: shapirov Date: Wed, 7 Aug 2024 15:29:22 -0400 Subject: [PATCH 1/2] Incremented cloudwathc insight versions to address the test failure --- lib/addons/cloud-watch-insights/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/addons/cloud-watch-insights/index.ts b/lib/addons/cloud-watch-insights/index.ts index 725b97771..3fbc8de90 100644 --- a/lib/addons/cloud-watch-insights/index.ts +++ b/lib/addons/cloud-watch-insights/index.ts @@ -10,11 +10,11 @@ import {KubernetesVersion} from "aws-cdk-lib/aws-eks"; // aws eks describe-addon-versions --kubernetes-version --addon-name amazon-cloudwatch-observability \ // --query 'addons[].addonVersions[].{Version: addonVersion, Defaultversion: compatibilities[0].defaultVersion}' --output table const versionMap: Map = new Map([ - [KubernetesVersion.V1_30, "v1.8.0-eksbuild.1"], - [KubernetesVersion.V1_29, "v1.8.0-eksbuild.1"], - [KubernetesVersion.V1_28, "v1.8.0-eksbuild.1"], - [KubernetesVersion.V1_27, "v1.8.0-eksbuild.1"], - [KubernetesVersion.V1_26, "v1.8.0-eksbuild.1"], + [KubernetesVersion.V1_30, "v1.10.0-eksbuild.2"], + [KubernetesVersion.V1_29, "v1.10.0-eksbuild.2"], + [KubernetesVersion.V1_28, "v1.10.0-eksbuild.2"], + [KubernetesVersion.V1_27, "v1.10.0-eksbuild.2"], + [KubernetesVersion.V1_26, "v1.10.0-eksbuild.2"], ]); From fba270a39a8c667cedc189b6f525903b648a03e7 Mon Sep 17 00:00:00 2001 From: shapirov103 Date: Mon, 28 Oct 2024 10:35:07 -0400 Subject: [PATCH 2/2] bugfix: cloudwatch tests updated --- lib/addons/core-addon/index.ts | 11 ++++++----- package.json | 2 +- test/cloudwatch-insights.test.ts | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/addons/core-addon/index.ts b/lib/addons/core-addon/index.ts index 4a080eb5c..60312ed69 100644 --- a/lib/addons/core-addon/index.ts +++ b/lib/addons/core-addon/index.ts @@ -7,6 +7,7 @@ import { KubernetesVersion } from "aws-cdk-lib/aws-eks"; import { createServiceAccountWithPolicy, deployBeforeCapacity, logger, userLog, } from "../../utils"; import * as sdk from "@aws-sdk/client-eks"; import { RemovalPolicy } from "aws-cdk-lib"; +import cluster from "cluster"; export class CoreAddOnProps { /** @@ -87,7 +88,7 @@ export class CoreAddOn implements ClusterAddOn { let version: string = this.coreAddOnProps.version; if (this.coreAddOnProps.version === "auto") { - version = await this.provideVersion(clusterInfo); + version = await this.provideVersion(clusterInfo.version, clusterInfo.cluster.stack.region); } let addOnProps = { @@ -176,11 +177,11 @@ export class CoreAddOn implements ClusterAddOn { return result; } - async provideVersion(clusterInfo: ClusterInfo) : Promise { - const client = new sdk.EKSClient({ region: clusterInfo.cluster.stack.region }); + async provideVersion(clusterVersion: KubernetesVersion, region: string) : Promise { + const client = new sdk.EKSClient({ region }); const command = new sdk.DescribeAddonVersionsCommand({ addonName: this.coreAddOnProps.addOnName, - kubernetesVersion: clusterInfo.version.version + kubernetesVersion: clusterVersion.version }); try { @@ -210,7 +211,7 @@ export class CoreAddOn implements ClusterAddOn { logger.warn(`Failed to retrieve add-on versions from EKS for add-on ${this.coreAddOnProps.addOnName}.`); logger.warn("Possible reasons for failures - Unauthorized or Authentication failure or Network failure on the terminal."); logger.warn(" Falling back to default version."); - let version: string = this.provideDefaultAutoVersion(clusterInfo.version); + let version: string = this.provideDefaultAutoVersion(clusterVersion); userLog.debug(`Core add-on ${this.coreAddOnProps.addOnName} has autoselected version ${version}`); return version; } diff --git a/package.json b/package.json index 76a2ba630..d5ba2d74e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aws-quickstart/eks-blueprints", - "version": "1.16.1", + "version": "1.16.2", "license": "Apache-2.0", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/test/cloudwatch-insights.test.ts b/test/cloudwatch-insights.test.ts index 0303c7e33..d28405eff 100644 --- a/test/cloudwatch-insights.test.ts +++ b/test/cloudwatch-insights.test.ts @@ -80,7 +80,7 @@ describe('Unit test for CloudWatch Addon', () => { const app = new cdk.App(); const addOn = new blueprints.CloudWatchInsights({}); - const version = KubernetesVersion.V1_29; + const version = KubernetesVersion.V1_30; const blueprint = await blueprints.EksBlueprint.builder() .version(version) .account("123456789012").region('us-east-2') @@ -89,9 +89,11 @@ describe('Unit test for CloudWatch Addon', () => { const template = Template.fromStack(blueprint); + const inferredVersion = await addOn.provideVersion(version, 'us-west-2'); + template.hasResource("AWS::EKS::Addon", { Properties: { - "AddonVersion": Match.exact(addOn.provideDefaultAutoVersion(version)) + "AddonVersion": Match.exact(inferredVersion) } }); });