Skip to content

Commit 4fd3033

Browse files
nixprimegvisor-bot
authored andcommitted
runsc/cgroup: don't no-op cgroupSystemd.Join() if unit exists
Note that although dbus.Conn.AttachProcessesToUnit() was added in v22.6.0 (2025: https://pkg.go.dev/github.com/coreos/go-systemd/v22/dbus?tab=versions), the underlying systemd call was added in v238 (2018: https://lists.freedesktop.org/archives/systemd-devel/2018-March/040469.html). PiperOrigin-RevId: 827238671
1 parent feddee9 commit 4fd3033

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/containerd/go-runc v1.0.0
1616
github.com/containerd/log v0.1.0
1717
github.com/containerd/typeurl v1.0.2
18-
github.com/coreos/go-systemd/v22 v22.5.0
18+
github.com/coreos/go-systemd/v22 v22.6.0
1919
github.com/godbus/dbus/v5 v5.1.0
2020
github.com/gofrs/flock v0.8.0
2121
github.com/gogo/protobuf v1.3.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+
234234
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
235235
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
236236
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
237+
github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo=
238+
github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU=
237239
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
238240
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
239241
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=

runsc/cgroup/systemd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ func (c *cgroupSystemd) Join() (func(), error) {
182182
return nil, fmt.Errorf("unknown job completion status %q", s)
183183
}
184184
} else if unitAlreadyExists(err) {
185+
if err := c.dbusConn.AttachProcessesToUnit(timedCtx, unitName, "" /* subcgroup */, []uint32{uint32(os.Getpid())}); err != nil {
186+
return nil, fmt.Errorf("error joining systemd unit `%s`: %w", unitName, err)
187+
}
185188
return clean.Release(), nil
186189
} else {
187190
return nil, fmt.Errorf("systemd error: %v", err)

0 commit comments

Comments
 (0)