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

feat: add support for systemd socket activation #2186

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

Conversation

rgl
Copy link

@rgl rgl commented Jan 26, 2024

What type of PR is this?
feature

Which issue does this PR fix:

#2182

What does this PR do / Why do we need it:

WARNING I'm unsure about the go.mod version changes. Should they be done? If so, should CI be upgraded too?

It allows zot to use systemd socket activation.

This was implemented using the coreos/go-systemd library (see the httpserver example).

With this change, we configure systemd to use a privileged port like 80 or 443 with the zot.socket file. With this, we do not need to grant zot the CAP_NET_BIND_SERVICE capability. systemd will bind the socket and will pass it to zot as a file descriptor.

Testing done on this change:

This can be tested using:

systemd-socket-activate --listen=127.0.0.1:9999 ./bin/zot-linux-amd64 serve examples/config-minimal.json

The example systemd zot.service file was modified to depend on the zot.socket file too.

This can be installed using:

install examples/zot.service /etc/systemd/system/zot.service
install examples/zot.socket /etc/systemd/system/zot.socket
systemctl daemon-reload
systemctl enable zot.service zot.socket
systemctl restart zot.service zot.socket

Automation added to e2e:

Will this break upgrades or downgrades?

No.

Does this PR introduce any user-facing change?:

Yes and No. If you want to use this feature, the zot listening address will no longer be configured from the zot configuration file, instead it will be configured from the zot.socket file.

add support for systemd socket activation. please see the example zot.socket and zot.service files.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@andaaron andaaron left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

go.mod Outdated Show resolved Hide resolved
examples/zot.service Outdated Show resolved Hide resolved
@rgl rgl force-pushed the feature-add-systemd-socket-activation branch 2 times, most recently from a21de08 to 2c52ccb Compare January 26, 2024 20:08
pkg/api/controller.go Fixed Show fixed Hide fixed
pkg/api/controller.go Fixed Show fixed Hide fixed
@rchincha
Copy link
Contributor

rchincha commented Feb 5, 2024

@rgl sorry, could you rebase and push pls.

@rgl
Copy link
Author

rgl commented Feb 6, 2024

@rchincha I can only build this branch with go 1.21.6. as such, this is waiting for #2049 to land in the main branch; when that happens, I'll rebase on the main branch.

@rgl rgl force-pushed the feature-add-systemd-socket-activation branch 5 times, most recently from 995fae3 to 50dad18 Compare February 7, 2024 19:41
@rchincha
Copy link
Contributor

@rgl do you rebase and try again?

@rgl rgl force-pushed the feature-add-systemd-socket-activation branch from 50dad18 to 43ca3c7 Compare February 16, 2024 09:18
@rgl
Copy link
Author

rgl commented Feb 16, 2024

@rchincha sure. I've rebased it. please note that

@rchincha rchincha added this to the v2.1.0 milestone Mar 1, 2024
@rchincha
Copy link
Contributor

rchincha commented Mar 1, 2024

Let's target this PR for v2.1.0

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