buildkite-plugins/docker-buildkite-plugin

error pulling amazonlinux:latest

royalcala opened this issue · 6 comments

  - docker#v5.6.0:
        image: "amazonlinux:latest"
        always-pull: true

hello, Could you help me, I have these errors in the logs of buildkite when I try to use the latest of amazonlinux, with a previous version works but not with the latest

Unable to find image 'amazonlinux:latest' locally
--
  | latest: Pulling from library/amazonlinux
  | ee5c3b4d09bc: Pull complete
  | Digest: sha256:1293fb4fa103ea81a8769d7b0aa000072884b0750c0a28563fd9838fea784245
  | Status: Downloaded newer image for amazonlinux:latest
  | Amazon Linux 2023 repository                    0.0  B/s \|   0  B     00:00
  | Errors during downloading metadata for repository 'amazonlinux':
  | - Curl error (6): Couldn't resolve host name for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.0.20230322/x86_64/mirror.list [getaddrinfo() thread failed to start]
  | Error: Failed to download metadata for repo 'amazonlinux': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.0.20230322/x86_64/mirror.list [getaddrinfo() thread failed to start]
  | Ignoring repositories: amazonlinux
  | No match for argument: unzip
toote commented

@royalcala the error appears to be on the command you are running as the docker pull output is only up to the Status: line, whatever is after that is what you are running inside the container.

Could you provide more information so that we can further troubleshoot?

thanks @toote , these are my logs and the following is my config(if I use image: "amazonlinux:2" works, but not with the latest version, suddenly it stopped working)

steps:
- label: ":lambda: Unit testing & lambda zip artifact creation"
  commands:
    - "npm install"
    - "npm run test"
    - "mkdir -p build"
    - "chown -R $(whoami) build"
    - "cp src/index.js package.json package-lock.json src/constants.js build"
    - "cp src/country.utils.js src/constants.zip_codes.js src/zip_code.utils.js src/identifiers.js build"
    - "cd build && npm install --production"
    - "npx bestzip lambda.zip *"
    - "buildkite-agent artifact upload lambda.zip"
  plugins:
    - docker#v3.9.0:
        image: "node:12"

- wait
- label: ":rocket: Deploying lambda zip to aws"
  command: "./lambda-deploy.sh"
  plugins:
    - cultureamp/aws-assume-role:
        role: arn:aws:iam::127579856528:role/buildkite-sam-role
    - docker#v3.9.0:
        image: "amazonlinux"
        propagate-environment: true
        environment:
          - AWS_REGION
          - AWS_SECRET_ACCESS_KEY
          - AWS_SESSION_TOKEN
          - AWS_DEFAULT_REGION
          - AWS_ACCESS_KEY_ID
toote commented

@royalcala looks like the issue is within your ./lambda-deploy.sh script. From the error, it would appear that that it is not finding the zipfile... which makes sense as you are uploading it as an artifact in the previous step but not downloading afterwards 🤷

this is my lambda-deploy.sh that works before but now it doesn't works with the latest image

#!/usr/bin/env /bin/bash
echo "************************************************************"
echo "Starting Deployment to ${LAMBDA_ENV}"
echo "************************************************************"
set -euo pipefail


LAMBDA_ENV="mktg_starfish_lambda_stg"
ENVIRONMENT="stg"
if [[ "${BUILDKITE_BRANCH}" == "main" ]]; then
   LAMBDA_ENV="mktg_starfish_lambda"
   ENVIRONMENT="prod"
fi


yum -y install unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip && ./aws/install


buildkite-agent artifact download lambda.zip .


aws lambda update-function-code \
   --publish \
   --function-name $LAMBDA_ENV \
   --zip-file fileb://lambda.zip > /dev/null


echo "************************************************************"
echo "Deployment completed to ${LAMBDA_ENV}"
echo "************************************************************"

with the latest amazonlinux version works adding privileged to true

    - docker#v3.9.0:
        image: "amazonlinux"
        privileged: true
toote commented

That is weird... the error is obviously that curl could not download the the installation step as you can see in the following line:

Couldn't resolve host name for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.0.20230322/x86_64/mirror.list [getaddrinfo() thread failed to start]

Doesn't look like an issue with the plugin itself but with the network where it is running or the setup of docker because I can't reproduce on my local agent :(