cloudfoundry / bosh-aws-cpi-release

BOSH AWS CPI
Apache License 2.0
29 stars 62 forks source link

create-env using CPI v96 fails compiling with "bundle: command not found" error #141

Closed lodener closed 1 year ago

lodener commented 1 year ago

When updating our BOSH director, the create-env operation seems to fail during the compilation of bosh_aws_cpi. It appears as if PATH is not including the bundle bin location when the change from 25868caf383634f214d239cf889cac82e49506fe is run.

Debug output:

[File System] 2023/01/02 14:58:23 DEBUG - Reading file /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/stemcell-manager2603373172/stemcell.MF
[File System] 2023/01/02 14:58:23 DEBUG - Read content
********************
---
name: bosh-aws-xen-hvm-ubuntu-jammy-go_agent
version: '1.64'
api_version: 3
bosh_protocol: '1'
sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
operating_system: ubuntu-jammy
stemcell_formats:
- aws-light
cloud_properties:
  infrastructure: aws
  ami:
    ap-northeast-1: ami-0e3926dbbcb119579
    ap-northeast-2: ami-089fcc88cd813d95e
    ap-northeast-3: ami-071b848a689019de3
    ap-south-1: ami-02ef8d6b6091d54e7
    ap-southeast-1: ami-082d7b1cd5bbde3be
    ap-southeast-2: ami-09c571edfde52e513
    ca-central-1: ami-082aa344c708557c0
    eu-central-1: ami-0f187ab97d56e2853
    eu-north-1: ami-0ba4a9e13a0964de0
    eu-west-1: ami-06697fc0134bdb793
    eu-west-2: ami-02496aec9cd23ebe7
    eu-west-3: ami-0e6195520a603408c
    sa-east-1: ami-0f617a6309408319b
    us-east-1: ami-09a7871e48141d4b8
    us-east-2: ami-0a209c9e5effb6395
    us-west-1: ami-0e7f0010aa557d987
    us-west-2: ami-0909ef4d521917695
    us-gov-east-1: ami-0f91eb35c68edb07e
    us-gov-west-1: ami-0f257b3632a6ba0b3

********************
 Finished (00:00:00)
