tinkerbell / actions

Suite of Tinkerbell Actions for use in Tinkerbell Workflows
Apache License 2.0
28 stars 43 forks source link

cexec produces an exec format error when trying to execute a command using /usr/bin/sh #71

Closed alienninja closed 3 years ago

alienninja commented 3 years ago

Using the Tinkerbell documentation as an example (links below), I am unable to use the cexec action for any commands as it returns an exec format error. In googling, this is related to not having "#!/bin/sh" at the top of a script, but I am not calling from a script, so I a not sure if this is indirectly how to fix this, or if I am using cexec incorrectly.

Expected Behaviour

I expect cexec to run the commands as expected with the default interpreter.

Current Behaviour

Cexec errors out and the workflow fails to continue executing

Possible Solution

Steps to Reproduce (for bugs)

  1. Set up a docker-compose instance of Tinkerbell
  2. Create a hardware json as outlined on https://docs.tinkerbell.org/hardware-data/
  3. Create a template yaml as outlined on the bottom of https://docs.tinkerbell.org/deploying-operating-systems/examples-ubuntu/
  4. Run a pxeboot on the machine to be provisioned, review the tink-worker logs to show that cexec failed with an exec format error

Context

This is preventing me from using cexec.

Your Environment

#notes: using a locally modified version of rootio which can process the metadata correctly as a Tinkerbell hardware json file.
version: "0.1"
name: ubuntu_provisioning
global_timeout: 1800
tasks:
  - name: "os-installation"
    worker: "{{.device_1}}"
    volumes:
      - /dev:/dev
      - /dev/console:/dev/console
      - /lib/firmware:/lib/firmware:ro
    actions:
      - name: "disk-wipe-partition"
        image: thebsdbox/rootio:1.0
        timeout: 90
        command: ["partition"]
        environment:
            MIRROR_HOST: [redacted]
      - name: "format"
        image: thebsdbox/rootio:1.0
        timeout: 90
        command: ["format"]
        environment:
            MIRROR_HOST: [redacted]
      - name: "expand-ubuntu-filesystem-to-root"
        image: quay.io/tinkerbell-actions/archive2disk:v1.0.0
        timeout: 90
        environment:
            ARCHIVE_URL: http://[redacted]:8080/ubuntu_rootfs.tar.gz
            ARCHIVE_TYPE: targz
            DEST_DISK: /dev/sda3
            FS_TYPE: ext4
            DEST_PATH: /
      - name: "apt-update"
        image: quay.io/tinkerbell-actions/cexec:v1.0.0
        timeout: 90
        environment:
            BLOCK_DEVICE: /dev/sda3
            FS_TYPE: ext4
            DEFAULT_INTERPRETER: "/usr/bin/sh -c"
            CHROOT: y
            CMD_LINE: "apt-get -y update"
exec_format_error
alienninja commented 3 years ago

This may be an issue in archive2disk, symbolic links look like they are not preserved. When I manually mounted sda3 and extracted ubuntu_rootfs.tar.gz, and re-ran my cexec container, my command worked.

alienninja commented 3 years ago

The issue appears to be archive2disk not processing symbolic links correctly, so closing this issue and creating one for archive2disk