-
Notifications
You must be signed in to change notification settings - Fork 4k
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(cli): warns about missing --no-rollback
flag that is present
#32309
Changes from all commits
023a4fa
b9e2027
36b4d62
bf0bb5e
01dfa6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1127,30 +1127,41 @@ describe('disable rollback', () => { | |
}); | ||
|
||
test.each([ | ||
[StackStatus.UPDATE_FAILED, 'failpaused-need-rollback-first'], | ||
[StackStatus.CREATE_COMPLETE, 'replacement-requires-norollback'], | ||
])('no-rollback and replacement is disadvised: %p -> %p', async (stackStatus, expectedType) => { | ||
// From a failed state, a --no-rollback is possible as long as there is not a replacement | ||
[StackStatus.UPDATE_FAILED, 'no-rollback', 'no-replacement', 'did-deploy-stack'], | ||
[StackStatus.UPDATE_FAILED, 'no-rollback', 'replacement', 'failpaused-need-rollback-first'], | ||
// Any combination of UPDATE_FAILED & rollback always requires a rollback first | ||
[StackStatus.UPDATE_FAILED, 'rollback', 'replacement', 'failpaused-need-rollback-first'], | ||
[StackStatus.UPDATE_FAILED, 'rollback', 'no-replacement', 'failpaused-need-rollback-first'], | ||
// From a stable state, any deployment containing a replacement requires a regular deployment (--rollback) | ||
[StackStatus.UPDATE_COMPLETE, 'no-rollback', 'replacement', 'replacement-requires-rollback'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't traced through the code fully, but this seems to read that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the stack is in a stable state ( That is to say, the combination of What will happen in practice is that our CLI will catch this return code and ask "Do you want to perform a regular (--rollback) deployment (y/n)?" |
||
] satisfies Array<[StackStatus, 'rollback' | 'no-rollback', 'replacement' | 'no-replacement', string]>) | ||
('no-rollback and replacement is disadvised: %s %s %s -> %s', async (stackStatus, rollback, replacement, expectedType) => { | ||
// GIVEN | ||
givenTemplateIs(FAKE_STACK.template); | ||
givenStackExists({ | ||
NotificationARNs: ['arn:aws:sns:bermuda-triangle-1337:123456789012:TestTopic'], | ||
// First call | ||
StackStatus: stackStatus, | ||
}, { | ||
// Later calls | ||
StackStatus: 'UPDATE_COMPLETE', | ||
}); | ||
givenChangeSetContainsReplacement(); | ||
givenChangeSetContainsReplacement(replacement === 'replacement'); | ||
|
||
// WHEN | ||
const result = await deployStack({ | ||
...standardDeployStackArguments(), | ||
stack: FAKE_STACK, | ||
rollback: false, | ||
rollback: rollback === 'rollback', | ||
force: true, // Bypass 'canSkipDeploy' | ||
}); | ||
|
||
// THEN | ||
expect(result.type).toEqual(expectedType); | ||
}); | ||
|
||
test('assertIsSuccessfulDeployStackResult does what it says', () => { | ||
expect(() => assertIsSuccessfulDeployStackResult({ type: 'replacement-requires-norollback' })).toThrow(); | ||
expect(() => assertIsSuccessfulDeployStackResult({ type: 'replacement-requires-rollback' })).toThrow(); | ||
}); | ||
/** | ||
* Set up the mocks so that it looks like the stack exists to start with | ||
|
@@ -1162,12 +1173,14 @@ function givenStackExists(...overrides: Array<Partial<Stack>>) { | |
overrides = [{}]; | ||
} | ||
|
||
let handler = mockCloudFormationClient.on(DescribeStacksCommand); | ||
|
||
for (const override of overrides.slice(0, overrides.length - 1)) { | ||
mockCloudFormationClient.on(DescribeStacksCommand).resolvesOnce({ | ||
handler = handler.resolvesOnce({ | ||
Stacks: [{ ...baseResponse, ...override }], | ||
}); | ||
} | ||
mockCloudFormationClient.on(DescribeStacksCommand).resolves({ | ||
handler.resolves({ | ||
Stacks: [{ ...baseResponse, ...overrides[overrides.length - 1] }], | ||
}); | ||
} | ||
|
@@ -1178,10 +1191,10 @@ function givenTemplateIs(template: any) { | |
}); | ||
} | ||
|
||
function givenChangeSetContainsReplacement() { | ||
function givenChangeSetContainsReplacement(replacement: boolean) { | ||
mockCloudFormationClient.on(DescribeChangeSetCommand).resolves({ | ||
Status: 'CREATE_COMPLETE', | ||
Changes: [ | ||
Changes: replacement ? [ | ||
{ | ||
Type: 'Resource', | ||
ResourceChange: { | ||
|
@@ -1205,6 +1218,6 @@ function givenChangeSetContainsReplacement() { | |
], | ||
}, | ||
}, | ||
], | ||
] : [], | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this is a debug line left by Otavio :).
In any case, I don't want just the account number, ARN and userId printed to the log without text.