Finished validating (00:00:10)
[config] 2023/01/02 14:58:23 DEBUG - Loading deployment state: state.json
[File System] 2023/01/02 14:58:23 DEBUG - Checking if file exists state.json
[File System] 2023/01/02 14:58:23 DEBUG - Stat 'state.json'
[File System] 2023/01/02 14:58:23 DEBUG - Reading file state.json
[File System] 2023/01/02 14:58:23 DEBUG - Read content
********************
{
    "director_id": "903766cb-135b-4380-70dc-477ab4ccbeaa",
    "installation_id": "68520a9a-0b2a-44c1-74e3-a60b789679aa",
    "current_vm_cid": "i-***",
    "current_stemcell_id": "dc2df2ac-2571-4267-4bc7-e2a8b94fbef0",
    "current_disk_id": "feffd4d6-38ce-4dfb-7d7d-66e9ed9c50c9",
    "current_release_ids": [
        "b4217934-1b20-4232-592e-28b171aaca17",
        "f13c4db8-a000-41f3-752d-4b72df76b13f",
        "c2b27741-835e-467d-7150-4a4fc3bf240c",
        "11a607d1-28f4-49b2-623a-286fd963006a",
        "230d54d6-be05-480a-5413-e9fc6b38f160",
        "f79ad23c-fcfe-4203-4d88-fd381ca742bc",
        "b02daf85-13f4-4258-6e69-219431674d2b"
    ],
    "current_manifest_sha": "948860f94380640255023d6396a2acc1e836b1182dde3c073d323d6fd7e84a52cb93283aa299f62f1b5a4d84e2e3d2fad2bee412a43e09a96e8c80e1ee2164ad",
    "disks": [
        {
            "id": "feffd4d6-38ce-4dfb-7d7d-66e9ed9c50c9",
            "cid": "vol-***",
            "size": 32768,
            "cloud_properties": {
                "type": "gp3"
            }
        }
    ],
    "stemcells": [
        {
            "id": "dc2df2ac-2571-4267-4bc7-e2a8b94fbef0",
            "name": "bosh-aws-xen-hvm-ubuntu-jammy-go_agent",
            "version": "1.64",
            "api_version": 3,
            "cid": "ami-06697fc0134bdb793 light"
        }
    ],
    "releases": [
        {
            "id": "b4217934-1b20-4232-592e-28b171aaca17",
            "name": "bosh",
            "version": "276.1.1"
        },
        {
            "id": "f13c4db8-a000-41f3-752d-4b72df76b13f",
            "name": "bpm",
            "version": "1.1.21"
        },
        {
            "id": "c2b27741-835e-467d-7150-4a4fc3bf240c",
            "name": "bosh-aws-cpi",
            "version": "96"
        },
        {
            "id": "11a607d1-28f4-49b2-623a-286fd963006a",
            "name": "os-conf",
            "version": "22.1.2"
        },
        {
            "id": "230d54d6-be05-480a-5413-e9fc6b38f160",
            "name": "uaa",
            "version": "76.4.0"
        },
        {
            "id": "f79ad23c-fcfe-4203-4d88-fd381ca742bc",
            "name": "credhub",
            "version": "2.12.17"
        },
        {
            "id": "b02daf85-13f4-4258-6e69-219431674d2b",
            "name": "node-exporter",
            "version": "5.0.0"
        }
    ]
}
********************
[config] 2023/01/02 14:58:23 DEBUG - Deployment File Contents {
    "director_id": "903766cb-135b-4380-70dc-477ab4ccbeaa",
    "installation_id": "68520a9a-0b2a-44c1-74e3-a60b789679aa",
    "current_vm_cid": "i-***",
    "current_stemcell_id": "dc2df2ac-2571-4267-4bc7-e2a8b94fbef0",
    "current_disk_id": "feffd4d6-38ce-4dfb-7d7d-66e9ed9c50c9",
    "current_release_ids": [
        "b4217934-1b20-4232-592e-28b171aaca17",
        "f13c4db8-a000-41f3-752d-4b72df76b13f",
        "c2b27741-835e-467d-7150-4a4fc3bf240c",
        "11a607d1-28f4-49b2-623a-286fd963006a",
        "230d54d6-be05-480a-5413-e9fc6b38f160",
        "f79ad23c-fcfe-4203-4d88-fd381ca742bc",
        "b02daf85-13f4-4258-6e69-219431674d2b"
    ],
    "current_manifest_sha": "948860f94380640255023d6396a2acc1e836b1182dde3c073d323d6fd7e84a52cb93283aa299f62f1b5a4d84e2e3d2fad2bee412a43e09a96e8c80e1ee2164ad",
    "disks": [
        {
            "id": "feffd4d6-38ce-4dfb-7d7d-66e9ed9c50c9",
            "cid": "vol-***",
            "size": 32768,
            "cloud_properties": {
                "type": "gp3"
            }
        }
    ],
    "stemcells": [
        {
            "id": "dc2df2ac-2571-4267-4bc7-e2a8b94fbef0",
            "name": "bosh-aws-xen-hvm-ubuntu-jammy-go_agent",
            "version": "1.64",
            "api_version": 3,
            "cid": "ami-06697fc0134bdb793 light"
        }
    ],
    "releases": [
        {
            "id": "b4217934-1b20-4232-592e-28b171aaca17",
            "name": "bosh",
            "version": "276.1.1"
        },
        {
            "id": "f13c4db8-a000-41f3-752d-4b72df76b13f",
            "name": "bpm",
            "version": "1.1.21"
        },
        {
            "id": "c2b27741-835e-467d-7150-4a4fc3bf240c",
            "name": "bosh-aws-cpi",
            "version": "96"
        },
        {
            "id": "11a607d1-28f4-49b2-623a-286fd963006a",
            "name": "os-conf",
            "version": "22.1.2"
        },
        {
            "id": "230d54d6-be05-480a-5413-e9fc6b38f160",
            "name": "uaa",
            "version": "76.4.0"
        },
        {
            "id": "f79ad23c-fcfe-4203-4d88-fd381ca742bc",
            "name": "credhub",
            "version": "2.12.17"
        },
        {
            "id": "b02daf85-13f4-4258-6e69-219431674d2b",
            "name": "node-exporter",
            "version": "5.0.0"
        }
    ]
}

Started installing CPI
[installer] 2023/01/02 14:58:23 INFO - Installing CPI deployment 'bosh'
[installer] 2023/01/02 14:58:23 DEBUG - Installing CPI deployment 'bosh' with manifest: manifest.Manifest{Name:"bosh", Template:manifest.ReleaseJobRef{Name:"aws_cpi", Release:"bosh-aws-cpi"}, Properties:property.Map{"agent":property.Map{"mbus":"https://mbus:***@0.0.0.0:6868"}, "aws":property.Map{"credentials_source":"env_or_profile", "default_iam_instance_profile":"***", "default_key_name":"***", "default_security_groups":property.List{"***"}, "iam_instance_profile":"***", "region":"eu-west-1"}, "blobstore":property.Map{"path":"/var/vcap/micro_bosh/data/cache", "provider":"local"}}, Mbus:"https://mbus:***@***:6868", Cert:manifest.Certificate{CA:"-----BEGIN CERTIFICATE-----\n***\n-----END CERTIFICATE-----\n"}}
[dependencyCompiler] 2023/01/02 14:58:23 DEBUG - Sorted dependencies:
aws-cpi-ruby-3.1/4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744
bosh_aws_cpi/6e28528c67ec23092911b251ad834ed03231efd12c37d54025dba804fb3fc45c
  Compiling package 'aws-cpi-ruby-3.1/4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744'...[packageCompiler] 2023/01/02 14:58:23 DEBUG - Checking for compiled package 'aws-cpi-ruby-3.1/4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744'
[File System] 2023/01/02 14:58:23 DEBUG - Checking if file exists /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json'
[File System] 2023/01/02 14:58:23 DEBUG - Reading file /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Read content
********************
[{"Key":{"DependencyKey":"","PackageFingerprint":"4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744","PackageName":"aws-cpi-ruby-3.1"},"Value":{"BlobID":"d86697d5-d3e1-4b5f-6dd5-b10656c3477b","BlobSHA1":"sha256:0c333bf61c12e9cdcea16a095c40470252f3b19b1e4a13839b057c6945212c5f"}}]
********************
 Finished (00:00:00)
  Compiling package 'bosh_aws_cpi/6e28528c67ec23092911b251ad834ed03231efd12c37d54025dba804fb3fc45c'...[packageCompiler] 2023/01/02 14:58:23 DEBUG - Checking for compiled package 'bosh_aws_cpi/6e28528c67ec23092911b251ad834ed03231efd12c37d54025dba804fb3fc45c'
