project-stacker/stacker

Bug: import when path is a (http/https) url does not allow renaming

Opened this issue · 2 comments

smoser commented

stacker version

v1.0.0-rc4-8e267fc

Describe the bug

stacker cannot rename an import when the 'path' is a http or https url.
the imported path will be the basename of the url.

To reproduce

  1. Configuration
    stacker.yaml
build:
  build_only: true
  from: 
    type: docker
    url: ${{DOCKER_BASE:docker://docker.io/library}}/busybox
  import:
    - path: /etc/passwd
      dest: /imports/host-file
    - path: https://www.cisco.com/favicon.ico
      dest: /imports/http-file
  run: |
    #!/bin/sh
    set +e
    
    ERRS=0
    err() { echo "$@"; ERRS=$((ERRS+1)); }
    assertFile() {
      [ -f "$1" ] || {
        err "$1: not a file"
        return 1
      }
      return 0
    }

    ls -l /imports
    assertFile /imports/host-file
    assertFile /imports/http-file

    [ "$ERRS" = "0" ]
  1. Client tool used: stacker build
  2. Seen error
+ stacker --work-dir=/tmp/xx/workdir clean
+ stacker --debug --work-dir=/tmp/xx/workdir build stacker.yaml
stacker version v1.0.0-rc4-8e267fc
usernsexec-ing [u 0 1000 1 1 100001 65535 g 0 1000 1 1 100001 65535 -- /usr/local/bin/stacker --internal-userns --debug --work-dir=/tmp/xx/workdir build stacker.yaml]
stacker version v1.0.0-rc4-8e267fc
no previous storage type detected
initializing stacker recipe: stacker.yaml
substituting $STACKER_ROOTFS_DIR to /tmp/xx/workdir/roots
substituting $STACKER_STACKER_DIR to /tmp/xx/workdir/.stacker
substituting $STACKER_OCI_DIR to /tmp/xx/workdir/oci
substituting $STACKER_WORK_DIR to /tmp/xx/workdir
stacker build order:
0 build /tmp/xx/stacker.yaml: requires: []
building: 0 /tmp/xx/stacker.yaml
substituting $STACKER_ROOTFS_DIR to /tmp/xx/workdir/roots
substituting $STACKER_STACKER_DIR to /tmp/xx/workdir/.stacker
substituting $STACKER_OCI_DIR to /tmp/xx/workdir/oci
substituting $STACKER_WORK_DIR to /tmp/xx/workdir
Dependency Order [build]
preparing image build...
copying /etc/passwd
Remote file: hash:  length: 1406
downloading https://www.cisco.com/favicon.ico
overlay-dirs, possibly modified after import: [{/tmp/xx/workdir/.stacker/imports-copy/build/2347239968 /imports} {/tmp/xx/workdir/.stacker/imports-copy/build/1875296639 /imports}]
loading docker://docker.io/library/busybox
unpacking to /tmp/xx/workdir/roots/build
lxc rootfs overlay arg overlayfs:/tmp/xx/workdir/roots/sha256_5117e10bc8baa52d35c600833f4f12d12ada63d94b373b1c9a5dbccc08e204d3/overlay:/tmp/xx/workdir/roots/sha256_7f5dcf49981ba90c6d381da1e524d7e6577dd1d20fdf772463b3a17367e66d5f/overlay:/tmp/xx/workdir/roots/sha256_4b35f584bb4f862773e2b84b827795b6f01985c7bcebb0696a3eb66318a166a5/overlay:/tmp/xx/workdir/roots/build/overlay
stacker version v1.0.0-rc4-8e267fc
stacker subcommand: [/usr/local/bin/stacker --oci-dir /tmp/xx/workdir/oci --roots-dir /tmp/xx/workdir/roots --stacker-dir /tmp/xx/workdir/.stacker --storage-type overlay --internal-userns --debug internal-go check-aa-profile lxc-container-default-cgns]
bind mounting /tmp/xx/workdir/.stacker/imports/build into container
total 8
-rw-r--r--    1 root     root          1406 Apr 18 17:03 favicon.ico
-rw-r--r--    1 root     root          3581 Apr 18 17:03 host-file
/imports/http-file: not a file
lxc build 20230418170313.176 ERROR    cgroup2_devices - ../src/lxc/cgroups/cgroup2_devices.c:bpf_program_load_kernel:332 - Operation not permitted - Failed to load bpf program: 
lxc build 20230418170313.177 ERROR    cgfsng - ../src/lxc/cgroups/cgfsng.c:__cgfsng_delegate_controllers:3341 - Resource busy - Could not enable "+memory +pids" controllers in the unified cgroup 9
lxc build 20230418170313.180 ERROR    cgfsng - ../src/lxc/cgroups/cgfsng.c:__cgfsng_delegate_controllers:3341 - Resource busy - Could not enable "+memory +pids" controllers in the unified cgroup 9
error: run commands failed: execute failed: exit status 1
stackerbuild.io/stacker/pkg/stacker.(*Builder).build
	/stacker-tree/pkg/stacker/build.go:471
stackerbuild.io/stacker/pkg/stacker.(*Builder).BuildMultiple
	/stacker-tree/pkg/stacker/build.go:568
main.doBuild
	/stacker-tree/cmd/stacker/build.go:117
github.com/urfave/cli.HandleAction
	/stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli@v1.22.12/app.go:524
github.com/urfave/cli.Command.Run
	/stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli@v1.22.12/command.go:175
github.com/urfave/cli.(*App).Run
	/stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli@v1.22.12/app.go:277
main.main
	/stacker-tree/cmd/stacker/main.go:324
runtime.main
	/usr/lib/go/src/runtime/proc.go:250
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:1598
error: exit status 1
stackerbuild.io/stacker/pkg/container.MaybeRunInNamespace
	/stacker-tree/pkg/container/userns.go:102
main.main.func3
	/stacker-tree/cmd/stacker/main.go:319
github.com/urfave/cli.(*App).Run
	/stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli@v1.22.12/app.go:264
main.main
	/stacker-tree/cmd/stacker/main.go:324
runtime.main
	/usr/lib/go/src/runtime/proc.go:250
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:1598

Expected behavior

No response

Screenshots

No response

Additional context

No response

 - path: https://www.cisco.com/favicon.ico
      dest: /imports/http-file
smoser commented
 - path: https://www.cisco.com/favicon.ico
   dest: /imports/http-file

thats what i had, right?

    - path: https://www.cisco.com/favicon.ico
      dest: /imports/http-file

I'm confused.