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

Append PR number to TF Workspace Name when available #342

Merged
merged 6 commits into from
Oct 9, 2019

Conversation

KeithJRome
Copy link
Contributor

All Submissions:


  • [YES] Have you followed the guidelines in our Contributing document?
  • [YES] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [NA] I have updated the documentation accordingly.
  • [NA] I have added tests to cover my changes.
  • [NA] All new and existing tests passed.
  • [YES] My code follows the code style of this project.
  • [NA] I ran lint checks locally prior to submission.
  • [YES] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

What is the current behavior?


Individual PRs will compete for the same resource groups as the master branch deployment. This is a frequent immediate cause for many of the CD failures that we see in the PR checks for otherwise correct code. This problem is expected to become a more serious issue once a custom build agent is in use (with parallel builds).

Issue Number: #311

What is the new behavior?


  • When CI/CD checks are performed on a Pull Request, the PR number is appended to the Terraform Workspace Name. This ensures that the deployment of the PR that occurs during the checks will not race with other PR checks or with the main merge stream back to master.
  • Master merges should continue to deploy as before, without an appended number in the workspace name.
  • As a [new] final step in the PR process, developers need to be mindful about tearing down these temporary workspaces once their code merges to master, in order to keep resource expenditure from spiraling.

Does this introduce a breaking change?


  • [NO]

Any relevant logs, error output, etc?


(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Other information


@KeithJRome KeithJRome force-pushed the 311-pr-in-workspace-name branch from 6d817b2 to 788cc9c Compare October 1, 2019 01:10
@KeithJRome KeithJRome added the wip label Oct 2, 2019
@KeithJRome KeithJRome force-pushed the 311-pr-in-workspace-name branch from 67bc5ce to 3efffe6 Compare October 4, 2019 22:41
@KeithJRome KeithJRome force-pushed the 311-pr-in-workspace-name branch from 3efffe6 to b5e30e0 Compare October 7, 2019 20:53
@KeithJRome KeithJRome removed the wip label Oct 7, 2019
Copy link
Contributor

@ianphil ianphil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 it... questions or thoughts can roll into later revisions if they make sense.

@@ -33,7 +33,9 @@ stages:
- template: ./infrastructure/azure-pipeline-cicd-compose.yml
parameters:
environments:
- 'devint'
- name: 'devint'
enablePrIsolation: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this come from a variable in the var group?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. If it's useful to do that, then we should spin off a post-v1 feature request story for it.

IFS='/' # delimiter
read -ra PARTS <<< "$BUILD_SOURCEBRANCH" # split the branch into parts

if [[ "${#PARTS[@]}" == "4" && "${PARTS[0]}" == "refs" && "${PARTS[1]}" == "pull" && "${PARTS[3]}" == "merge" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice check... sed/awk could be used here, but this does the trick.

@KeithJRome KeithJRome merged commit bf4963a into master Oct 9, 2019
@KeithJRome KeithJRome deleted the 311-pr-in-workspace-name branch October 9, 2019 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants