Skip to content

systemd "unit already exists" error is not ignored during startUnit #2996

@kolyshkin

Description

@kolyshkin

This seems like a recent regression (in rc95 maybe).

Test case:

func TestUnitExistsIgnored(t *testing.T) {
       if !IsRunningSystemd() {
               t.Skip("Test requires systemd.")
       }
       if os.Geteuid() != 0 {
               t.Skip("Test requires root.")
       }

       podConfig := &configs.Cgroup{
               Parent: "system.slice",
               Name:   "system-runc_test_exists.slice",
       }
       pm := newManager(podConfig)
       defer pm.Destroy() //nolint:errcheck

       // create twice to make sure "UnitExists" error is ignored.
       for i := 0; i < 2; i++ {
               if err := pm.Apply(-1); err != nil {
                       t.Fatal(err)
               }
       }
}

fails on my system with:

[kir@kir-rhat systemd]$ sudo ./systemd.test -test.v -test.run Exis
=== RUN   TestUnitExistsIgnored
    systemd_test.go:192: error while starting unit "system-runc_test_exists.slice" with properties [{Name:Description Value:"libcontainer container system-runc_test_exists.slice"} {Name:Wants Value:["system.slice"]} {Name:MemoryAccounting Value:true} {Name:CPUAccounting Value:true} {Name:IOAccounting Value:true} {Name:TasksAccounting Value:true} {Name:DefaultDependencies Value:false}]: Unit system-runc_test_exists.slice already exists.
--- FAIL: TestUnitExistsIgnored (0.04s)
FAIL

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions