diff options
author | ZheNing Hu <adlternative@gmail.com> | 2023-07-27 15:23:31 +0300 |
---|---|---|
committer | ZheNing Hu <adlternative@gmail.com> | 2023-07-28 06:26:38 +0300 |
commit | 97b5d2a2c8c8e667275a38ce10d6b51f3a7b2938 (patch) | |
tree | b8f429669e147e7e59c50e5323434c1560be10d5 | |
parent | e0e0cc45caff5305763f7e5afd6150e8a6f51407 (diff) |
cgroup: using a noop manager on linux without cgroup
Due to the lack of consideration for non-cgroup scenarios
on Linux systems, Gitaly exits with the error message
"unknown cgroup version", which hinders the usage for
these Linux users. Therefore, using noop implementation
of the cgroup manager for Linux systems without cgroup
is necessary to solve this issue.
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
-rw-r--r-- | internal/cgroups/cgroups.go | 4 | ||||
-rw-r--r-- | internal/cgroups/manager_linux.go | 4 | ||||
-rw-r--r-- | internal/cgroups/v1_linux_test.go | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/internal/cgroups/cgroups.go b/internal/cgroups/cgroups.go index 0c6927502..e4f7e840b 100644 --- a/internal/cgroups/cgroups.go +++ b/internal/cgroups/cgroups.go @@ -42,7 +42,9 @@ type Manager interface { // NewManager returns the appropriate Cgroups manager func NewManager(cfg cgroups.Config, pid int) Manager { if cfg.Repositories.Count > 0 { - return newCgroupManager(cfg, pid) + if manager := newCgroupManager(cfg, pid); manager != nil { + return manager + } } return &NoopManager{} diff --git a/internal/cgroups/manager_linux.go b/internal/cgroups/manager_linux.go index 7b8c4a34d..f9215d342 100644 --- a/internal/cgroups/manager_linux.go +++ b/internal/cgroups/manager_linux.go @@ -49,7 +49,8 @@ func newCgroupManagerWithMode(cfg cgroupscfg.Config, pid int, mode cgrps.CGMode) handler = newV2Handler(cfg, pid) log.Warnf("Gitaly now includes experimental support for CgroupV2. Please proceed with caution and use this experimental feature at your own risk") default: - log.Fatalf("unknown cgroup version") + log.Warnf("Gitaly has encountered an issue while trying to detect the version of the system's cgroup. As a result, all subsequent commands will be executed without cgroup support. Please check the system's cgroup configuration and try again") + return nil } return &CGroupManager{ @@ -172,6 +173,5 @@ func pruneOldCgroupsWithMode(cfg cgroupscfg.Config, logger log.FieldLogger, mode case cgrps.Unified: pruneOldCgroupsV2(cfg, logger) default: - log.Fatalf("unknown cgroup version") } } diff --git a/internal/cgroups/v1_linux_test.go b/internal/cgroups/v1_linux_test.go index a68ebed4d..7503ff8bf 100644 --- a/internal/cgroups/v1_linux_test.go +++ b/internal/cgroups/v1_linux_test.go @@ -42,6 +42,8 @@ func TestNewManagerV1(t *testing.T) { require.IsType(t, &cgroupV1Handler{}, manager.handler) manager = newCgroupManagerWithMode(cfg, 1, cgrps.Hybrid) require.IsType(t, &cgroupV1Handler{}, manager.handler) + manager = newCgroupManagerWithMode(cfg, 1, cgrps.Unavailable) + require.Nil(t, manager) } func TestSetup_ParentCgroups(t *testing.T) { |