Commit c2b978e0 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Bump containerd to v1.4.9-k3s1

parent e9bdb995
...@@ -9,7 +9,7 @@ replace ( ...@@ -9,7 +9,7 @@ replace (
github.com/containerd/btrfs => github.com/containerd/btrfs v1.0.0 github.com/containerd/btrfs => github.com/containerd/btrfs v1.0.0
github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.1 github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.1
github.com/containerd/console => github.com/containerd/console v1.0.2 github.com/containerd/console => github.com/containerd/console v1.0.2
github.com/containerd/containerd => github.com/k3s-io/containerd v1.4.8-k3s1 // k3s-release/1.4 github.com/containerd/containerd => github.com/k3s-io/containerd v1.4.9-k3s1 // k3s-release/1.4
github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1 github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1
github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7 // k3s-release/1.4 github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7 // k3s-release/1.4
github.com/containerd/fifo => github.com/containerd/fifo v1.0.0 github.com/containerd/fifo => github.com/containerd/fifo v1.0.0
...@@ -93,7 +93,7 @@ require ( ...@@ -93,7 +93,7 @@ require (
github.com/minio/minio-go/v7 v7.0.7 github.com/minio/minio-go/v7 v7.0.7
github.com/natefinch/lumberjack v2.0.0+incompatible github.com/natefinch/lumberjack v2.0.0+incompatible
// LOOK TO scripts/download FOR THE VERSION OF runc THAT WE ARE BUILDING/SHIPPING // LOOK TO scripts/download FOR THE VERSION OF runc THAT WE ARE BUILDING/SHIPPING
github.com/opencontainers/runc v1.0.0-rc93 github.com/opencontainers/runc v1.0.0-rc94
github.com/opencontainers/selinux v1.8.0 github.com/opencontainers/selinux v1.8.0
github.com/pierrec/lz4 v2.5.2+incompatible github.com/pierrec/lz4 v2.5.2+incompatible
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
...@@ -111,7 +111,7 @@ require ( ...@@ -111,7 +111,7 @@ require (
go.etcd.io/etcd v0.5.0-alpha.5.0.20200819165624-17cef6e3e9d5 go.etcd.io/etcd v0.5.0-alpha.5.0.20200819165624-17cef6e3e9d5
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 golang.org/x/sys v0.0.0-20210426230700-d19ff857e887
google.golang.org/grpc v1.33.2 google.golang.org/grpc v1.33.2
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.19.13 k8s.io/api v0.19.13
......
...@@ -173,8 +173,9 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf ...@@ -173,8 +173,9 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg=
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/coreos/go-systemd/v22 v22.3.1 h1:7OO2CXWMYNDdaAzP51t4lCCZWwpQHmvPbm9sxWjm3So=
github.com/coreos/go-systemd/v22 v22.3.1/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
...@@ -326,8 +327,9 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= ...@@ -326,8 +327,9 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c h1:RBUpb2b14UnmRHNd2uHz20ZHLDK+SW5Us/vWF5IHRaY= github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c h1:RBUpb2b14UnmRHNd2uHz20ZHLDK+SW5Us/vWF5IHRaY=
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc= github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gogo/googleapis v1.4.0 h1:zgVt4UpGxcqVOw97aRGxT4svlcmdK35fynLNctY32zI= github.com/gogo/googleapis v1.4.0 h1:zgVt4UpGxcqVOw97aRGxT4svlcmdK35fynLNctY32zI=
...@@ -460,8 +462,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 ...@@ -460,8 +462,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/k3s-io/containerd v1.4.8-k3s1 h1:p4Z22iGEy7EaOCDChlgojqm6Jnziv19EuqnnLnK4tpk= github.com/k3s-io/containerd v1.4.9-k3s1 h1:gV6EDgGcp4sxeZ+5dOaul+K+Z6nSx3rfzmC28DIDSSo=
github.com/k3s-io/containerd v1.4.8-k3s1/go.mod h1:FxLYZ8JAZ2kqHz/1mpWp1wkcquVwfNbDlUKjrT1B0iI= github.com/k3s-io/containerd v1.4.9-k3s1/go.mod h1:O7TXIlGKEOd9pX4UfoQW7kzPLmpjWSRRE1V0qZ+XZFw=
github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1 h1:KEz2rd9IDbrQT8w6RibEYlwfTXiu0P6hQDE+6O4IJdI= github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1 h1:KEz2rd9IDbrQT8w6RibEYlwfTXiu0P6hQDE+6O4IJdI=
github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
github.com/k3s-io/cri v1.4.0-k3s.7 h1:1ycdF3dMDJMW/k/UxDC6eMsyGSMZ/p0AoUBVdJvNGQs= github.com/k3s-io/cri v1.4.0-k3s.7 h1:1ycdF3dMDJMW/k/UxDC6eMsyGSMZ/p0AoUBVdJvNGQs=
......
...@@ -3,9 +3,12 @@ module github.com/containerd/containerd ...@@ -3,9 +3,12 @@ module github.com/containerd/containerd
go 1.14 go 1.14
replace ( replace (
github.com/Microsoft/go-winio => github.com/Microsoft/go-winio v0.4.19
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.16
github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1 github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1
github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7 // k3s-release/1.4 github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7 // k3s-release/1.4
github.com/golang/protobuf => github.com/golang/protobuf v1.3.5 github.com/golang/protobuf => github.com/golang/protobuf v1.3.5
github.com/opencontainers/runc => github.com/opencontainers/runc v1.0.0-rc94
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63 google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63
k8s.io/api => k8s.io/api v0.19.10 k8s.io/api => k8s.io/api v0.19.10
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.10 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.10
...@@ -32,12 +35,13 @@ replace ( ...@@ -32,12 +35,13 @@ replace (
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.19.10 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.19.10
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.19.10 k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.19.10
k8s.io/sample-controller => k8s.io/sample-controller v0.19.10 k8s.io/sample-controller => k8s.io/sample-controller v0.19.10
) )
require ( require (
github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml v0.3.1
github.com/Microsoft/go-winio v0.4.19 github.com/Microsoft/go-winio v0.4.19
github.com/Microsoft/hcsshim v0.8.20 github.com/Microsoft/hcsshim v0.8.16
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3 github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3
github.com/containerd/aufs v1.0.0 github.com/containerd/aufs v1.0.0
github.com/containerd/btrfs v1.0.0 github.com/containerd/btrfs v1.0.0
...@@ -50,7 +54,7 @@ require ( ...@@ -50,7 +54,7 @@ require (
github.com/containerd/ttrpc v1.0.2 github.com/containerd/ttrpc v1.0.2
github.com/containerd/typeurl v1.0.2 github.com/containerd/typeurl v1.0.2
github.com/containerd/zfs v1.0.0 github.com/containerd/zfs v1.0.0
github.com/coreos/go-systemd/v22 v22.1.0 github.com/coreos/go-systemd/v22 v22.3.1
github.com/docker/docker v17.12.0-ce-rc1.0.20200310163718-4634ce647cf2+incompatible // indirect github.com/docker/docker v17.12.0-ce-rc1.0.20200310163718-4634ce647cf2+incompatible // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c
github.com/docker/go-metrics v0.0.1 github.com/docker/go-metrics v0.0.1
...@@ -64,8 +68,8 @@ require ( ...@@ -64,8 +68,8 @@ require (
github.com/imdario/mergo v0.3.11 github.com/imdario/mergo v0.3.11
github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/image-spec v1.0.1
github.com/opencontainers/runc v1.0.0-rc93 github.com/opencontainers/runc v1.0.0-rc94
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/selinux v1.8.0 github.com/opencontainers/selinux v1.8.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.7.1 github.com/prometheus/client_golang v1.7.1
...@@ -75,7 +79,7 @@ require ( ...@@ -75,7 +79,7 @@ require (
go.etcd.io/bbolt v1.3.5 go.etcd.io/bbolt v1.3.5
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 golang.org/x/sys v0.0.0-20210426230700-d19ff857e887
google.golang.org/grpc v1.33.2 google.golang.org/grpc v1.33.2
gotest.tools/v3 v3.0.3 gotest.tools/v3 v3.0.3
) )
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/version"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
...@@ -356,6 +357,9 @@ func (ah *authHandler) fetchTokenWithOAuth(ctx context.Context, to tokenOptions) ...@@ -356,6 +357,9 @@ func (ah *authHandler) fetchTokenWithOAuth(ctx context.Context, to tokenOptions)
req.Header[k] = append(req.Header[k], v...) req.Header[k] = append(req.Header[k], v...)
} }
} }
if len(req.Header.Get("User-Agent")) == 0 {
req.Header.Set("User-Agent", "containerd/"+version.Version)
}
resp, err := ctxhttp.Do(ctx, ah.client, req) resp, err := ctxhttp.Do(ctx, ah.client, req)
if err != nil { if err != nil {
...@@ -408,6 +412,9 @@ func (ah *authHandler) fetchToken(ctx context.Context, to tokenOptions) (string, ...@@ -408,6 +412,9 @@ func (ah *authHandler) fetchToken(ctx context.Context, to tokenOptions) (string,
req.Header[k] = append(req.Header[k], v...) req.Header[k] = append(req.Header[k], v...)
} }
} }
if len(req.Header.Get("User-Agent")) == 0 {
req.Header.Set("User-Agent", "containerd/"+version.Version)
}
reqParams := req.URL.Query() reqParams := req.URL.Query()
......
...@@ -148,7 +148,7 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R ...@@ -148,7 +148,7 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R
}) })
} }
func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string, offset int64) (io.ReadCloser, error) { func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string, offset int64) (_ io.ReadCloser, retErr error) {
req.header.Set("Accept", strings.Join([]string{mediatype, `*/*`}, ", ")) req.header.Set("Accept", strings.Join([]string{mediatype, `*/*`}, ", "))
if offset > 0 { if offset > 0 {
...@@ -162,13 +162,17 @@ func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string, ...@@ -162,13 +162,17 @@ func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string,
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() {
if retErr != nil {
resp.Body.Close()
}
}()
if resp.StatusCode > 299 { if resp.StatusCode > 299 {
// TODO(stevvooe): When doing a offset specific request, we should // TODO(stevvooe): When doing a offset specific request, we should
// really distinguish between a 206 and a 200. In the case of 200, we // really distinguish between a 206 and a 200. In the case of 200, we
// can discard the bytes, hiding the seek behavior from the // can discard the bytes, hiding the seek behavior from the
// implementation. // implementation.
defer resp.Body.Close()
if resp.StatusCode == http.StatusNotFound { if resp.StatusCode == http.StatusNotFound {
return nil, errors.Wrapf(errdefs.ErrNotFound, "content at %v not found", req.String()) return nil, errors.Wrapf(errdefs.ErrNotFound, "content at %v not found", req.String())
......
...@@ -109,12 +109,15 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten ...@@ -109,12 +109,15 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
// TODO: Set updated time? // TODO: Set updated time?
}, },
}) })
resp.Body.Close()
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest) return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest)
} }
} else if resp.StatusCode != http.StatusNotFound { } else if resp.StatusCode != http.StatusNotFound {
resp.Body.Close()
// TODO: log error // TODO: log error
return nil, errors.Errorf("unexpected response: %s", resp.Status) return nil, errors.Errorf("unexpected response: %s", resp.Status)
} }
resp.Body.Close()
} }
if isManifest { if isManifest {
......
...@@ -239,7 +239,7 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp ...@@ -239,7 +239,7 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
} }
var ( var (
lastErr error firstErr error
paths [][]string paths [][]string
dgst = refspec.Digest() dgst = refspec.Digest()
caps = HostCapabilityPull caps = HostCapabilityPull
...@@ -293,8 +293,8 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp ...@@ -293,8 +293,8 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
err = errors.Wrapf(err, "pull access denied, repository does not exist or may require authorization") err = errors.Wrapf(err, "pull access denied, repository does not exist or may require authorization")
} }
// Store the error for referencing later // Store the error for referencing later
if lastErr == nil { if firstErr == nil {
lastErr = err firstErr = err
} }
log.G(ctx).WithError(err).Info("trying next host") log.G(ctx).WithError(err).Info("trying next host")
continue // try another host continue // try another host
...@@ -306,7 +306,14 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp ...@@ -306,7 +306,14 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
log.G(ctx).Info("trying next host - response was http.StatusNotFound") log.G(ctx).Info("trying next host - response was http.StatusNotFound")
continue continue
} }
return "", ocispec.Descriptor{}, errors.Errorf("unexpected status code %v: %v", u, resp.Status) if resp.StatusCode > 399 {
// Set firstErr when encountering the first non-404 status code.
if firstErr == nil {
firstErr = errors.Errorf("pulling from host %s failed with status code %v: %v", host.Host, u, resp.Status)
}
continue // try another host
}
return "", ocispec.Descriptor{}, errors.Errorf("pulling from host %s failed with unexpected status code %v: %v", host.Host, u, resp.Status)
} }
size := resp.ContentLength size := resp.ContentLength
contentType := getManifestMediaType(resp) contentType := getManifestMediaType(resp)
...@@ -369,8 +376,8 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp ...@@ -369,8 +376,8 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
} }
// Prevent resolving to excessively large manifests // Prevent resolving to excessively large manifests
if size > MaxManifestSize { if size > MaxManifestSize {
if lastErr == nil { if firstErr == nil {
lastErr = errors.Wrapf(errdefs.ErrNotFound, "rejecting %d byte manifest for %s", size, ref) firstErr = errors.Wrapf(errdefs.ErrNotFound, "rejecting %d byte manifest for %s", size, ref)
} }
continue continue
} }
...@@ -386,11 +393,15 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp ...@@ -386,11 +393,15 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
} }
} }
if lastErr == nil { // If above loop terminates without return, then there was an error.
lastErr = errors.Wrap(errdefs.ErrNotFound, ref) // "firstErr" contains the first non-404 error. That is, "firstErr == nil"
// means that either no registries were given or each registry returned 404.
if firstErr == nil {
firstErr = errors.Wrap(errdefs.ErrNotFound, ref)
} }
return "", ocispec.Descriptor{}, lastErr return "", ocispec.Descriptor{}, firstErr
} }
func (r *dockerResolver) Fetcher(ctx context.Context, ref string) (remotes.Fetcher, error) { func (r *dockerResolver) Fetcher(ctx context.Context, ref string) (remotes.Fetcher, error) {
...@@ -561,7 +572,21 @@ func (r *request) do(ctx context.Context) (*http.Response, error) { ...@@ -561,7 +572,21 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
if err := r.authorize(ctx, req); err != nil { if err := r.authorize(ctx, req); err != nil {
return nil, errors.Wrap(err, "failed to authorize") return nil, errors.Wrap(err, "failed to authorize")
} }
resp, err := ctxhttp.Do(ctx, r.host.Client, req)
var client = &http.Client{}
if r.host.Client != nil {
*client = *r.host.Client
}
if client.CheckRedirect == nil {
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return errors.New("stopped after 10 redirects")
}
return errors.Wrap(r.authorize(ctx, req), "failed to authorize redirect")
}
}
resp, err := ctxhttp.Do(ctx, client, req)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to do request") return nil, errors.Wrap(err, "failed to do request")
} }
......
...@@ -23,7 +23,7 @@ var ( ...@@ -23,7 +23,7 @@ var (
Package = "github.com/containerd/containerd" Package = "github.com/containerd/containerd"
// Version holds the complete version number. Filled in at linking time. // Version holds the complete version number. Filled in at linking time.
Version = "1.4.8+unknown" Version = "1.4.9+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build // Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time. // the program at linking time.
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// +build !windows
// Package activation implements primitives for systemd socket activation. // Package activation implements primitives for systemd socket activation.
package activation package activation
......
// Copyright 2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package activation
import "os"
func Files(unsetEnv bool) []*os.File {
return nil
}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package dbus package dbus
import ( import (
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"os" "os"
...@@ -112,39 +113,63 @@ type Conn struct { ...@@ -112,39 +113,63 @@ type Conn struct {
// New establishes a connection to any available bus and authenticates. // New establishes a connection to any available bus and authenticates.
// Callers should call Close() when done with the connection. // Callers should call Close() when done with the connection.
// Deprecated: use NewWithContext instead
func New() (*Conn, error) { func New() (*Conn, error) {
conn, err := NewSystemConnection() return NewWithContext(context.Background())
}
// NewWithContext same as New with context
func NewWithContext(ctx context.Context) (*Conn, error) {
conn, err := NewSystemConnectionContext(ctx)
if err != nil && os.Geteuid() == 0 { if err != nil && os.Geteuid() == 0 {
return NewSystemdConnection() return NewSystemdConnectionContext(ctx)
} }
return conn, err return conn, err
} }
// NewSystemConnection establishes a connection to the system bus and authenticates. // NewSystemConnection establishes a connection to the system bus and authenticates.
// Callers should call Close() when done with the connection // Callers should call Close() when done with the connection
// Deprecated: use NewSystemConnectionContext instead
func NewSystemConnection() (*Conn, error) { func NewSystemConnection() (*Conn, error) {
return NewSystemConnectionContext(context.Background())
}
// NewSystemConnectionContext same as NewSystemConnection with context
func NewSystemConnectionContext(ctx context.Context) (*Conn, error) {
return NewConnection(func() (*dbus.Conn, error) { return NewConnection(func() (*dbus.Conn, error) {
return dbusAuthHelloConnection(dbus.SystemBusPrivate) return dbusAuthHelloConnection(ctx, dbus.SystemBusPrivate)
}) })
} }
// NewUserConnection establishes a connection to the session bus and // NewUserConnection establishes a connection to the session bus and
// authenticates. This can be used to connect to systemd user instances. // authenticates. This can be used to connect to systemd user instances.
// Callers should call Close() when done with the connection. // Callers should call Close() when done with the connection.
// Deprecated: use NewUserConnectionContext instead
func NewUserConnection() (*Conn, error) { func NewUserConnection() (*Conn, error) {
return NewUserConnectionContext(context.Background())
}
// NewUserConnectionContext same as NewUserConnection with context
func NewUserConnectionContext(ctx context.Context) (*Conn, error) {
return NewConnection(func() (*dbus.Conn, error) { return NewConnection(func() (*dbus.Conn, error) {
return dbusAuthHelloConnection(dbus.SessionBusPrivate) return dbusAuthHelloConnection(ctx, dbus.SessionBusPrivate)
}) })
} }
// NewSystemdConnection establishes a private, direct connection to systemd. // NewSystemdConnection establishes a private, direct connection to systemd.
// This can be used for communicating with systemd without a dbus daemon. // This can be used for communicating with systemd without a dbus daemon.
// Callers should call Close() when done with the connection. // Callers should call Close() when done with the connection.
// Deprecated: use NewSystemdConnectionContext instead
func NewSystemdConnection() (*Conn, error) { func NewSystemdConnection() (*Conn, error) {
return NewSystemdConnectionContext(context.Background())
}
// NewSystemdConnectionContext same as NewSystemdConnection with context
func NewSystemdConnectionContext(ctx context.Context) (*Conn, error) {
return NewConnection(func() (*dbus.Conn, error) { return NewConnection(func() (*dbus.Conn, error) {
// We skip Hello when talking directly to systemd. // We skip Hello when talking directly to systemd.
return dbusAuthConnection(func(opts ...dbus.ConnOption) (*dbus.Conn, error) { return dbusAuthConnection(ctx, func(opts ...dbus.ConnOption) (*dbus.Conn, error) {
return dbus.Dial("unix:path=/run/systemd/private") return dbus.Dial("unix:path=/run/systemd/private", opts...)
}) })
}) })
} }
...@@ -201,8 +226,8 @@ func (c *Conn) GetManagerProperty(prop string) (string, error) { ...@@ -201,8 +226,8 @@ func (c *Conn) GetManagerProperty(prop string) (string, error) {
return variant.String(), nil return variant.String(), nil
} }
func dbusAuthConnection(createBus func(opts ...dbus.ConnOption) (*dbus.Conn, error)) (*dbus.Conn, error) { func dbusAuthConnection(ctx context.Context, createBus func(opts ...dbus.ConnOption) (*dbus.Conn, error)) (*dbus.Conn, error) {
conn, err := createBus() conn, err := createBus(dbus.WithContext(ctx))
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -221,8 +246,8 @@ func dbusAuthConnection(createBus func(opts ...dbus.ConnOption) (*dbus.Conn, err ...@@ -221,8 +246,8 @@ func dbusAuthConnection(createBus func(opts ...dbus.ConnOption) (*dbus.Conn, err
return conn, nil return conn, nil
} }
func dbusAuthHelloConnection(createBus func(opts ...dbus.ConnOption) (*dbus.Conn, error)) (*dbus.Conn, error) { func dbusAuthHelloConnection(ctx context.Context, createBus func(opts ...dbus.ConnOption) (*dbus.Conn, error)) (*dbus.Conn, error) {
conn, err := dbusAuthConnection(createBus) conn, err := dbusAuthConnection(ctx, createBus)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
dist: bionic
language: go
go_import_path: github.com/godbus/dbus
go:
- 1.11.x
- 1.12.x
- 1.13.x
- tip
matrix:
fast_finish: true
allow_failures:
- go: tip
addons:
apt:
packages:
- dbus
- dbus-x11
before_install:
- export GO111MODULE=on
script:
- go test -v -race -mod=readonly ./... # Run all the tests with the race detector enabled
- go vet ./... # go vet is the official Go static analyzer
jobs:
include:
# The build matrix doesn't cover build stages, so manually expand
# the jobs with anchors
- &multiarch
stage: "Multiarch Test"
go: 1.11.x
env: TARGETS="386 arm arm64 ppc64le"
before_install:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
script:
- |
set -e
for target in $TARGETS; do
printf "\e[1mRunning test suite under ${target}.\e[0m\n"
GOARCH="$target" go test -v ./...
printf "\n\n"
done
- <<: *multiarch
go: 1.12.x
- <<: *multiarch
go: 1.13.x
[![Build Status](https://travis-ci.org/godbus/dbus.svg?branch=master)](https://travis-ci.org/godbus/dbus) ![Build Status](https://github.com/godbus/dbus/workflows/Go/badge.svg)
dbus dbus
---- ----
...@@ -32,6 +32,8 @@ gives a short overview over the basic usage. ...@@ -32,6 +32,8 @@ gives a short overview over the basic usage.
#### Projects using godbus #### Projects using godbus
- [notify](https://github.com/esiqveland/notify) provides desktop notifications over dbus into a library. - [notify](https://github.com/esiqveland/notify) provides desktop notifications over dbus into a library.
- [go-bluetooth](https://github.com/muka/go-bluetooth) provides a bluetooth client over bluez dbus API. - [go-bluetooth](https://github.com/muka/go-bluetooth) provides a bluetooth client over bluez dbus API.
- [playerbm](https://github.com/altdesktop/playerbm) a bookmark utility for media players.
- [iwd](https://github.com/shibumi/iwd) go bindings for the internet wireless daemon "iwd".
Please note that the API is considered unstable for now and may change without Please note that the API is considered unstable for now and may change without
further notice. further notice.
......
...@@ -37,7 +37,7 @@ const ( ...@@ -37,7 +37,7 @@ const (
// Auth defines the behaviour of an authentication mechanism. // Auth defines the behaviour of an authentication mechanism.
type Auth interface { type Auth interface {
// Return the name of the mechnism, the argument to the first AUTH command // Return the name of the mechanism, the argument to the first AUTH command
// and the next status. // and the next status.
FirstData() (name, resp []byte, status AuthStatus) FirstData() (name, resp []byte, status AuthStatus)
......
...@@ -24,6 +24,15 @@ type Call struct { ...@@ -24,6 +24,15 @@ type Call struct {
// Holds the response once the call is done. // Holds the response once the call is done.
Body []interface{} Body []interface{}
// ResponseSequence stores the sequence number of the DBus message containing
// the call response (or error). This can be compared to the sequence number
// of other call responses and signals on this connection to determine their
// relative ordering on the underlying DBus connection.
// For errors, ResponseSequence is populated only if the error came from a
// DBusMessage that was received or if there was an error receiving. In case of
// failure to make the call, ResponseSequence will be NoSequence.
ResponseSequence Sequence
// tracks context and canceler // tracks context and canceler
ctx context.Context ctx context.Context
ctxCanceler context.CancelFunc ctxCanceler context.CancelFunc
......
...@@ -28,6 +28,7 @@ var ( ...@@ -28,6 +28,7 @@ var (
interfaceType = reflect.TypeOf((*interface{})(nil)).Elem() interfaceType = reflect.TypeOf((*interface{})(nil)).Elem()
unixFDType = reflect.TypeOf(UnixFD(0)) unixFDType = reflect.TypeOf(UnixFD(0))
unixFDIndexType = reflect.TypeOf(UnixFDIndex(0)) unixFDIndexType = reflect.TypeOf(UnixFDIndex(0))
errType = reflect.TypeOf((*error)(nil)).Elem()
) )
// An InvalidTypeError signals that a value which cannot be represented in the // An InvalidTypeError signals that a value which cannot be represented in the
...@@ -63,6 +64,9 @@ func storeInterfaces(src, dest interface{}) error { ...@@ -63,6 +64,9 @@ func storeInterfaces(src, dest interface{}) error {
func store(dest, src reflect.Value) error { func store(dest, src reflect.Value) error {
if dest.Kind() == reflect.Ptr { if dest.Kind() == reflect.Ptr {
if dest.IsNil() {
dest.Set(reflect.New(dest.Type().Elem()))
}
return store(dest.Elem(), src) return store(dest.Elem(), src)
} }
switch src.Kind() { switch src.Kind() {
......
...@@ -126,14 +126,28 @@ func (m exportedMethod) Call(args ...interface{}) ([]interface{}, error) { ...@@ -126,14 +126,28 @@ func (m exportedMethod) Call(args ...interface{}) ([]interface{}, error) {
} }
ret := m.Value.Call(params) ret := m.Value.Call(params)
var err error
err := ret[t.NumOut()-1].Interface().(*Error) nilErr := false // The reflection will find almost-nils, let's only pass back clean ones!
if t.NumOut() > 0 {
if e, ok := ret[t.NumOut()-1].Interface().(*Error); ok { // godbus *Error
nilErr = ret[t.NumOut()-1].IsNil()
ret = ret[:t.NumOut()-1]
err = e
} else if ret[t.NumOut()-1].Type().Implements(errType) { // Go error
i := ret[t.NumOut()-1].Interface()
if i == nil {
nilErr = ret[t.NumOut()-1].IsNil()
} else {
err = i.(error)
}
ret = ret[:t.NumOut()-1] ret = ret[:t.NumOut()-1]
}
}
out := make([]interface{}, len(ret)) out := make([]interface{}, len(ret))
for i, val := range ret { for i, val := range ret {
out[i] = val.Interface() out[i] = val.Interface()
} }
if err == nil { if nilErr || err == nil {
//concrete type to interface nil is a special case //concrete type to interface nil is a special case
return out, nil return out, nil
} }
......
...@@ -69,6 +69,22 @@ func getMethods(in interface{}, mapping map[string]string) map[string]reflect.Va ...@@ -69,6 +69,22 @@ func getMethods(in interface{}, mapping map[string]string) map[string]reflect.Va
return methods return methods
} }
func getAllMethods(in interface{}, mapping map[string]string) map[string]reflect.Value {
if in == nil {
return nil
}
methods := make(map[string]reflect.Value)
val := reflect.ValueOf(in)
typ := val.Type()
for i := 0; i < typ.NumMethod(); i++ {
methtype := typ.Method(i)
method := val.Method(i)
// map names while building table
methods[computeMethodName(methtype.Name, mapping)] = method
}
return methods
}
func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []interface{}) ([]interface{}, error) { func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []interface{}) ([]interface{}, error) {
pointers := make([]interface{}, m.NumArguments()) pointers := make([]interface{}, m.NumArguments())
decode := make([]interface{}, 0, len(body)) decode := make([]interface{}, 0, len(body))
...@@ -159,7 +175,6 @@ func (conn *Conn) handleCall(msg *Message) { ...@@ -159,7 +175,6 @@ func (conn *Conn) handleCall(msg *Message) {
if msg.Flags&FlagNoReplyExpected == 0 { if msg.Flags&FlagNoReplyExpected == 0 {
reply := new(Message) reply := new(Message)
reply.Type = TypeMethodReply reply.Type = TypeMethodReply
reply.serial = conn.getSerial()
reply.Headers = make(map[HeaderField]Variant) reply.Headers = make(map[HeaderField]Variant)
if hasSender { if hasSender {
reply.Headers[FieldDestination] = msg.Headers[FieldSender] reply.Headers[FieldDestination] = msg.Headers[FieldSender]
...@@ -195,7 +210,6 @@ func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) erro ...@@ -195,7 +210,6 @@ func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) erro
} }
msg := new(Message) msg := new(Message)
msg.Type = TypeSignal msg.Type = TypeSignal
msg.serial = conn.getSerial()
msg.Headers = make(map[HeaderField]Variant) msg.Headers = make(map[HeaderField]Variant)
msg.Headers[FieldInterface] = MakeVariant(iface) msg.Headers[FieldInterface] = MakeVariant(iface)
msg.Headers[FieldMember] = MakeVariant(member) msg.Headers[FieldMember] = MakeVariant(member)
...@@ -247,6 +261,18 @@ func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error { ...@@ -247,6 +261,18 @@ func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error {
return conn.ExportWithMap(v, nil, path, iface) return conn.ExportWithMap(v, nil, path, iface)
} }
// ExportAll registers all exported methods defined by the given object on
// the message bus.
//
// Unlike Export there is no requirement to have the last parameter as type
// *Error. If you want to be able to return error then you can append an error
// type parameter to your method signature. If the error returned is not nil,
// it is sent back to the caller as an error. Otherwise, a method reply is
// sent with the other return values as its body.
func (conn *Conn) ExportAll(v interface{}, path ObjectPath, iface string) error {
return conn.export(getAllMethods(v, nil), path, iface, false)
}
// ExportWithMap works exactly like Export but provides the ability to remap // ExportWithMap works exactly like Export but provides the ability to remap
// method names (e.g. export a lower-case method). // method names (e.g. export a lower-case method).
// //
...@@ -299,7 +325,9 @@ func (conn *Conn) ExportSubtreeMethodTable(methods map[string]interface{}, path ...@@ -299,7 +325,9 @@ func (conn *Conn) ExportSubtreeMethodTable(methods map[string]interface{}, path
} }
func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectPath, iface string, includeSubtree bool) error { func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectPath, iface string, includeSubtree bool) error {
out := make(map[string]reflect.Value) var out map[string]reflect.Value
if methods != nil {
out = make(map[string]reflect.Value)
for name, method := range methods { for name, method := range methods {
rval := reflect.ValueOf(method) rval := reflect.ValueOf(method)
if rval.Kind() != reflect.Func { if rval.Kind() != reflect.Func {
...@@ -313,6 +341,7 @@ func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectP ...@@ -313,6 +341,7 @@ func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectP
} }
out[name] = rval out[name] = rval
} }
}
return conn.export(out, path, iface, includeSubtree) return conn.export(out, path, iface, includeSubtree)
} }
...@@ -327,12 +356,12 @@ func (conn *Conn) unexport(h *defaultHandler, path ObjectPath, iface string) err ...@@ -327,12 +356,12 @@ func (conn *Conn) unexport(h *defaultHandler, path ObjectPath, iface string) err
return nil return nil
} }
// exportWithMap is the worker function for all exports/registrations. // export is the worker function for all exports/registrations.
func (conn *Conn) export(methods map[string]reflect.Value, path ObjectPath, iface string, includeSubtree bool) error { func (conn *Conn) export(methods map[string]reflect.Value, path ObjectPath, iface string, includeSubtree bool) error {
h, ok := conn.handler.(*defaultHandler) h, ok := conn.handler.(*defaultHandler)
if !ok { if !ok {
return fmt.Errorf( return fmt.Errorf(
`dbus: export only allowed on the default hander handler have %T"`, `dbus: export only allowed on the default handler. Received: %T"`,
conn.handler) conn.handler)
} }
......
package dbus package dbus
import ( import (
"strconv"
"strings" "strings"
) )
...@@ -60,3 +61,29 @@ func WithMatchPathNamespace(namespace ObjectPath) MatchOption { ...@@ -60,3 +61,29 @@ func WithMatchPathNamespace(namespace ObjectPath) MatchOption {
func WithMatchDestination(destination string) MatchOption { func WithMatchDestination(destination string) MatchOption {
return WithMatchOption("destination", destination) return WithMatchOption("destination", destination)
} }
// WithMatchArg sets argN match option, range of N is 0 to 63.
func WithMatchArg(argIdx int, value string) MatchOption {
if argIdx < 0 || argIdx > 63 {
panic("range of argument index is 0 to 63")
}
return WithMatchOption("arg"+strconv.Itoa(argIdx), value)
}
// WithMatchArgPath sets argN path match option, range of N is 0 to 63.
func WithMatchArgPath(argIdx int, path string) MatchOption {
if argIdx < 0 || argIdx > 63 {
panic("range of argument index is 0 to 63")
}
return WithMatchOption("arg"+strconv.Itoa(argIdx)+"path", path)
}
// WithMatchArg0Namespace sets arg0namespace match option.
func WithMatchArg0Namespace(arg0Namespace string) MatchOption {
return WithMatchOption("arg0namespace", arg0Namespace)
}
// WithMatchEavesdrop sets eavesdrop match option.
func WithMatchEavesdrop(eavesdrop bool) MatchOption {
return WithMatchOption("eavesdrop", strconv.FormatBool(eavesdrop))
}
...@@ -16,6 +16,7 @@ type BusObject interface { ...@@ -16,6 +16,7 @@ type BusObject interface {
AddMatchSignal(iface, member string, options ...MatchOption) *Call AddMatchSignal(iface, member string, options ...MatchOption) *Call
RemoveMatchSignal(iface, member string, options ...MatchOption) *Call RemoveMatchSignal(iface, member string, options ...MatchOption) *Call
GetProperty(p string) (Variant, error) GetProperty(p string) (Variant, error)
StoreProperty(p string, value interface{}) error
SetProperty(p string, v interface{}) error SetProperty(p string, v interface{}) error
Destination() string Destination() string
Path() ObjectPath Path() ObjectPath
...@@ -109,7 +110,6 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch ...@@ -109,7 +110,6 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
method = method[i+1:] method = method[i+1:]
msg := new(Message) msg := new(Message)
msg.Type = TypeMethodCall msg.Type = TypeMethodCall
msg.serial = o.conn.getSerial()
msg.Flags = flags & (FlagNoAutoStart | FlagNoReplyExpected) msg.Flags = flags & (FlagNoAutoStart | FlagNoReplyExpected)
msg.Headers = make(map[HeaderField]Variant) msg.Headers = make(map[HeaderField]Variant)
msg.Headers[FieldPath] = MakeVariant(o.path) msg.Headers[FieldPath] = MakeVariant(o.path)
...@@ -122,68 +122,31 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch ...@@ -122,68 +122,31 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
if len(args) > 0 { if len(args) > 0 {
msg.Headers[FieldSignature] = MakeVariant(SignatureOf(args...)) msg.Headers[FieldSignature] = MakeVariant(SignatureOf(args...))
} }
if msg.Flags&FlagNoReplyExpected == 0 { return o.conn.SendWithContext(ctx, msg, ch)
if ch == nil {
ch = make(chan *Call, 1)
} else if cap(ch) == 0 {
panic("dbus: unbuffered channel passed to (*Object).Go")
}
ctx, cancel := context.WithCancel(ctx)
call := &Call{
Destination: o.dest,
Path: o.path,
Method: method,
Args: args,
Done: ch,
ctxCanceler: cancel,
ctx: ctx,
}
o.conn.calls.track(msg.serial, call)
o.conn.sendMessageAndIfClosed(msg, func() {
o.conn.calls.handleSendError(msg, ErrClosed)
cancel()
})
go func() {
<-ctx.Done()
o.conn.calls.handleSendError(msg, ctx.Err())
}()
return call
}
done := make(chan *Call, 1)
call := &Call{
Err: nil,
Done: done,
}
defer func() {
call.Done <- call
close(done)
}()
o.conn.sendMessageAndIfClosed(msg, func() {
call.Err = ErrClosed
})
return call
} }
// GetProperty calls org.freedesktop.DBus.Properties.Get on the given // GetProperty calls org.freedesktop.DBus.Properties.Get on the given
// object. The property name must be given in interface.member notation. // object. The property name must be given in interface.member notation.
func (o *Object) GetProperty(p string) (Variant, error) { func (o *Object) GetProperty(p string) (Variant, error) {
var result Variant
err := o.StoreProperty(p, &result)
return result, err
}
// StoreProperty calls org.freedesktop.DBus.Properties.Get on the given
// object. The property name must be given in interface.member notation.
// It stores the returned property into the provided value.
func (o *Object) StoreProperty(p string, value interface{}) error {
idx := strings.LastIndex(p, ".") idx := strings.LastIndex(p, ".")
if idx == -1 || idx+1 == len(p) { if idx == -1 || idx+1 == len(p) {
return Variant{}, errors.New("dbus: invalid property " + p) return errors.New("dbus: invalid property " + p)
} }
iface := p[:idx] iface := p[:idx]
prop := p[idx+1:] prop := p[idx+1:]
result := Variant{} return o.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).
err := o.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result) Store(value)
if err != nil {
return Variant{}, err
}
return result, nil
} }
// SetProperty calls org.freedesktop.DBus.Properties.Set on the given // SetProperty calls org.freedesktop.DBus.Properties.Set on the given
......
package dbus
// Sequence represents the value of a monotonically increasing counter.
type Sequence uint64
const (
// NoSequence indicates the absence of a sequence value.
NoSequence Sequence = 0
)
// sequenceGenerator represents a monotonically increasing counter.
type sequenceGenerator struct {
nextSequence Sequence
}
func (generator *sequenceGenerator) next() Sequence {
result := generator.nextSequence
generator.nextSequence++
return result
}
func newSequenceGenerator() *sequenceGenerator {
return &sequenceGenerator{nextSequence: 1}
}
package dbus
import (
"sync"
)
// NewSequentialSignalHandler returns an instance of a new
// signal handler that guarantees sequential processing of signals. It is a
// guarantee of this signal handler that signals will be written to
// channels in the order they are received on the DBus connection.
func NewSequentialSignalHandler() SignalHandler {
return &sequentialSignalHandler{}
}
type sequentialSignalHandler struct {
mu sync.RWMutex
closed bool
signals []*sequentialSignalChannelData
}
func (sh *sequentialSignalHandler) DeliverSignal(intf, name string, signal *Signal) {
sh.mu.RLock()
defer sh.mu.RUnlock()
if sh.closed {
return
}
for _, scd := range sh.signals {
scd.deliver(signal)
}
}
func (sh *sequentialSignalHandler) Terminate() {
sh.mu.Lock()
defer sh.mu.Unlock()
if sh.closed {
return
}
for _, scd := range sh.signals {
scd.close()
close(scd.ch)
}
sh.closed = true
sh.signals = nil
}
func (sh *sequentialSignalHandler) AddSignal(ch chan<- *Signal) {
sh.mu.Lock()
defer sh.mu.Unlock()
if sh.closed {
return
}
sh.signals = append(sh.signals, newSequentialSignalChannelData(ch))
}
func (sh *sequentialSignalHandler) RemoveSignal(ch chan<- *Signal) {
sh.mu.Lock()
defer sh.mu.Unlock()
if sh.closed {
return
}
for i := len(sh.signals) - 1; i >= 0; i-- {
if ch == sh.signals[i].ch {
sh.signals[i].close()
copy(sh.signals[i:], sh.signals[i+1:])
sh.signals[len(sh.signals)-1] = nil
sh.signals = sh.signals[:len(sh.signals)-1]
}
}
}
type sequentialSignalChannelData struct {
ch chan<- *Signal
in chan *Signal
done chan struct{}
}
func newSequentialSignalChannelData(ch chan<- *Signal) *sequentialSignalChannelData {
scd := &sequentialSignalChannelData{
ch: ch,
in: make(chan *Signal),
done: make(chan struct{}),
}
go scd.bufferSignals()
return scd
}
func (scd *sequentialSignalChannelData) bufferSignals() {
defer close(scd.done)
// Ensure that signals are delivered to scd.ch in the same
// order they are received from scd.in.
var queue []*Signal
for {
if len(queue) == 0 {
signal, ok := <- scd.in
if !ok {
return
}
queue = append(queue, signal)
}
select {
case scd.ch <- queue[0]:
copy(queue, queue[1:])
queue[len(queue)-1] = nil
queue = queue[:len(queue)-1]
case signal, ok := <-scd.in:
if !ok {
return
}
queue = append(queue, signal)
}
}
}
func (scd *sequentialSignalChannelData) deliver(signal *Signal) {
scd.in <- signal
}
func (scd *sequentialSignalChannelData) close() {
close(scd.in)
// Ensure that bufferSignals() has exited and won't attempt
// any future sends on scd.ch
<-scd.done
}
...@@ -137,7 +137,7 @@ func ParseSignatureMust(s string) Signature { ...@@ -137,7 +137,7 @@ func ParseSignatureMust(s string) Signature {
return sig return sig
} }
// Empty retruns whether the signature is the empty signature. // Empty returns whether the signature is the empty signature.
func (s Signature) Empty() bool { func (s Signature) Empty() bool {
return s.str == "" return s.str == ""
} }
......
...@@ -10,6 +10,7 @@ package dbus ...@@ -10,6 +10,7 @@ package dbus
/* /*
const int sizeofPtr = sizeof(void*); const int sizeofPtr = sizeof(void*);
#define _WANT_UCRED #define _WANT_UCRED
#include <sys/types.h>
#include <sys/ucred.h> #include <sys/ucred.h>
*/ */
import "C" import "C"
......
...@@ -142,3 +142,9 @@ func (v Variant) String() string { ...@@ -142,3 +142,9 @@ func (v Variant) String() string {
func (v Variant) Value() interface{} { func (v Variant) Value() interface{} {
return v.value return v.value
} }
// Store converts the variant into a native go type using the same
// mechanism as the "Store" function.
func (v Variant) Store(value interface{}) error {
return storeInterfaces(v.value, value)
}
...@@ -46,7 +46,7 @@ github.com/Microsoft/go-winio/pkg/etwlogrus ...@@ -46,7 +46,7 @@ github.com/Microsoft/go-winio/pkg/etwlogrus
github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/go-winio/pkg/guid
github.com/Microsoft/go-winio/pkg/security github.com/Microsoft/go-winio/pkg/security
github.com/Microsoft/go-winio/vhd github.com/Microsoft/go-winio/vhd
# github.com/Microsoft/hcsshim v0.8.20 => github.com/Microsoft/hcsshim v0.8.20 # github.com/Microsoft/hcsshim v0.8.16 => github.com/Microsoft/hcsshim v0.8.20
github.com/Microsoft/hcsshim github.com/Microsoft/hcsshim
github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options
github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats
...@@ -173,7 +173,7 @@ github.com/containerd/cgroups/v2 ...@@ -173,7 +173,7 @@ github.com/containerd/cgroups/v2
github.com/containerd/cgroups/v2/stats github.com/containerd/cgroups/v2/stats
# github.com/containerd/console v1.0.2 => github.com/containerd/console v1.0.2 # github.com/containerd/console v1.0.2 => github.com/containerd/console v1.0.2
github.com/containerd/console github.com/containerd/console
# github.com/containerd/containerd v1.5.1 => github.com/k3s-io/containerd v1.4.8-k3s1 # github.com/containerd/containerd v1.5.1 => github.com/k3s-io/containerd v1.4.9-k3s1
## explicit ## explicit
github.com/containerd/containerd github.com/containerd/containerd
github.com/containerd/containerd/api/events github.com/containerd/containerd/api/events
...@@ -412,7 +412,7 @@ github.com/coreos/go-semver/semver ...@@ -412,7 +412,7 @@ github.com/coreos/go-semver/semver
github.com/coreos/go-systemd/activation github.com/coreos/go-systemd/activation
github.com/coreos/go-systemd/daemon github.com/coreos/go-systemd/daemon
github.com/coreos/go-systemd/journal github.com/coreos/go-systemd/journal
# github.com/coreos/go-systemd/v22 v22.1.0 # github.com/coreos/go-systemd/v22 v22.3.1
github.com/coreos/go-systemd/v22/activation github.com/coreos/go-systemd/v22/activation
github.com/coreos/go-systemd/v22/daemon github.com/coreos/go-systemd/v22/daemon
github.com/coreos/go-systemd/v22/dbus github.com/coreos/go-systemd/v22/dbus
...@@ -524,7 +524,7 @@ github.com/go-openapi/validate ...@@ -524,7 +524,7 @@ github.com/go-openapi/validate
github.com/go-sql-driver/mysql github.com/go-sql-driver/mysql
# github.com/go-stack/stack v1.8.0 # github.com/go-stack/stack v1.8.0
github.com/go-stack/stack github.com/go-stack/stack
# github.com/godbus/dbus/v5 v5.0.3 # github.com/godbus/dbus/v5 v5.0.4
github.com/godbus/dbus/v5 github.com/godbus/dbus/v5
# github.com/gofrs/flock v0.7.1 # github.com/gofrs/flock v0.7.1
github.com/gofrs/flock github.com/gofrs/flock
...@@ -799,7 +799,7 @@ github.com/opencontainers/go-digest/digestset ...@@ -799,7 +799,7 @@ github.com/opencontainers/go-digest/digestset
github.com/opencontainers/image-spec/identity github.com/opencontainers/image-spec/identity
github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/image-spec/specs-go/v1
# github.com/opencontainers/runc v1.0.0-rc93 => github.com/opencontainers/runc v1.0.0-rc92 # github.com/opencontainers/runc v1.0.0-rc94 => github.com/opencontainers/runc v1.0.0-rc92
## explicit ## explicit
github.com/opencontainers/runc github.com/opencontainers/runc
github.com/opencontainers/runc/contrib/cmd/recvtty github.com/opencontainers/runc/contrib/cmd/recvtty
...@@ -827,7 +827,7 @@ github.com/opencontainers/runc/libcontainer/system ...@@ -827,7 +827,7 @@ github.com/opencontainers/runc/libcontainer/system
github.com/opencontainers/runc/libcontainer/user github.com/opencontainers/runc/libcontainer/user
github.com/opencontainers/runc/libcontainer/utils github.com/opencontainers/runc/libcontainer/utils
github.com/opencontainers/runc/types github.com/opencontainers/runc/types
# github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d => github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6 # github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 => github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6
github.com/opencontainers/runtime-spec/specs-go github.com/opencontainers/runtime-spec/specs-go
# github.com/opencontainers/selinux v1.8.0 # github.com/opencontainers/selinux v1.8.0
## explicit ## explicit
...@@ -1215,7 +1215,7 @@ golang.org/x/oauth2/jwt ...@@ -1215,7 +1215,7 @@ golang.org/x/oauth2/jwt
golang.org/x/sync/errgroup golang.org/x/sync/errgroup
golang.org/x/sync/semaphore golang.org/x/sync/semaphore
golang.org/x/sync/singleflight golang.org/x/sync/singleflight
# golang.org/x/sys v0.0.0-20210324051608-47abb6519492 => golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073 # golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 => golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073
## explicit ## explicit
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader
...@@ -2974,7 +2974,7 @@ vbom.ml/util/sortorder ...@@ -2974,7 +2974,7 @@ vbom.ml/util/sortorder
# github.com/containerd/btrfs => github.com/containerd/btrfs v1.0.0 # github.com/containerd/btrfs => github.com/containerd/btrfs v1.0.0
# github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.1 # github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.1
# github.com/containerd/console => github.com/containerd/console v1.0.2 # github.com/containerd/console => github.com/containerd/console v1.0.2
# github.com/containerd/containerd => github.com/k3s-io/containerd v1.4.8-k3s1 # github.com/containerd/containerd => github.com/k3s-io/containerd v1.4.9-k3s1
# github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1 # github.com/containerd/continuity => github.com/k3s-io/continuity v0.0.0-20210309170710-f93269e0d5c1
# github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7 # github.com/containerd/cri => github.com/k3s-io/cri v1.4.0-k3s.7
# github.com/containerd/fifo => github.com/containerd/fifo v1.0.0 # github.com/containerd/fifo => github.com/containerd/fifo v1.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment