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

check whether symlink exists #534

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

hallyn
Copy link
Contributor

@hallyn hallyn commented Nov 5, 2023

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hallyn hallyn force-pushed the 2023-11-04/symlinkmayexist branch from 3a38799 to 124a642 Compare November 5, 2023 03:57
Copy link

codecov bot commented Nov 5, 2023

Codecov Report

Merging #534 (9350b59) into main (67d1ffb) will decrease coverage by 0.14%.
Report is 2 commits behind head on main.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #534      +/-   ##
==========================================
- Coverage   13.14%   13.01%   -0.14%     
==========================================
  Files          40       40              
  Lines        5943     6003      +60     
==========================================
  Hits          781      781              
- Misses       5034     5094      +60     
  Partials      128      128              
Files Coverage Δ
pkg/overlay/pack.go 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@hallyn hallyn force-pushed the 2023-11-04/symlinkmayexist branch from 124a642 to 536ae90 Compare November 5, 2023 13:12
@hallyn hallyn marked this pull request as ready for review November 5, 2023 13:12
Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but still need to understand whether our test cases are incomplete since we didn't need this check until now.

@hallyn
Copy link
Contributor Author

hallyn commented Nov 8, 2023

install-base:
  build_only: true
  from:
    type: docker
    url: "docker://zothub.io/machine/bootkit/rootfs:v0.0.17.231018-squashfs"
    
install-rootfs-pkg:
  from:
    type: built
    tag: install-base
  build_only: true
  run: |
    #!/bin/sh -ex
    writefile() {
      mkdir -p "${1%/*}"
      echo "write $1" 1>&2
      cat >"$1"
    }

    writefile /etc/systemd/network/20-wire-enp0s-dhcp.network <<"END"
    [Match]
    Name=enp0s*
    [Network]
    DHCP=yes
    END

demo-zot:
  from:
    type: built
    tag: install-rootfs-pkg
  import:
    - x
  run: |
    #!/bin/sh -ex
    cp /stacker/imports/x /usr/bin/x

If I first stacker build --layer-type=squashfs, then --layer-type=tar, then this case broke for me in two ways. The first time, it would give me:

+ cp /stacker/imports/x /usr/bin/x
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
stackerbuild.io/stacker/pkg/overlay.generateLayer({{0x0, 0x0}, {0xc000046270, 0x2b}, {0xc000046570, 0x26}, {0xc0000465d0, 0x28}, 0x0, {0x1bb3f7e, ...}, ...}, ...)
        /stacker-tree/pkg/overlay/pack.go:400 +0x157b
stackerbuild.io/stacker/pkg/overlay.repackOverlay({{0x0, 0x0}, {0xc000046270, 0x2b}, {0xc000046570, 0x26}, {0xc0000465d0, 0x28}, 0x0, {0x1bb3f7e, ...}, ...}, ...)
        /stacker-tree/pkg/overlay/pack.go:602 +0x707
stackerbuild.io/stacker/pkg/overlay.(*overlay).Repack(0xc000288ea0, {0xc0003a5bf0, 0x8}, {0xc000012648, 0x1, 0x1}, 0x4c?)
        /stacker-tree/pkg/overlay/pack.go:292 +0xe5
stackerbuild.io/stacker/pkg/stacker.(*Builder).build(0xc000052b50, {0x3490440, 0xc000288ea0}, {0xc000047ec0, 0x2f})
        /stacker-tree/pkg/stacker/build.go:512 +0x1176
stackerbuild.io/stacker/pkg/stacker.(*Builder).BuildMultiple(0xc000052b50, {0xc000441670, 0x1, 0x1})
        /stacker-tree/pkg/stacker/build.go:610 +0x5ea
main.doBuild(0x4024340?)

The second woudl give me:

+ cp /stacker/imports/x /usr/bin/x
error: failed to create squashfs symlink: symlink /home/serge/delme/stackerfail/orig/roots/sha256_1b0a2913c9959502eb1f534067eec3f5ced3f656f6ea3170cfbe2484e7e484e5 /home/serge/delme/stackerfail/orig/roots/sha256_c46ab27817af8af8deb0bb60493266913dcef9fc76a3e4d5d1a42a3ced6b0196: file exists
error: exit status 1

With this fixed version, it builds the tar layers properly without crashing.

@hallyn hallyn force-pushed the 2023-11-04/symlinkmayexist branch from 6b49b78 to 9350b59 Compare November 9, 2023 00:47
@rchincha
Copy link
Contributor

rchincha commented Nov 9, 2023

So this fails then?
#540

@rchincha rchincha merged commit dcc1eca into project-stacker:main Nov 10, 2023
7 of 9 checks passed
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 this pull request may close these issues.

2 participants