AWS Codebuild download source phase often times out

Viewed 17

I've setup CodeBuild to run our tests when a PR is created/modified (from Bitbucket). But unfortunately, the DOWNLOAD_SOURCE phase sometimes (most times) fails after 3 minutes. After a couple of retries, it will run correctly and take about 50 seconds.

Here is the error I get when it times out:

CLIENT_ERROR: Get "https://################.git/info/refs?service=git-upload-pack": dial tcp #.#.#.#:443: i/o timeout for primary source and source version 0123456789abc

I'm guessing it's Bitbucket that is not responding for some reason. Also, I can't where/how to increase the 3mins timeout in CodeBuild.

Any suggestions?

1 Answers

We managed to fix this with the help of the AWS reddit community.

Here's what was happening:

  • CodeBuild was initially configured with 2 pre-existing subnets:

    • One was the default subnet for our VPC, with access to the default igw for our EC2s

    • The other was a separate subnet we configured for our lambdas, for which we configured a NAT gateway.

  • Each of the subnets seemed to provide the CodeBuild process with some of the network functionality it needed.

  • When removing either of the subnets, the CodeBuild would often (but not always!) fail in the Provisioning Stage or in the Downloading Code phase.

Here's how we fixed it:

  • we created and configured 1 subnet dedicated to CodeBuild.

Xavier

https://app.featherfinance.com/

Related