Skip to content

Commit

Permalink
Merge pull request #1098 from aws-quickstart/bugfix/cloudwatch-insigh…
Browse files Browse the repository at this point in the history
…ts-failing-tests

Bugfix/cloudwatch insights failing tests
  • Loading branch information
shapirov103 authored Oct 28, 2024
2 parents f2de8cc + fba270a commit 7c98619
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 6 additions & 5 deletions lib/addons/core-addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Check warning on line 10 in lib/addons/core-addon/index.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'cluster' is defined but never used

export class CoreAddOnProps {
/**
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -176,11 +177,11 @@ export class CoreAddOn implements ClusterAddOn {
return result;
}

async provideVersion(clusterInfo: ClusterInfo) : Promise<string> {
const client = new sdk.EKSClient({ region: clusterInfo.cluster.stack.region });
async provideVersion(clusterVersion: KubernetesVersion, region: string) : Promise<string> {
const client = new sdk.EKSClient({ region });
const command = new sdk.DescribeAddonVersionsCommand({
addonName: this.coreAddOnProps.addOnName,
kubernetesVersion: clusterInfo.version.version
kubernetesVersion: clusterVersion.version
});

try {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions test/cloudwatch-insights.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
}
});
});
Expand Down

0 comments on commit 7c98619

Please sign in to comment.