]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: downgrade warning if we can't get ID off cgroup
authorLennart Poettering <lennart@poettering.net>
Fri, 11 Feb 2022 12:18:58 +0000 (13:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 11 Feb 2022 12:36:39 +0000 (13:36 +0100)
The cgroupid feature was not available in old cgroupvs2 kernels, hence
try to get it but if we can't because it's not supported, then only
debug log about it and proceed.

(We only needs this for cgroup bpf stuff, but that isn't available on
such old kernels anyway)

Fixes: #22483
src/core/cgroup.c

index 316e8f571daef29527fca51aa033cc585664a6dc..f2044c2ffc075bb397923b4618c8f728b3f8eb8b 100644 (file)
@@ -2134,7 +2134,6 @@ static int unit_update_cgroup(
         bool created, is_root_slice;
         CGroupMask migrate_mask = 0;
         _cleanup_free_ char *cgroup_full_path = NULL;
-        uint64_t cgroup_id = 0;
         int r;
 
         assert(u);
@@ -2154,11 +2153,14 @@ static int unit_update_cgroup(
         created = r;
 
         if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) {
+                uint64_t cgroup_id = 0;
+
                 r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, NULL, &cgroup_full_path);
                 if (r == 0) {
                         r = cg_path_get_cgroupid(cgroup_full_path, &cgroup_id);
                         if (r < 0)
-                                log_unit_warning_errno(u, r, "Failed to get cgroup ID on cgroup %s, ignoring: %m", cgroup_full_path);
+                                log_unit_full_errno(u, ERRNO_IS_NOT_SUPPORTED(r) ? LOG_DEBUG : LOG_WARNING, r,
+                                                    "Failed to get cgroup ID of cgroup %s, ignoring: %m", cgroup_full_path);
                 } else
                         log_unit_warning_errno(u, r, "Failed to get full cgroup path on cgroup %s, ignoring: %m", empty_to_root(u->cgroup_path));
 
@@ -2169,7 +2171,6 @@ static int unit_update_cgroup(
         (void) unit_watch_cgroup(u);
         (void) unit_watch_cgroup_memory(u);
 
-
         /* For v2 we preserve enabled controllers in delegated units, adjust others,
          * for v1 we figure out which controller hierarchies need migration. */
         if (created || !u->cgroup_realized || !unit_cgroup_delegate(u)) {