Skip to content

Commit d651948

Browse files
authored
fix(eks): clusters in a FAILED state are not detected (#9553)
Fixes #9529 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6a8cba4 commit d651948

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/cluster.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ export class ClusterResourceHandler extends ResourceHandler {
196196
// if cluster is undefined (shouldnt happen) or status is not ACTIVE, we are
197197
// not complete. note that the custom resource provider framework forbids
198198
// returning attributes (Data) if isComplete is false.
199-
if (cluster?.status !== 'ACTIVE') {
199+
if (cluster?.status === 'FAILED') {
200+
// not very informative, unfortunately the response doesn't contain any error
201+
// information :\
202+
throw new Error('Cluster is in a FAILED status');
203+
} else if (cluster?.status !== 'ACTIVE') {
200204
return {
201205
IsComplete: false,
202206
};

packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts

+24
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ export = {
8888
test.done();
8989
},
9090

91+
async 'isCreateComplete throws if cluster is FAILED'(test: Test) {
92+
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create'));
93+
mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED';
94+
try {
95+
await handler.isComplete();
96+
test.ok(false, 'expected error to be thrown');
97+
} catch (err) {
98+
test.equal(err.message, 'Cluster is in a FAILED status');
99+
}
100+
test.done();
101+
},
102+
103+
async 'isUpdateComplete throws if cluster is FAILED'(test: Test) {
104+
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update'));
105+
mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED';
106+
try {
107+
await handler.isComplete();
108+
test.ok(false, 'expected error to be thrown');
109+
} catch (err) {
110+
test.equal(err.message, 'Cluster is in a FAILED status');
111+
}
112+
test.done();
113+
},
114+
91115
async 'isCreateComplete is complete when cluster is ACTIVE'(test: Test) {
92116
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create'));
93117
mocks.simulateResponse.describeClusterResponseMockStatus = 'ACTIVE';

0 commit comments

Comments
 (0)