diff --git a/autoinstallation/package/agama-auto.changes b/autoinstallation/package/agama-auto.changes index de41a1f1b0..1d2abbe8c4 100644 --- a/autoinstallation/package/agama-auto.changes +++ b/autoinstallation/package/agama-auto.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Aug 15 08:35:31 UTC 2024 - Josef Reidinger + +- change agama-auto systemd service depedencies to reflect changes + in agama CLI communication and ensure that it runs when + agama-auto runs + (gh#openSUSE/agama#1539) + ------------------------------------------------------------------- Wed Jul 3 15:24:48 UTC 2024 - Imobach Gonzalez Sosa diff --git a/autoinstallation/systemd/agama-auto.service b/autoinstallation/systemd/agama-auto.service index 3d703f6fa1..1eb79d726f 100644 --- a/autoinstallation/systemd/agama-auto.service +++ b/autoinstallation/systemd/agama-auto.service @@ -1,11 +1,9 @@ [Unit] Description=Agama automatic profile runner -# it needs to D-Bus, so it has access to Agama D-Bus interface -After=dbus.socket -# it needs to NetworkManager, so it has access to it -After=NetworkManager.service -# it needs agama, of course +# it needs agama web service as it calls CLI which uses its API +# other dependencies are transitive After=agama-web-server.service +BindsTo=agama-web-server.service [Service] ExecStart=/usr/bin/agama-auto diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 6a36a10ada..9b1ec100a3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -115,6 +115,7 @@ dependencies = [ "pin-project", "rand", "regex", + "sd-notify", "serde", "serde_json", "serde_with", @@ -3433,6 +3434,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sd-notify" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4646d6f919800cd25c50edb49438a1381e2cd4833c027e75e8897981c50b8b5e" + [[package]] name = "security-framework" version = "2.11.1" diff --git a/rust/agama-server/Cargo.toml b/rust/agama-server/Cargo.toml index 52386a3005..9b81d804ad 100644 --- a/rust/agama-server/Cargo.toml +++ b/rust/agama-server/Cargo.toml @@ -48,6 +48,7 @@ pam = "0.8.0" serde_with = "3.6.1" pin-project = "1.1.5" openssl = "0.10.64" +sd-notify = "0.4.2" hyper = "1.2.0" hyper-util = "0.1.3" tokio-openssl = "0.6.4" diff --git a/rust/agama-server/src/agama-web-server.rs b/rust/agama-server/src/agama-web-server.rs index 607a3dd572..714ae9d0a4 100644 --- a/rust/agama-server/src/agama-web-server.rs +++ b/rust/agama-server/src/agama-web-server.rs @@ -348,6 +348,12 @@ async fn serve_command(args: ServeArgs) -> anyhow::Result<()> { }) .collect(); + // notify systemd that web server start serving + if let Ok(true) = sd_notify::booted() { + sd_notify::notify(true, &[sd_notify::NotifyState::Ready]) + .context("Failed to notify systemd")?; + } + futures_util::future::join_all(servers).await; Ok(()) diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 6d4419301a..cbabd66d85 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Aug 15 08:33:02 UTC 2024 - Josef Reidinger + +- Use sd_notify for starting agama-web-service to notify systemd + when service is ready. It helps with race condition in agama-auto + (gh#openSUSE/agama#1539) +- improve systemd dependencies of agama-web-service to ensure that + agama service runs + ------------------------------------------------------------------- Fri Aug 9 08:50:31 UTC 2024 - Martin Vidner diff --git a/rust/share/agama-web-server.service b/rust/share/agama-web-server.service index 3c41fa2fea..9b987938eb 100644 --- a/rust/share/agama-web-server.service +++ b/rust/share/agama-web-server.service @@ -3,10 +3,10 @@ Description=Agama Web Server # agama-hostname might change the host name which is used when creating # a self signed certificate, run it before the web server After=network-online.target agama.service agama-hostname.service -PartOf=agama.service +BindsTo=agama.service [Service] -Type=simple +Type=notify ExecStart=/usr/bin/agama-web-server serve --address :::80 --address2 :::443 PIDFile=/run/agama/web.pid User=root