Skip to content

Codebuild as Github Actions Runner - Error when extracting the runner

0

Hi,

I have followed the following AWS docs for setting up a Github runner using codebuild: https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html

The setup seems complete, and the following steps seem to work properly:

  • Codebuild is successfully connecting to GitHub using GitHub App
  • My GitHub action (which is configured using the hello world template suggested in the documentation above) properly sends out the webhook
  • A run of my codebuild project is started in response to the webhook

However, codebuild runs into an error during the runner setup: Enter image description here

The error seems to indicate that the downloaded runner file is not in the expected format for extraction. I should add that I have not provided any buildspec override as I wish for codebuild to automatically configure my agent, as the documentation suggests. My codebuild runs in a private VPC. As you can see in the logs, the curl request seems to complete correctly, so I don't believe this should be an issue.

Could I have misconfigured anything ? Given the whole webhook sequence works properly, and it only fails while executing an AWS managed script, I'm having trouble finding the root cause of the issue!

Any help would be greatly appreciated!

Thank you

asked 8 months ago456 views
2 Answers
1

Hello.

If you look at the log, you will see the following message output.
This is the message that appears when you try to extract a file other than gzip using the tar xzf command.

gzip: stdin: not in gzip format

Is the "actions-runner-linux-x64.tar.gz" downloaded with the curl command a gzip file?
Can you check the file format using "file actions-runner-linux-x64.tar.gz" etc.?

EXPERT
answered 8 months ago
  • Hi, thanks for your reply! This is currently what I am trying to assess. In order to do this, I am attempting to debug the codebuild to find the curl request command, and find the requested url, but so far no luck. If I create a sandbox debug session, the original buildspec.yml gets overwritten so I can't find it that way.

    I'm not well versed in codebuild debugging functionalities so I'm trying to find a way to debug while keeping the original buildspec.yml file (which is managed/created by AWS, not created by myself) Any tips in that regards (or any alternative way) would be nice, thanks

  • To debug my codebuild, I had to:

    • Modify the codebuild configuration and override the buildspec.yml to add pre_build / post_build sections and commands
    • In my GitHub workflow, add "buildspec-override:true" in the runs-on array.

    With that, I was able to gather the following:

    • actions-runner-linux-x64.tar.gz is actually an XML document (???). Here's the output of the "file actions-runner-linux-x64.tar.gz" command: actions-runner-linux-x64.tar.gz: XML 1.0 document, ASCII text

    • The file is fetched from codefactory-eu-west-3-prod-default-build-agent-executor.s3.eu-west-3.amazonaws.com

-1

This issue appears to be related to the extraction of the GitHub Actions runner during the CodeBuild setup process. Based on the error message, the downloaded runner file is not in the expected format for extraction, despite the curl request appearing to complete successfully.

Since you're running CodeBuild in a private VPC, there might be network-related issues affecting the download of the runner. Even though the curl request seems to complete, the content might be corrupted or incomplete due to network constraints or proxy configurations.

Here are some troubleshooting steps you can try:

  1. Verify that your VPC has proper outbound connectivity to GitHub's domains. Even though the curl request completes, it might be returning an error page or incomplete file rather than the actual runner package.

  2. Check if you need to configure any specific network settings or NAT gateways to allow proper outbound traffic from your private VPC.

  3. Ensure that your CodeBuild project has the correct permissions to download and extract the runner.

  4. If you're using any label overrides in your GitHub Actions workflow, make sure they're consistent across all jobs. Inconsistent label configurations can cause issues with runner assignment.

  5. Verify that the credentials associated with your CodeBuild project have the necessary read permissions for deployments and actions within GitHub.

If the issue persists, you might want to check the webhook delivery details in GitHub to see if there are any specific error messages that could provide more insight into the problem. You can use GitHub's API to get details about the webhook delivery and see CodeBuild's response to the webhook's payload.
Sources
Self-hosted GitHub Actions runners in AWS CodeBuild - AWS CodeBuild
Troubleshoot the webhook - AWS CodeBuild
CodeBuild GitHub runners are randomly failing | AWS re:Post

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.