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

Script error in S6_STAGE2_HOOK does not halt the container #603

Open
taka-oyama opened this issue Dec 16, 2024 · 8 comments
Open

Script error in S6_STAGE2_HOOK does not halt the container #603

taka-oyama opened this issue Dec 16, 2024 · 8 comments

Comments

@taka-oyama
Copy link

taka-oyama commented Dec 16, 2024

This is more of a question than an issue.

What do you think about adding a flag (like S6_BEHAVIOUR_IF_STAGE2_HOOK_FAILS) to halt the container instead of printing a warning here.

I ask because I was expecting it to stop and was surprised when it continued with a warning.

Btw, thanks you for creating s6-overlay. It's exactly what I needed and is so much better than supervisord.

@skarnet
Copy link
Contributor

skarnet commented Dec 16, 2024

Yeah that's legitimate. I don't want to add too many bells and whistles to S6_STAGE2_HOOK because it's not officially supported and people who use it should know what they're doing, but it is true that it makes more sense to halt the container when the hook exits nonzero. If that behaviour isn't wanted, people can always wrap their hook to make it exit zero instead, whereas with the current behaviour it isn't possible to stop the container.

I'll change the behaviour in the next version of s6-overlay.

@skarnet
Copy link
Contributor

skarnet commented Dec 16, 2024

If you can build s6-overlay yourself, can you please build the latest git head and tell me if it's working for you? The container should exit with a fatal error message if S6_BEHAVIOUR_IF_STAGE2_FAILS (the same variable as for services) is set to 2 and the hooks exits nonzero.

@taka-oyama
Copy link
Author

Hi, thanks for the changes! I will try running it later today.

@taka-oyama
Copy link
Author

taka-oyama commented Dec 18, 2024

I tried to build it but failed with the following error.

exec mkdir -p /project/s6-overlay/output/rootfs-overlay-aarch64-linux-musl
exec cp -a /project/s6-overlay/output/staging-aarch64-linux-musl/package /project/s6-overlay/output/staging-aarch64-linux-musl/command /project/s6-overlay/output/rootfs-overlay-aarch64-linux-musl/
exec rm -rf /project/s6-overlay/output/rootfs-overlay-aarch64-linux-musl/package/*/*/include /project/s6-overlay/output/rootfs-overlay-aarch64-linux-musl/package/*/*/library
exec rm -f /project/s6-overlay/output/s6-overlay-aarch64.tar.xz.tmp
cd /project/s6-overlay/output/rootfs-overlay-aarch64-linux-musl && tar -Jcvf /project/s6-overlay/output/s6-overlay-aarch64.tar.xz.tmp --owner=0 --group=0 --numeric-owner .
tar: unrecognized option: owner=0
BusyBox v1.36.1 (2024-06-10 07:11:47 UTC) multi-call binary.

Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [LONGOPT]... [FILE]...

Create, extract, or list files from a tar file

	c	Create
	x	Extract
	t	List
	-f FILE	Name of TARFILE ('-' for stdin/out)
	-C DIR	Change to DIR before operation
	-v	Verbose
	-O	Extract to stdout
	-m	Don't restore mtime
	-o	Don't restore user:group
	-k	Don't replace existing files
	-Z	(De)compress using compress
	-z	(De)compress using gzip
	-J	(De)compress using xz
	-j	(De)compress using bzip2
	--lzma	(De)compress using lzma
	-a	(De)compress based on extension
	-h	Follow symlinks
	-T FILE	File with names to include
	-X FILE	File with glob patterns to exclude
	--exclude PATTERN	Glob pattern to exclude
	--overwrite		Replace existing files
	--strip-components NUM	NUM of leading components to strip
	--no-recursion		Don't descend in directories
	--numeric-owner		Use numeric user:group
	--no-same-permissions	Don't restore access permissions
make: *** [Makefile:39: /project/s6-overlay/output/s6-overlay-aarch64.tar.xz] Error 1

It seems like the tar in one of the scripts is using an option not supported by BusyBox (Alpine linux 3.20)?
I'll try to build it again with Debian 12 tomorrow.

@skarnet
Copy link
Contributor

skarnet commented Dec 18, 2024

Right, you need GNU tar. You can install GNU tar on Alpine, though: the package is called tar.

@taka-oyama
Copy link
Author

Oh I did not know that, I will try that today. Thank you.

@taka-oyama
Copy link
Author

taka-oyama commented Dec 19, 2024

I tried it out and confirmed that the container stopped.

Here is the log.

/run/s6/basedir/scripts/rc.init: fatal: hook docker-entrypoint exited 1 # added "exit 1" at top of script 
s6-rc: fatal: unable to take locks: No such file or directory
s6-linux-init-shutdownd: warning: /run/s6/basedir/scripts/rc.shutdown exited 111
app-1 exited with code 1

@skarnet
Copy link
Contributor

skarnet commented Dec 19, 2024

Ah, so it's half-working - the container stops but the code path is wrong. Thanks, I will fix it.

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

2 participants