]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
units: do not fail if imds is not configured
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 26 May 2026 16:22:18 +0000 (18:22 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 May 2026 19:36:05 +0000 (04:36 +0900)
In https://bugzilla.redhat.com/show_bug.cgi?id=2481466, it is reported
that systemd-imds-early-network.service fails on AWS EC2 instance with:

> No IMDS endpoint information provided or detected, cannot operate.

The service will be started on various systems where it doesn't have
enough configuration to run. The systemd-imds-generator only does some
superficial checks, so the tool should not mark the boot as failed
it turns out that IMDS is not supported.

src/imds/imdsd.c
units/systemd-imds-early-network.service.in
units/systemd-imds-import.service.in

index 9c194c09005a035f6d69b1fc8cd9661187a49652..5ad1935721c2fef6006c77f21684cb204b1465fe 100644 (file)
@@ -24,6 +24,7 @@
 #include "errno-util.h"
 #include "escape.h"
 #include "event-util.h"
+#include "exit-status.h"
 #include "fd-util.h"
 #include "format-ifname.h"
 #include "format-table.h"
@@ -63,7 +64,7 @@
  * https://docs.hetzner.cloud/reference/cloud#description/server-metadata
  *
  * Some notes:
- *   - IMDS service are heavily rate limited, and hence we want to centralize requests in one place and cache
+ *   - IMDS service are heavily rate-limited, and hence we want to centralize requests in one place and cache
  *   - In order to isolate IMDS access this expects that traffic to the IMDS address 169.254.169.254 is
  *     generally prohibited (via a prohibit route), but our service uses fwmark 0x7FFF0815, which (via source
  *     routing) can bypass this route.
@@ -1851,7 +1852,9 @@ static int cmdline_run(void) {
 
         /* Process the request when invoked via the command line (i.e. not via Varlink) */
 
-        r = imds_configured(LOG_ERR);
+        r = imds_configured(LOG_INFO);
+        if (r == -EOPNOTSUPP)
+                return EXIT_NOTCONFIGURED;
         if (r < 0)
                 return r;
 
index b4241237f098386dc352a3d095d7c1b3852c63c0..23b35e6337bdb8c2339f7d4bf71a5c9d59976e8b 100644 (file)
@@ -21,3 +21,8 @@ After=sys-devices-virtual-dmi-id.device
 ExecStart={{LIBEXECDIR}}/systemd-imdsd --setup-network
 Type=oneshot
 RemainAfterExit=yes
+
+# The tool returns EXIT_NOTCONFIGURED if the configuration required for basic
+# operation is not found. Do not treat this as error, because the service can
+# be started on generic systems that do not have complete IMDS support.
+SuccessExitStatus=NOTCONFIGURED
index d27e59778f2c176f8f857bf5dcfea6f052c498d7..4a6c83ae7d40b51fc67fc63e6dbe92ea43e90ef7 100644 (file)
@@ -23,3 +23,8 @@ Before=shutdown.target
 Type=oneshot
 RemainAfterExit=yes
 ExecStart={{LIBEXECDIR}}/systemd-imds --import
+
+# The tool returns EXIT_NOTCONFIGURED if the configuration required for basic
+# operation is not found. Do not treat this as error, because the service can
+# be started on generic systems that do not have complete IMDS support.
+SuccessExitStatus=NOTCONFIGURED