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

Fix systemd startup #1541

Merged
merged 3 commits into from
Aug 19, 2024
Merged

Fix systemd startup #1541

merged 3 commits into from
Aug 19, 2024

Conversation

jreidinger
Copy link
Contributor

Problem

Problem description is in issue #1539

Solution

Implement sd_notify for agama-web-service to notify systemd when web service is ready to serve requests.
Improve systemd dependencies to better reflect dependencies. For agama-auto adapt dependencies to reflect that CLI switch from direct systemd communication to HTTP API. related PR is #1438

Testing

  • Tested manually

Screenshots

snippet from log before change ( truncated, but to demonstrate that agama-auto runs too soon):

Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Started Agama Installer Service.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Started Agama Web Server.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Started Agama automatic profile runner.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Starting Postpone login prompt after the SSL fingerprint issue is generated...
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + export YAST_SKIP_XML_VALIDATION=1
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + YAST_SKIP_XML_VALIDATION=1
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + '[' -z '' ']'
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2691]: ++ awk -F agama.auto= '{sub(/ .*$/, "", $2); print $2}'
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + url=
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + '[' -z '' ']'
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + echo 'no autoinstallation profile'
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: no autoinstallation profile
Aug 14 13:10:47 dhcp118.suse.cz agama-auto[2689]: + exit 0
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: agama-auto.service: Deactivated successfully.
Aug 14 13:10:47 dhcp118.suse.cz sshd-gen-keys-start[2683]: ssh-keygen: generating new host keys: RSA ECDSA ED25519
Aug 14 13:10:47 dhcp118.suse.cz sshd[2702]: Server listening on 0.0.0.0 port 22.
Aug 14 13:10:47 dhcp118.suse.cz sshd[2702]: Server listening on :: port 22.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Started OpenSSH Daemon.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Starting Generate issue file for SSH host keys...
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: agama-ssh-issue.service: Deactivated successfully.
Aug 14 13:10:47 dhcp118.suse.cz systemd[1]: Finished Generate issue file for SSH host keys.
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: registering event source with poller: token=Token(94923250365696), interests=READABLE | WRITABLE
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: Initializing
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: Waiting for DATA or OK from server
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: Received OK from server
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: Waiting for Unix FD passing agreement from server
Aug 14 13:10:47 dhcp118.suse.cz agama-web-server[2688]: Unix FD passing agreed by server

and now after change:

Aug 15 10:19:15 dhcp118.suse.cz systemd[1]: Started Agama Web Server.
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Starting Agama web server at :::80
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Starting Agama web server at :::443
...
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Waiting for message on the socket..
...
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Listening for property changes on org.freedesktop.NetworkManager.Device...
Aug 15 10:19:15 dhcp118.suse.cz systemd[1]: Started Agama automatic profile runner.
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Message received on the socket: Msg { type: Signal, sender: UniqueName(Str(Borrowed(":1.2"))), path: ObjectPath("/org/freedesktop/systemd1/unit/agama_2dauto_2eservice"), iface: InterfaceName(Str(Borrowed("org.freedesktop.DBus.Properties"))), member: MemberName(Str(Borrowed("PropertiesChanged"))), body: Signature("sa{sv}as") }
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + export YAST_SKIP_XML_VALIDATION=1
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + YAST_SKIP_XML_VALIDATION=1
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + '[' -z '' ']'
...
Aug 15 10:19:15 dhcp118.suse.cz agama-web-server[12467]: Waiting for message on the socket..
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12482]: ++ awk -F agama.auto= '{sub(/ .*$/, "", $2); print $2}'
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + url=
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + '[' -z '' ']'
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + echo 'no autoinstallation profile'
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: no autoinstallation profile
Aug 15 10:19:15 dhcp118.suse.cz agama-auto[12479]: + exit 0
Aug 15 10:19:15 dhcp118.suse.cz systemd[1]: agama-auto.service: Deactivated successfully.

Copy link
Contributor

@mchf mchf left a comment

Choose a reason for hiding this comment

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

lgtm

@jreidinger jreidinger merged commit fc0f3a2 into master Aug 19, 2024
2 checks passed
@jreidinger jreidinger deleted the fix_systemd_startup branch August 19, 2024 07:03
@mvidner
Copy link
Contributor

mvidner commented Aug 19, 2024

Nice :)
A funny thing, this manual page contains also the implementation of the notification mechanism, in C and Python: https://www.man7.org/linux/man-pages/man3/sd_notify.3.html

@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
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.

3 participants