[File System] 2023/01/02 14:58:23 DEBUG - Checking if file exists /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json'
[File System] 2023/01/02 14:58:23 DEBUG - Reading file /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Read content
********************
[{"Key":{"DependencyKey":"","PackageFingerprint":"4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744","PackageName":"aws-cpi-ruby-3.1"},"Value":{"BlobID":"d86697d5-d3e1-4b5f-6dd5-b10656c3477b","BlobSHA1":"sha256:0c333bf61c12e9cdcea16a095c40470252f3b19b1e4a13839b057c6945212c5f"}}]
********************
[packageCompiler] 2023/01/02 14:58:23 DEBUG - Installing dependencies of package 'bosh_aws_cpi/6e28528c67ec23092911b251ad834ed03231efd12c37d54025dba804fb3fc45c'
[packageCompiler] 2023/01/02 14:58:23 DEBUG - Checking for compiled package 'aws-cpi-ruby-3.1/4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744'
[File System] 2023/01/02 14:58:23 DEBUG - Checking if file exists /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json'
[File System] 2023/01/02 14:58:23 DEBUG - Reading file /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/compiled_packages.json
[File System] 2023/01/02 14:58:23 DEBUG - Read content
********************
[{"Key":{"DependencyKey":"","PackageFingerprint":"4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744","PackageName":"aws-cpi-ruby-3.1"},"Value":{"BlobID":"d86697d5-d3e1-4b5f-6dd5-b10656c3477b","BlobSHA1":"sha256:0c333bf61c12e9cdcea16a095c40470252f3b19b1e4a13839b057c6945212c5f"}}]
********************
[packageCompiler] 2023/01/02 14:58:23 DEBUG - Installing package 'aws-cpi-ruby-3.1/4ee287ba7e2dce5e088dabda8f41615bd3a47f1e12e39445a77833c8fb0f5744'
[File System] 2023/01/02 14:58:23 DEBUG - Creating temp file with prefix bosh-blobstore-external-Get
[File System] 2023/01/02 14:58:23 DEBUG - Copying file '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/blobs/d86697d5-d3e1-4b5f-6dd5-b10656c3477b' to '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/bosh-blobstore-external-Get4099259026'
[File System] 2023/01/02 14:58:23 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/blobs/d86697d5-d3e1-4b5f-6dd5-b10656c3477b'
[File System] 2023/01/02 14:58:24 DEBUG - Checking if file exists /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1
[File System] 2023/01/02 14:58:24 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1'
[File System] 2023/01/02 14:58:24 DEBUG - Making dir /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1 with perm 0777
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Running command 'tar --no-same-owner -xzf /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/bosh-blobstore-external-Get4099259026 -C /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1'
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Stdout:
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Stderr:
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Successful: true (0)
[File System] 2023/01/02 14:58:24 DEBUG - Remove all /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/bosh-blobstore-external-Get4099259026
[packageCompiler] 2023/01/02 14:58:24 DEBUG - Compiling package 'bosh_aws_cpi/6e28528c67ec23092911b251ad834ed03231efd12c37d54025dba804fb3fc45c'
[File System] 2023/01/02 14:58:24 DEBUG - Making dir /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/bosh_aws_cpi with perm 0777
[File System] 2023/01/02 14:58:24 DEBUG - Checking if file exists /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/bosh-release-pkg1630265185/packaging
[File System] 2023/01/02 14:58:24 DEBUG - Stat '/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/tmp/bosh-release-pkg1630265185/packaging'
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Running command 'bash -x packaging'
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Stdout:
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Stderr: + set -e
+ BOSH_PACKAGES_DIR=/root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages
+ source /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1/bosh/compile.env
+ cp -a bosh_aws_cpi/Gemfile bosh_aws_cpi/Gemfile.lock bosh_aws_cpi/bin bosh_aws_cpi/lib bosh_aws_cpi/vendor /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/bosh_aws_cpi
+ cd /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/bosh_aws_cpi
++ bundle -v
packaging: line 14: bundle: command not found
++ grep -o -e '[0-9.]*'
+ export BUNDLER_VERSION=
+ BUNDLER_VERSION=
+ bundle config set --local deployment true
packaging: line 15: bundle: command not found
[Cmd Runner] 2023/01/02 14:58:24 DEBUG - Successful: false (127)
[File System] 2023/01/02 14:58:24 DEBUG - Remove all /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages
 Failed (00:00:00)
Failed installing CPI (00:00:00)

This issue does not occur when falling back to the v95 CPI release.

ramonskie commented 1 year ago

the commit you pointed out to is used in v95 so if v95 works for you than this should not be the change causing this issue

but as you are running bosh create-env bundler should be available in your path on the machine/image you are running it from.

rkoster commented 1 year ago

@lodener could you post the contents of /root/.bosh/installations/68520a9a-0b2a-44c1-74e3-a60b789679aa/packages/aws-cpi-ruby-3.1/bosh/compile.env?

lodener commented 1 year ago

@ramonskie ah yes you're right, my bad. So something related to the package being moved/renamed from ruby-3.1 to aws-cpi-ruby-3.1 then perhaps?

@rkoster both compile.env and runtime.env appear to be empty on v96. ./packages/:

total 12
drwxr-xr-x 6 root root 4096 Jan  6 12:18 ..
drwxr-xr-x 3 root root 4096 Jan  6 12:18 .
drwxr-xr-x 3 root root 4096 Jan  6 12:18 aws-cpi-ruby-3.1

./packages/aws-cpi-ruby-3.1/bosh/:

