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

(pipelines): Allow re-generating CloudFormation changeset after failure #11995

Closed
2 tasks
blimmer opened this issue Dec 10, 2020 · 8 comments
Closed
2 tasks
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@blimmer
Copy link
Contributor

blimmer commented Dec 10, 2020

As of today, I couldn't find a way to re-run an application stage deployment if application of the CloudFormation changeset failed. We can kick off the pipeline again by committing a dummy/no-op commit to the repository, but this creates unnecessary cruft in the SCM history.

Use Case

Consider a CloudFormation template that could not apply for some reason. In my case, it was because of a naming conflict with another CloudFormation stack that needed to be destroyed.

The CodePipeline user interface looks like this after the failure:

Screen_Shot_2020-12-10_at_10_20_02_AM

So, I took a look at the failure and noticed the naming conflict. I went and destroyed the other CDK stack and wanted to re-run the deployment. However, when I clicked the "Retry" button in the UI, the "Deploy" stage failed with this error message:

ChangeSet [PipelineChange] does not exist (Service: AmazonCloudFormation; Status Code: 404; Error Code: ChangeSetNotFound; Request ID: <redacted>)

Indeed, in the CloudFormation user interface, the changeset was not present:

Screen Shot 2020-12-10 at 10 06 59 AM

The problem appears to be because there's no way to retry an entire stage in CodePipeline, including steps that previously succeeded. According to the aws cli docs (aws codepipeline retry-stage-execution help):

--retry-mode (string)
  The scope of the retry attempt. Currently, the only supported  value
  is FAILED_ACTIONS.

  Possible values:

  o FAILED_ACTIONS

Because I didn't have a way to rerun the .Prepare step (which produces the changeset), I was kind of stuck and had to revert to pushing a no-op commit to force the step to re-run.

Proposed Solution

Since this appears to be a CodePipeline limitation, maybe a custom "step" is needed? Like maybe an SNS topic or something to kick off the deployment again? Or maybe a better solution would be to +1 feature requests on the CodePipeline side to allow "Retry (including succeeded)" behavior?

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@blimmer blimmer added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 10, 2020
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Dec 10, 2020
@blimmer
Copy link
Contributor Author

blimmer commented Dec 10, 2020

Is it possible that this is only an issue with the initial deploy of the stack? Potentially similar to this: #901?

@blimmer
Copy link
Contributor Author

blimmer commented Dec 10, 2020

I also just found this command to re-trigger a pipeline from the CLI - maybe it's just not exposed via the UI?

aws codepipeline start-pipeline-execution

Perhaps this is a good workaround.

@rix0rrr
Copy link
Contributor

rix0rrr commented Dec 14, 2020

Or maybe a better solution would be to +1 feature requests on the CodePipeline side to allow "Retry (including succeeded)" behavior?

I would agree that a better solution would be to petition to fix the root cause, rather than try to work around it.

There should be a button at the top-right of your pipeline though that says "Release Change", which does the same as starting the execution using the CLI.

image

Not actionable for CDK. Closing.

@rix0rrr rix0rrr closed this as completed Dec 14, 2020
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@openwebsolns
Copy link
Contributor

I also just found this command to re-trigger a pipeline from the CLI - maybe it's just not exposed via the UI?

aws codepipeline start-pipeline-execution

Perhaps this is a good workaround.

This is available through the UI by clicking the "Release change" button.

@openwebsolns
Copy link
Contributor

This is still a problem. If you have a large pipeline, "releasing a change" would require deploying through all the previous stages before you can retry the failed stage. Is there a creative workaround by which we can "replay" a changeset with the same name (PipelineChange) so that the CodePipeline retry works? Does CDK provide the ability to just create the changeset?

@fab-mindflow
Copy link

Indeed, we also have a large CDK deployment and this forces us to build everything again and again. Any workaround?

@XTEKiyZRLr8UsiQN
Copy link

Indeed, we also have a large CDK deployment and this forces us to build everything again and again. Any workaround?

Hi, a workaround for this is to actually disable change sets. They are auto enabled but based on https://github.com/aws/aws-cdk/pull/21619/files you should be able to remove them. I have had success with this and can now retry my stages. Hope this helps.

https://github.com/aws/aws-cdk/pull/21619/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants