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

daemon: listeners: make systemd listener optional #42430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

metux
Copy link
Contributor

@metux metux commented May 27, 2021

On non systemd systems, the systemd-based activation is not needed at all,
thus make it build-time optional. It won't be built in if the 'nosystemd'
tag is set.

Signed-off-by: Enrico Weigelt, metux IT consult info@metux.net

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the problem you're trying to resolve, other than "I don't want to use systemd", as (if I'm not mistaken) this code will only be called when running as a systemd service, using the fd:// for the socket;

case "fd":
fds, err := listenFD(addr, tlsConfig)
if err != nil {
return nil, err
}
ls = append(ls, fds...)

@metux
Copy link
Contributor Author

metux commented May 27, 2021

Could you describe the problem you're trying to resolve, other than "I don't want to use systemd", as (if I'm not mistaken) this code will only be called when running as a systemd service, using the fd:// for the socket;

case "fd":
fds, err := listenFD(addr, tlsConfig)
if err != nil {
return nil, err
}
ls = append(ls, fds...)

reduce unnecessary code, eg. for small systems, easier audits, ...

@metux metux force-pushed the submit/optional-systemd-listener branch from a359008 to 95aa6f5 Compare May 27, 2021 17:03
@AkihiroSuda
Copy link
Member

reduce unnecessary code, eg. for small systems, easier audits, ...

How many bytes are reduced?

@metux metux force-pushed the submit/optional-systemd-listener branch 3 times, most recently from 3c5cd64 to 82fdca2 Compare June 16, 2021 14:04
@metux metux force-pushed the submit/optional-systemd-listener branch from 82fdca2 to 9e21902 Compare August 24, 2023 11:52
@thaJeztah
Copy link
Member

How many bytes are reduced?

Was curious as well; did a quick try with this PR:

hack/make.sh binary

ls -l --block-size=1 ./bundles/binary-daemon/
total 204955648
-rwxr-xr-x 1 root root 37224448 Aug 24 12:13 containerd
-rwxr-xr-x 1 root root 11862016 Aug 24 12:13 containerd-shim-runc-v2
-rwxr-xr-x 1 root root 18219008 Aug 24 12:13 ctr
-rwxr-xr-x 1 root root   535800 Aug 24 12:13 docker-init
-rwxr-xr-x 1 root root  2046594 Aug 24 12:13 docker-proxy
-rwxr-xr-x 1 root root 63013608 Aug 24 12:13 dockerd
-rwxr-xr-x 1 root root    14185 Aug 24 12:13 dockerd-rootless-setuptool.sh
-rwxr-xr-x 1 root root     5190 Aug 24 12:13 dockerd-rootless.sh
-rwxr-xr-x 1 root root 11002021 Aug 24 12:13 rootlesskit
-rwxr-xr-x 1 root root  7055888 Aug 24 12:13 rootlesskit-docker-proxy
-rwxr-xr-x 1 root root 14348976 Aug 24 12:13 runc
-rwxr-xr-x 1 root root 39607984 Aug 24 12:13 vpnkit


hack/make.sh dynbinary
ls -l --block-size=1 ./bundles/dynbinary-daemon/
total 71487488
-rwxr-xr-x 1 root root  2246690 Aug 24 12:12 docker-proxy
-rwxr-xr-x 1 root root 69234944 Aug 24 12:12 dockerd
DOCKER_BUILDTAGS=no_systemd hack/make.sh binary

ls -l --block-size=1 ./bundles/binary-daemon/
total 204935168
-rwxr-xr-x 1 root root 37224448 Aug 24 12:14 containerd
-rwxr-xr-x 1 root root 11862016 Aug 24 12:14 containerd-shim-runc-v2
-rwxr-xr-x 1 root root 18219008 Aug 24 12:14 ctr
-rwxr-xr-x 1 root root   535800 Aug 24 12:14 docker-init
-rwxr-xr-x 1 root root  2046594 Aug 24 12:14 docker-proxy
-rwxr-xr-x 1 root root 62995856 Aug 24 12:14 dockerd
-rwxr-xr-x 1 root root    14185 Aug 24 12:14 dockerd-rootless-setuptool.sh
-rwxr-xr-x 1 root root     5190 Aug 24 12:14 dockerd-rootless.sh
-rwxr-xr-x 1 root root 11002021 Aug 24 12:14 rootlesskit
-rwxr-xr-x 1 root root  7055888 Aug 24 12:14 rootlesskit-docker-proxy
-rwxr-xr-x 1 root root 14348976 Aug 24 12:14 runc
-rwxr-xr-x 1 root root 39607984 Aug 24 12:14 vpnkit



DOCKER_BUILDTAGS=no_systemd hack/make.sh dynbinary
ls -l --block-size=1 ./bundles/dynbinary-daemon/
total 71471104
-rwxr-xr-x 1 root root  2246690 Aug 24 12:08 docker-proxy
-rwxr-xr-x 1 root root 69221448 Aug 24 12:08 dockerd

Looks like it's saving 20k max (on a ~60Mib binary);

  • binary (static): 204955648-204935168=20480 (20kib)
  • dynbinary: 71471104-71487488=16384 (16kib)

@metux metux force-pushed the submit/optional-systemd-listener branch 2 times, most recently from e3a9a5b to 2cf0b25 Compare August 25, 2023 11:35
On non systemd systems, the systemd-based activation is not needed at all,
thus make it build-time optional. It won't be built in if the 'no_systemd'
tag is set.

changes v2: renamed 'nosystemd' tag to 'no_systemd'
changes v3: fixed some obsolete imports
            use new style tags

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
@metux metux force-pushed the submit/optional-systemd-listener branch from 2cf0b25 to dd37233 Compare August 25, 2023 12:40
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 this pull request may close these issues.

None yet

3 participants