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

commands in cexec:v1.0.0 cannot resolve host, but image2disk:v1.0.0 can #92

Closed
nicolacdnll opened this issue Sep 28, 2022 · 4 comments · Fixed by #129
Closed

commands in cexec:v1.0.0 cannot resolve host, but image2disk:v1.0.0 can #92

nicolacdnll opened this issue Sep 28, 2022 · 4 comments · Fixed by #129

Comments

@nicolacdnll
Copy link

nicolacdnll commented Sep 28, 2022

Commands within cexec:v1.0.0 cannot resolve host, but image2disk:v1.0.0 can download files from the same host and path. The example below is with curl but the same happens with a yum install.

          version: "0.1"
          name: centos7
          global_timeout: 1800
          tasks:
            - name: os-installation
              worker: '{{.device_1}}'
              volumes:
                - "/dev:/dev"
                - "/dev/console:/dev/console"
                - "/lib/firmware:/lib/firmware:ro"
              actions:
                - name: "stream-os-image"
                  image: "image2disk:v1.0.0"
                  timeout: 600
                  environment:
                    DEST_DISK: /dev/sda
                    IMG_URL: https://foo.bar.com/filea.raw.gz
                    COMPRESSED: true
[... other actions ...]
                - name: "download-file"
                  image: cexec:v1.0.0
                  timeout: 90
                  environment:
                    BLOCK_DEVICE: /dev/sda4
                    FS_TYPE: xfs
                    CHROOT: y
                    DEFAULT_INTERPRETER: "/bin/sh -c"
                    CMD_LINE: "curl https://foo.bar.com/fileb.img -o /path/fileb.img"

Expected Behaviour

To be able to curl the file like in this example: https://docs.tinkerbell.org/deploying-operating-systems/examples-rhel-centos/ Am I doing something wrong?

Current Behaviour

curl: (6) Could not resolve host: foo.bar.com.
FATA[0011] Error running [/bin/bash [-c curl curl https://foo.bar.com/fileb.img -o /path/fileb.img]] [exit status 6]`

Your Environment

Linuxkit: https://github.com/linuxkit/linuxkit

@nicolacdnll nicolacdnll changed the title curl in cexec:v1.0.0 cannot resolve host, but image2disk:v1.0.0 can commands in cexec:v1.0.0 cannot resolve host, but image2disk:v1.0.0 can Sep 29, 2022
@Cajga
Copy link

Cajga commented Feb 12, 2024

@nicolacdnll, we run into the same. Have you managed to find a workaround?

@Cajga
Copy link

Cajga commented Feb 12, 2024

ok so basically an echo 'nameserver IPOFYOURDNSSERVER' > /etc/resolv.conf workarounds this problem...

@jacobweinstock
Copy link
Member

Wow, sincere apologies for the extremely delayed response here.

This is a symptom of chroot not handling networking/dns/etc and this action not taking those things into account. Let me see if i can figure out an OS agnostic way to get networking and DNS working. Maybe bind mounts or similar. Will try some things out and report back. Thanks for your patience !

@rpardini
Copy link

This indeed depends on the image being deployed. If it uses systemd-resolved, then /etc/resolv.conf will be a dangling symlink (to some /run/... file put there by systemd when the image is really booted into, but not under chroot-exec).
To make it work during provisioning, move /etc/resolv.conf (which is a dangling symlink) away, replace it with a real resolv.conf (nameserver …) one. Then bring the symlink back at the end of the workflow, so it works again when provisioning is finished...

@mergify mergify bot closed this as completed in #129 Apr 27, 2024
mergify bot added a commit that referenced this issue Apr 27, 2024
## Description


Cleaning up the code base for improved maintainability. Add option to use the host's /etc/resolv.conf in the chroot env. This resolves issues with DNS based network calls for things like package managers, etc.

## Why is this needed



Fixes: #92 

## How Has This Been Tested?





## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
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.

4 participants