Skip to content

Commit f8918cf

Browse files
committed
go.mod: coreos/go-systemd/v22 v22.3.2 to prepare for deprecations
I noticed that some containerd dependencies updated to the latest version of github.com/coreos/go-systemd/v22, which has deprecated various functions. Updating the version here as well to prevent using functions that have been deprecated. v22.3.2 also contains a fix for leaked sockets after successful probe. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ff350a8 commit f8918cf

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.13
44

55
require (
66
github.com/cilium/ebpf v0.4.0
7-
github.com/coreos/go-systemd/v22 v22.1.0
7+
github.com/coreos/go-systemd/v22 v22.3.2
88
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
99
github.com/docker/go-units v0.4.0
10-
github.com/godbus/dbus/v5 v5.0.3
10+
github.com/godbus/dbus/v5 v5.0.4
1111
github.com/gogo/protobuf v1.3.2
1212
github.com/opencontainers/runtime-spec v1.0.2
1313
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
22
github.com/cilium/ebpf v0.4.0 h1:QlHdikaxALkqWasW8hAC1mfR0jdmvbfaBdBPFmRSglA=
33
github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
4-
github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg=
5-
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
4+
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
5+
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
66
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
77
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
88
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@@ -13,8 +13,8 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
1313
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
1414
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
1515
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
16-
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
17-
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
16+
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
17+
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
1818
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
1919
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
2020
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=

systemd.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package cgroups
1818

1919
import (
20+
"context"
2021
"path/filepath"
2122
"strings"
2223
"sync"
@@ -78,7 +79,8 @@ func (s *SystemdController) Name() Name {
7879
}
7980

8081
func (s *SystemdController) Create(path string, _ *specs.LinuxResources) error {
81-
conn, err := systemdDbus.New()
82+
ctx := context.TODO()
83+
conn, err := systemdDbus.NewWithContext(ctx)
8284
if err != nil {
8385
return err
8486
}
@@ -90,7 +92,7 @@ func (s *SystemdController) Create(path string, _ *specs.LinuxResources) error {
9092
checkDelegate := func() {
9193
canDelegate = true
9294
dlSlice := newProperty("Delegate", true)
93-
if _, err := conn.StartTransientUnit(slice, "testdelegate", []systemdDbus.Property{dlSlice}, nil); err != nil {
95+
if _, err := conn.StartTransientUnitContext(ctx, slice, "testdelegate", []systemdDbus.Property{dlSlice}, nil); err != nil {
9496
if dbusError, ok := err.(dbus.Error); ok {
9597
// Starting with systemd v237, Delegate is not even a property of slices anymore,
9698
// so the D-Bus call fails with "InvalidArgs" error.
@@ -100,7 +102,7 @@ func (s *SystemdController) Create(path string, _ *specs.LinuxResources) error {
100102
}
101103
}
102104

103-
conn.StopUnit(slice, "testDelegate", nil)
105+
_, _ = conn.StopUnitContext(ctx, slice, "testDelegate", nil)
104106
}
105107
once.Do(checkDelegate)
106108
properties := []systemdDbus.Property{
@@ -118,7 +120,7 @@ func (s *SystemdController) Create(path string, _ *specs.LinuxResources) error {
118120
}
119121

120122
ch := make(chan string)
121-
_, err = conn.StartTransientUnit(name, "replace", properties, ch)
123+
_, err = conn.StartTransientUnitContext(ctx, name, "replace", properties, ch)
122124
if err != nil {
123125
return err
124126
}
@@ -127,14 +129,15 @@ func (s *SystemdController) Create(path string, _ *specs.LinuxResources) error {
127129
}
128130

129131
func (s *SystemdController) Delete(path string) error {
130-
conn, err := systemdDbus.New()
132+
ctx := context.TODO()
133+
conn, err := systemdDbus.NewWithContext(ctx)
131134
if err != nil {
132135
return err
133136
}
134137
defer conn.Close()
135138
_, name := splitName(path)
136139
ch := make(chan string)
137-
_, err = conn.StopUnit(name, "replace", ch)
140+
_, err = conn.StopUnitContext(ctx, name, "replace", ch)
138141
if err != nil {
139142
return err
140143
}

v2/manager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v2
1818

1919
import (
2020
"bufio"
21+
"context"
2122
"io/ioutil"
2223
"math"
2324
"os"
@@ -662,8 +663,9 @@ func NewSystemd(slice, group string, pid int, resources *Resources) (*Manager, e
662663
if slice == "" {
663664
slice = defaultSlice
664665
}
666+
ctx := context.TODO()
665667
path := filepath.Join(defaultCgroup2Path, slice, group)
666-
conn, err := systemdDbus.New()
668+
conn, err := systemdDbus.NewWithContext(ctx)
667669
if err != nil {
668670
return &Manager{}, err
669671
}
@@ -733,7 +735,7 @@ func NewSystemd(slice, group string, pid int, resources *Resources) (*Manager, e
733735
}
734736

735737
statusChan := make(chan string, 1)
736-
if _, err := conn.StartTransientUnit(group, "replace", properties, statusChan); err == nil {
738+
if _, err := conn.StartTransientUnitContext(ctx, group, "replace", properties, statusChan); err == nil {
737739
select {
738740
case <-statusChan:
739741
case <-time.After(time.Second):
@@ -759,14 +761,15 @@ func LoadSystemd(slice, group string) (*Manager, error) {
759761
}
760762

761763
func (c *Manager) DeleteSystemd() error {
762-
conn, err := systemdDbus.New()
764+
ctx := context.TODO()
765+
conn, err := systemdDbus.NewWithContext(ctx)
763766
if err != nil {
764767
return err
765768
}
766769
defer conn.Close()
767770
group := systemdUnitFromPath(c.path)
768771
ch := make(chan string)
769-
_, err = conn.StopUnit(group, "replace", ch)
772+
_, err = conn.StopUnitContext(ctx, group, "replace", ch)
770773
if err != nil {
771774
return err
772775
}

0 commit comments

Comments
 (0)