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

[#115624569] Workaround terraform codecommit issue with default_branch property #177

Merged
merged 2 commits into from
Mar 30, 2016

Conversation

keymon
Copy link
Contributor

@keymon keymon commented Mar 29, 2016

#115624569 Implement locking for pipelines

What?

We did not catch this issue in the PR #173.

Terraform codecommit resource[1] has a bug managing the default_branch
property: hashicorp/terraform#5641

Although this property is optional, terraform will try to manage it.

If defined, codecommit will fail during creation:

BranchDoesNotExistException: refs/heads/master does not exist

Meanwhile if default_branch is defined, codecommit it will fail as soon
as a branch is pushed to the repository. The reason is that AWS enforces
having at least one branch as default branch, failing when terraform is
trying to set it empty:

  * aws_codecommit_repository.concourse-pool: Error Updating Default
  * Branch for CodeCommit Repository: InvalidParameter: 1 validation
    * errors:
     - field too short, minimum length 1: DefaultBranchName

Scope

This issue will be reported upstream, but meanwhile we will workaround it by
passing the default branch as a variable, and quering it using awscli.
If the respository does not exist or does not have default branch, the
variable will be set to empty string "".

We additionally remove the bump of the pipeline-trigger in the init job, which is not required anymore.

How to test

Running from a environment without an associated codecommit git pool-resource
respository:

  1. Run the bootstrap process SELF_UPDATE_PIPELINE=false BRANCH=$(git rev-parse --abbrev-ref HEAD) make dev bootstrap DEPLOY_ENV=...
  2. Run the jobs up to concourse-terraform (the rest are not relevant)
    • concourse-terraform should finnish OK
    • the terraform apply output for the resource aws_codecommit_repository.concourse-pool should not refer to any default_branch
  3. Rerun concourse-terraform it should end OK.
  4. Run the lock-pipeline job in create-bosh-cloudfoundry
    a. Upload the pipelines: SELF_UPDATE_PIPELINE=false BRANCH=$(git rev-parse --abbrev-ref HEAD) make dev pipelines DEPLOY_ENV=...
    b. This will create a initial branch in the codecommit repo.
  5. Back in the bootstrap concourse (http://localhost:8080), rerun concourse-terraform
    • It should finish OK
    • terraform output should not report any change

Who?

Anyone but @keymon

Terraform codecommit resource[1] has a bug managing the default_branch
property.

Although this property is optional, terraform will try to manage it.

If defined, codecommit will fail during creation:

  BranchDoesNotExistException: refs/heads/master does not exist

Meanwhile if default_branch is defined, codecommit it will fail as soon
as a branch is pushed to the repository. The reason is that AWS enforces
having at least one branch as default branch, failing when terraform is
trying to set it empty:

  * aws_codecommit_repository.concourse-pool: Error Updating Default
  * Branch for CodeCommit Repository: InvalidParameter: 1 validation
    * errors:
     - field too short, minimum length 1: DefaultBranchName

This will be reported upstream, but meanwhile we will workaround it by
passing the default branch as a variable, and quering it using awscli.
If the respository does not exist or does not have default branch, the
variable will be set to empty string "".
@dcarley
Copy link
Contributor

dcarley commented Mar 29, 2016

Haven't tested, but this look reasonable given the circumstances 👌

@keymon
Copy link
Contributor Author

keymon commented Mar 29, 2016

I did a PR on terraform to fix the issue, although I am not sure if this is the right way to implement it: hashicorp/terraform#5904

One alternative can be just use the patched version and bundle it in the terraform container, but it that case we will have a dependency on that branch.

@mtekel mtekel self-assigned this Mar 30, 2016
After adding the job lock pipeline, which bumps the pipeline-trigger
resource, it is not required that init to do the same.
@mtekel
Copy link
Contributor

mtekel commented Mar 30, 2016

works well, merging

@mtekel mtekel merged commit 657d037 into master Mar 30, 2016
@mtekel mtekel deleted the bugfix/115624569_pipeline_locking branch March 30, 2016 11:31
richardTowers added a commit that referenced this pull request Apr 26, 2019
Full diff: alphagov/paas-admin@v0.82.0...v0.94.0

Contains the following PRs by human beings:

- #146 Stub APIs needed for the calculator
- #148 Request logging
- #160 Use javascript naming for request log interceptor
- #173 Support: Fix bug showing allocations
- #180 Skip calculator getQuote if there are no items
- #181 Remove low-value, flakey test

And the following dependabot specials:

- #161 Bump nunjucks from 3.1.3 to 3.2.0
- #165 Bump glob from 7.1.2 to 7.1.3
- #164 Bump @types/source-map-support from 0.4.1 to 0.5.0
- #162 Bump webpack-cli from 3.1.0 to 3.3.1
- #170 Bump pino from 5.1.0 to 5.12.3
- #169 Bump @types/jest from 23.3.1 to 24.0.11
- #168 Bump nodemon-webpack-plugin from 4.0.3 to 4.0.8
- #167 Bump express-static-gzip from 1.1.1 to 1.1.3
- #166 Bump @types/uuid from 3.4.3 to 3.4.4
- #163 Bump @types/helmet from 0.0.38 to 0.0.43
- #174 Bump tslint-microsoft-contrib from 5.2.0 to 6.1.1
- #175 Bump qs from 6.5.2 to 6.7.0
- #176 Bump moment from 2.22.2 to 2.24.0
- #177 Bump jest from 23.5.0 to 23.6.0
- #178 Bump @types/passport from 0.4.6 to 1.0.0
- #179 Bump jest and ts-jest
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.

3 participants