Skip to content
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

fix(eks): clusters in a FAILED state are not detected #9553

Merged
merged 4 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ export class ClusterResourceHandler extends ResourceHandler {
// if cluster is undefined (shouldnt happen) or status is not ACTIVE, we are
// not complete. note that the custom resource provider framework forbids
// returning attributes (Data) if isComplete is false.
if (cluster?.status !== 'ACTIVE') {
if (cluster?.status === 'FAILED') {
throw new Error('Cluster is in a FAILED status');
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
} else if (cluster?.status !== 'ACTIVE') {
return {
IsComplete: false,
};
Expand Down
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ export = {
test.done();
},

async 'isCreateComplete throws if cluster is FAILED'(test: Test) {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create'));
mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED';
try {
await handler.isComplete();
test.ok(false, 'expected error to be thrown');
} catch (err) {
test.equal(err.message, 'Cluster is in a FAILED status');
}
test.done();
},

async 'isUpdateComplete throws if cluster is FAILED'(test: Test) {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update'));
mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED';
try {
await handler.isComplete();
test.ok(false, 'expected error to be thrown');
} catch (err) {
test.equal(err.message, 'Cluster is in a FAILED status');
}
test.done();
},

async 'isCreateComplete is complete when cluster is ACTIVE'(test: Test) {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create'));
mocks.simulateResponse.describeClusterResponseMockStatus = 'ACTIVE';
Expand Down