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

Init command is never run unless --cachekey is used #38

Open
tux3 opened this issue Apr 8, 2024 · 0 comments
Open

Init command is never run unless --cachekey is used #38

tux3 opened this issue Apr 8, 2024 · 0 comments

Comments

@tux3
Copy link

tux3 commented Apr 8, 2024

Hello, in the osbase run function it looks like the init command is only ever used if self._cachekey is truthy, and if the cached image doesn't already exist.

I noticed this when I tried to use --init-command, and I couldn't see any effect:

$ debspawn run --init-command "sh -c 'echo init command without cachekey'" sid echo "regular command"
┌─────────────────────────────┐
│  Preparing container        │
└─────────────────────────────┘
Hit:1 http://deb.debian.org/debian sid InRelease
Hit:2 http://deb.debian.org/debian experimental InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

┌──────────────────────┐
│  Running Task        │
└──────────────────────┘
regular command

┌────────────────────────────────────┐
│  Retrieving build artifacts        │
└────────────────────────────────────┘
Copied 0 files.
Done

With a cachekey, the init command is run as expected:

$ debspawn run --init-command "sh -c 'pwd;id;echo init command'" --cachekey test_cachekey sid echo "regular command"
╔════════════════════════════════════════════════╗
║  Preparing template for `test_cachekey`        ║
╚════════════════════════════════════════════════╝

┌─────────────────────────────┐
│  Preparing container        │
└─────────────────────────────┘
Hit:1 http://deb.debian.org/debian sid InRelease
Hit:2 http://deb.debian.org/debian experimental InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
/srv
uid=0(root) gid=0(root) groups=0(root)
init command
Storing prepared image in cache
New compressed tarball size (for test_cachekey) is 610.0MiB
Using cached container image `test_cachekey`
usermod: no changes

┌─────────────────────────────┐
│  Preparing container        │
└─────────────────────────────┘
Hit:1 http://deb.debian.org/debian sid InRelease
Hit:2 http://deb.debian.org/debian experimental InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

┌──────────────────────┐
│  Running Task        │
└──────────────────────┘
regular command

┌────────────────────────────────────┐
│  Retrieving build artifacts        │
└────────────────────────────────────┘
Copied 0 files.
Done.

The doc says something about the init command being ignored if the cachekey already exists (which is correct!), but not about the init command being ignored if there is no cachekey, so I assume this may be a bug?

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

No branches or pull requests

1 participant