total 12
-rw-r--r-- 1 root root    0 Jan  6 11:02 runtime.env
-rw-r--r-- 1 root root   19 Jan  6 11:02 gemrc
-rw-r--r-- 1 root root    0 Jan  6 11:02 compile.env
drwxr-xr-x 7 root root 4096 Jan  6 11:48 ..
drwxr-xr-x 2 root root 4096 Jan  6 11:48 .

Whereas on v95 they are properly populated (./ruby-3.1/bosh/):

total 20
-rw-r--r-- 1 root root  150 Jan  6 11:55 runtime.env
-rw-r--r-- 1 root root   19 Jan  6 11:55 gemrc
-rw-r--r-- 1 root root 1085 Jan  6 11:55 compile.env
drwxr-xr-x 7 root root 4096 Jan  6 11:55 ..
drwxr-xr-x 2 root root 4096 Jan  6 11:55 .

compile.env on v95:

#!/bin/bash

# shellcheck disable=1090
source "${BOSH_PACKAGES_DIR:-/var/vcap/packages}/ruby-3.1/bosh/runtime.env"

# Use Clang if available; the resulting Ruby is faster
if [ -x /usr/bin/clang ]; then
  export CXX=/usr/bin/clang++ CC=/usr/bin/clang
fi

bosh_bundle() {
  bundle config set --local no_prune 'true'
  bundle config set --local without 'development test'
  bundle config set --local path "${BOSH_INSTALL_TARGET}/gem_home"

  bundle install \
    --binstubs "${BOSH_INSTALL_TARGET}/bin" \
    "$@"
}

bosh_bundle_local() {
  bundle config set --local no_prune 'true'
  bundle config set --local without 'development test'
  bundle config set --local path "${BOSH_INSTALL_TARGET}/gem_home"

  bundle install \
    --local \
    --binstubs "${BOSH_INSTALL_TARGET}/bin" \
    "$@"
}

bosh_generate_runtime_env() {
  mkdir -p "${BOSH_INSTALL_TARGET}/bosh"
  cat > "${BOSH_INSTALL_TARGET}/bosh/runtime.env" <<EOF
export PATH=${BOSH_INSTALL_TARGET}/bin:\$PATH
export GEM_HOME=${BOSH_INSTALL_TARGET}/gem_home/ruby/3.1.2
export BUNDLE_GEMFILE=${BOSH_INSTALL_TARGET}/Gemfile
EOF
}

Additionally, this is being run on a Concourse 7.9.0 worker VM (Linux 97078b27-44a5-444f-51d8-53a31b70d446 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 GNU/Linux).

rkoster commented 1 year ago

When you say:

both compile.env and runtime.env appear to be empty on v96.
./packages/:

total 12
drwxr-xr-x 6 root root 4096 Jan  6 12:18 ..
drwxr-xr-x 3 root root 4096 Jan  6 12:18 .
drwxr-xr-x 3 root root 4096 Jan  6 12:18 aws-cpi-ruby-3.1

Do you mean the ./packages/aws-cpi-ruby-3.1 directory is empty?

rkoster commented 1 year ago

I think you are running into: https://github.com/bosh-packages/ruby-release/commit/f390302c17b090bb7d449e0fef6798986b812c00

Could you try installing envsubst in your concourse container?

rkoster commented 1 year ago

The above change has already been bumped into the aws-cpi, so the next release will use sed instead of envsubst.

lodener commented 1 year ago

When you say:

both compile.env and runtime.env appear to be empty on v96.
./packages/:

total 12
drwxr-xr-x 6 root root 4096 Jan  6 12:18 ..
drwxr-xr-x 3 root root 4096 Jan  6 12:18 .
drwxr-xr-x 3 root root 4096 Jan  6 12:18 aws-cpi-ruby-3.1

Do you mean the ./packages/aws-cpi-ruby-3.1 directory is empty?

No I only added that just to show the directory is actually created, the directory itself is not empty.

I think you are running into: bosh-packages/ruby-release@f390302

Could you try installing envsubst in your concourse container?

Spot on, the gettext package was indeed not present and after installing it,envsubst is there and the .env files are populated properly resulting in a successful create-env run.

The above change has already been bumped into the aws-cpi, so the next release will use sed instead of envsubst.

Nice, thanks for the insight-/helpful replies!

beyhan commented 1 year ago

This is clarified and this is fixed in Ruby 3.2 update.