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

The "cargo make" step creates invalid symlinks when the BUILDSYS_NAME variable is set #1311

Closed
diranged opened this issue Feb 9, 2021 · 1 comment · Fixed by #1312
Closed
Assignees

Comments

@diranged
Copy link

diranged commented Feb 9, 2021

Platform I'm building on:
AWS CodeBuild

What I expected to happen:
We set the BUILDSYS_NAME to a custom value (in this example, nd-bottlerocket). The build itself works fine, but it produces images that are named bottlerocket-... but symlinks that are pointing to files named nd-bottlerocket....

What actually happened:

root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket# cargo make -e BUILDSYS_NAME=${BUILDSYS_NAME} -e BUILDSYS_VARIANT=${BUILDSYS_VARIANT} -e BUILDSYS_ARCH=${BUILDSYS_ARCH} -e PUBLISH_DATA_VOLUME_SIZE=${PUBLISH_DATA_VOLUME_SIZE} -e BUILDSYS_JOBS=32
[cargo-make] INFO - cargo make 0.32.12
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: setup
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ mkdir -p /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build
+ mkdir -p /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18
+ mkdir -p /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/rpms
+ mkdir -p /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/.gomodcache
[cargo-make] INFO - Running Task: setup-build
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ command -v curl
+ command -v docker
+ command -v gunzip
+ command -v lz4
[cargo-make] INFO - Running Task: fetch-sdk
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ set -o pipefail
+ docker image inspect bottlerocket/sdk-x86_64:v0.15.0-x86_64
[cargo-make] INFO - Running Task: fetch-sources
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ for ws in sources packages variants/* tools
+ '[' -d sources ']'
+ cargo fetch --locked --manifest-path sources/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d packages ']'
+ cargo fetch --locked --manifest-path packages/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/README.md ']'
+ continue
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-dev ']'
+ cargo fetch --locked --manifest-path variants/aws-dev/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-ecs-1 ']'
+ cargo fetch --locked --manifest-path variants/aws-ecs-1/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-k8s-1.15 ']'
+ cargo fetch --locked --manifest-path variants/aws-k8s-1.15/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-k8s-1.16 ']'
+ cargo fetch --locked --manifest-path variants/aws-k8s-1.16/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-k8s-1.17 ']'
+ cargo fetch --locked --manifest-path variants/aws-k8s-1.17/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-k8s-1.18 ']'
+ cargo fetch --locked --manifest-path variants/aws-k8s-1.18/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d variants/aws-k8s-1.19 ']'
+ cargo fetch --locked --manifest-path variants/aws-k8s-1.19/Cargo.toml
+ for ws in sources packages variants/* tools
+ '[' -d tools ']'
+ cargo fetch --locked --manifest-path tools/Cargo.toml
+ chmod -R o+r /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/.cargo
[cargo-make] INFO - Running Task: fetch-vendored
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/tools/docker-go --module-path /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/sources/host-ctr --sdk-image bottlerocket/sdk-x86_64:v0.15.0-x86_64 --go-mod-cache /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/.gomodcache --command go list -mod=readonly ./... >/dev/null && go mod vendor
[cargo-make] INFO - Running Task: fetch
[cargo-make] INFO - Running Task: link-clean
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-boot.ext4.lz4 ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-boot.ext4.lz4
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-data.img.lz4 ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-data.img.lz4
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-migrations.tar ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-migrations.tar
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.ext4.lz4 ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.ext4.lz4
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.verity.lz4 ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.verity.lz4
+ [ -L /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4 ]
+ rm /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4
[cargo-make] INFO - Running Task: check-licenses
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ [ false = true ]
+ cd sources
+ cargo deny check --disable-fetch licenses
+ cd tools
+ cargo deny check --disable-fetch licenses
+ set -e
[cargo-make] INFO - Running Task: build-tools
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ cargo install --jobs 32 --offline --locked --path tools/buildsys --root tools --force --quiet
[cargo-make] INFO - Running Task: tuftool
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ cargo install --jobs 32 --root tools --quiet tuftool
[cargo-make] INFO - Running Task: publish-setup-tools
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ cargo install --jobs 32 --offline --locked --path tools/pubsys-setup --root tools --force --quiet
[cargo-make] INFO - Running Task: publish-setup
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ set -e
+ export PATH=/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/tools/bin:/root/.cargo/bin:/root/.cargo/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/tools/bin:/usr/local/android-sdk-linux/platform-tools:/codebuild/user/bin
+ [  = true ]
+ pubsys-setup --infra-config-path /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/Infra.toml --root-role-path /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/roles/default.root.json --default-key-path /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/keys/default.pem --repo default
18:54:25 [INFO] Found infra config at path: /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/Infra.toml
18:54:25 [INFO] No repo config in '/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/Infra.toml' - using local roles/keys
[cargo-make] INFO - Running Task: build-packages
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ export PATH=/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/tools/bin:/root/.cargo/bin:/root/.cargo/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/tools/bin:/usr/local/android-sdk-linux/platform-tools:/codebuild/user/bin
+ cargo build --jobs 32 --offline --locked --manifest-path packages/Cargo.toml --all
    Finished dev [optimized] target(s) in 0.12s
[cargo-make] INFO - Running Task: build-variant
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ export PATH=/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/tools/bin:/root/.cargo/bin:/root/.cargo/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/tools/bin:/usr/local/android-sdk-linux/platform-tools:/codebuild/user/bin
+ cargo build --jobs 32 --offline --locked --manifest-path variants/aws-k8s-1.18/Cargo.toml
   Compiling aws-k8s-1_18 v0.1.0 (/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/variants/aws-k8s-1.18)
    Finished dev [unoptimized + debuginfo] target(s) in 52.07s
[cargo-make] INFO - Running Task: link-variant
+ cd /codebuild/output/src598688494/src/github.com/xxx/bottlerocket
+ mkdir -p /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95.img.lz4 /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-data.img.lz4 /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-data.img.lz4
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-boot.ext4.lz4 /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-boot.ext4.lz4
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.ext4.lz4 /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.ext4.lz4
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.verity.lz4 /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.verity.lz4
+ ln -snf ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-migrations.tar /codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-migrations.tar
[cargo-make] INFO - Running Task: default
[cargo-make] INFO - ================Time Summary================
[cargo-make] INFO - build-variant:         90.80%          52.14 seconds
[cargo-make] INFO - fetch-sources:         3.76%           2.16 seconds
[cargo-make] INFO - fetch-vendored:        1.77%           1.01 seconds
[cargo-make] INFO - check-licenses:        1.12%           0.64 seconds
[cargo-make] INFO - tuftool:               1.05%           0.60 seconds
[cargo-make] INFO - publish-setup-tools:   0.74%           0.42 seconds
[cargo-make] INFO - build-packages:        0.36%           0.21 seconds
[cargo-make] INFO - build-tools:           0.32%           0.18 seconds
[cargo-make] INFO - fetch-sdk:             0.05%           0.03 seconds
[cargo-make] INFO - link-variant:          0.02%           0.01 seconds
[cargo-make] INFO - link-clean:            0.01%           0.01 seconds
[cargo-make] INFO - setup:                 0.01%           0.01 seconds
[cargo-make] INFO - publish-setup:         0.01%           0.00 seconds
[cargo-make] INFO - setup-build:           0.00%           0.00 seconds
[cargo-make] INFO - fetch:                 0.00%           0.00 seconds
[cargo-make] INFO - default:               0.00%           0.00 seconds
[cargo-make] INFO - ============================================
[cargo-make] INFO - Build Done in 57.44 seconds.

At this point, if we look for the image symlinks, we see ones that look right at first glance:

root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket# find build/images/*/latest -type l
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.ext4.lz4
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-root.verity.lz4
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-boot.ext4.lz4
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-migrations.tar
build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64-data.img.lz4

However if we dig in, we'll see that they are broken symlinks:

root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket# ls -la build/images/x86_64-aws-k8s-1.18/
total 523588
drwxr-xr-x 3 root root      4096 Feb  9 18:55 .
drwxr-xr-x 4 root root      4096 Feb  9 18:42 ..
-rw-r--r-- 1 root root  12491284 Feb  9 18:54 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-boot.ext4.lz4
-rw-r--r-- 1 root root   4220091 Feb  9 18:54 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-data.img.lz4
-rw-r--r-- 1 root root  11847680 Feb  9 18:54 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-migrations.tar
-rw-r--r-- 1 root root 216188134 Feb  9 18:55 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.ext4.lz4
-rw-r--r-- 1 root root   4596427 Feb  9 18:54 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.verity.lz4
-rw-r--r-- 1 root root 286782341 Feb  9 18:54 bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95.img.lz4
drwxr-xr-x 2 root root      4096 Feb  9 18:55 latest
root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket# ls -la build/images/x86_64-aws-k8s-1.18/latest
total 32
drwxr-xr-x 2 root root 4096 Feb  9 18:55 .
drwxr-xr-x 3 root root 4096 Feb  9 18:55 ..
lrwxrwxrwx 1 root root   66 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64-boot.ext4.lz4 -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-boot.ext4.lz4
lrwxrwxrwx 1 root root   65 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64-data.img.lz4 -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-data.img.lz4
lrwxrwxrwx 1 root root   67 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64-migrations.tar -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-migrations.tar
lrwxrwxrwx 1 root root   66 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64-root.ext4.lz4 -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.ext4.lz4
lrwxrwxrwx 1 root root   68 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64-root.verity.lz4 -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95-root.verity.lz4
lrwxrwxrwx 1 root root   60 Feb  9 18:55 nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4 -> ../nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95.img.lz4
root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket# realpath build/images/x86_64-aws-k8s-1.18/latest/nd-bottlerocket-aws-k8s-1.18-x86_64.img.lz4
/codebuild/output/src598688494/src/github.com/xxx/bottlerocket/build/images/x86_64-aws-k8s-1.18/nd-bottlerocket-aws-k8s-1.18-x86_64-1.0.5-f306b95.img.lz4
root@206b2110f8a1:/codebuild/output/src598688494/src/github.com/xxx/bottlerocket#

How to reproduce the problem:
Set the BUILDSYS_NAME variable for your ami build..

The problem

These broken symlinks then cause the cargo make ami step to fail..

@tjkirch tjkirch self-assigned this Feb 9, 2021
@tjkirch
Copy link
Contributor

tjkirch commented Feb 9, 2021

Thanks for finding and reporting this!

It looks like rpm2img is assuming the prefix, so I'll work on plumbing the real one through.

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 a pull request may close this issue.

2 participants