warewulf icon indicating copy to clipboard operation
warewulf copied to clipboard

rfe: import local containers from a relative path

Open anderbubble opened this issue 3 years ago • 3 comments

Importing a local container from a .tar appears to only work when a full path is specified.

# wwctl container import fuzzball-substrate-compute.tar fuzzball-substrate-compute
ERROR  : Could not import image: error opening file "/fuzzball-substrate-compute.tar": open /fuzzball-substrate-compute.tar: no such file or directory

Even this didn't work.

# wwctl container import ./fuzzball-substrate-compute.tar fuzzball-substrate-compute2
ERROR  : Could not import image: error opening file "/./fuzzball-substrate-compute.tar": open /./fuzzball-substrate-compute.tar: no such file or directory

I was able to get around it with readlink.

# wwctl container import $(readlink -f fuzzball-substrate-compute.tar) fuzzball-substrate-compute2

But this seems unnecessarily baroque, and import should be able to receive a relative path to the file to import.

anderbubble avatar Jul 10 '22 01:07 anderbubble

The official syntax is to use file://pathToTarBall so with this syntax a relative path is not sensible. That it's possible to use this without file prefix is a kind bug.

mslacken avatar Jul 14 '22 18:07 mslacken

Syntax without a prefix is explicitly documented.

$ wwctl container import -h

This command will pull and import a container into Warewulf from SOURCE,
optionally renaming it to NAME. The SOURCE must be in a supported URI format. Formats 
are:
 * docker://registry.example.org/example:latest
 * docker-daemon://example:latest
 * file://path/to/archive/tar/ball
 * /path/to/archive/tar/ball
 * /path/to/chroot/
 [...]
$ man wwctl-container-import

NAME
       wwctl-container-import - Import a container into Warewulf

SYNOPSIS
       wwctl container import [OPTIONS] SOURCE [NAME]

DESCRIPTION
       This command will pull and import a container into Warewulf from SOURCE, optionally renaming it to NAME. The SOURCE must be in a supported URI format. Formats are:
        * docker://registry.example.org/example:latest
        * docker-daemon://example:latest
        * file://path/to/archive/tar/ball
        * /path/to/archive/tar/ball
        * /path/to/chroot/ Imported containers are used to create bootable VNFS images.
[...]

Also at https://warewulf.org/docs/enchiridion/containers

sudo wwctl container import /tmp/newroot containername

anderbubble avatar Jul 14 '22 19:07 anderbubble

I remember that I didn't want to write "/absolute/path/to/archive/tar/ball" So the problem here is that the underlying API wants the absolute paths, so as there might be a proper reason for this constraint, and I did not have the time for a proper investigation.

mslacken avatar Jul 15 '22 10:07 mslacken

Even if the API wants an absolute path, the CLI could resolve the absolute path automatically.

I'm going to look into this.

anderbubble avatar Jan 24 '23 17:01 anderbubble