From 3a7cfaebbd6ab1cfdc650dfb1569dd2b8ff5d91a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 13 Oct 2022 23:21:07 +0200 Subject: [PATCH 1/5] sys: remove alias for deprecated sys.RunningInUserNS() The alias is in the 1.6 release, which should give consumers time to migrate. Signed-off-by: Sebastiaan van Stijn --- sys/userns_deprecated.go | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 sys/userns_deprecated.go diff --git a/sys/userns_deprecated.go b/sys/userns_deprecated.go deleted file mode 100644 index 53acf5547..000000000 --- a/sys/userns_deprecated.go +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright The containerd Authors. - - 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 sys - -import "github.com/containerd/containerd/pkg/userns" - -// RunningInUserNS detects whether we are currently running in a user namespace. -// Deprecated: use github.com/containerd/containerd/pkg/userns.RunningInUserNS instead. -var RunningInUserNS = userns.RunningInUserNS From 3e5b444ac403ef6af1080e8528f6a9f34cc447cc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 13 Oct 2022 23:40:28 +0200 Subject: [PATCH 2/5] pkg/cri/util/: remove deprecated NormalizeImageRef alias Has been deprecated in containerd v1.3.0, so we can remove this. Signed-off-by: Sebastiaan van Stijn --- pkg/cri/util/image.go | 33 --------------- pkg/cri/util/image_test.go | 85 -------------------------------------- 2 files changed, 118 deletions(-) delete mode 100644 pkg/cri/util/image.go delete mode 100644 pkg/cri/util/image_test.go diff --git a/pkg/cri/util/image.go b/pkg/cri/util/image.go deleted file mode 100644 index d3abcd31a..000000000 --- a/pkg/cri/util/image.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright The containerd Authors. - - 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 util - -import ( - "github.com/containerd/containerd/reference/docker" -) - -// NormalizeImageRef normalizes the image reference following the docker convention. This is added -// mainly for backward compatibility. -// The reference returned can only be either tagged or digested. For reference contains both tag -// and digest, the function returns digested reference, e.g. docker.io/library/busybox:latest@ -// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as -// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa. -// -// Deprecated: use github.com/containerd/containerd/reference/docker.ParseDockerRef() instead -func NormalizeImageRef(ref string) (docker.Named, error) { - return docker.ParseDockerRef(ref) -} diff --git a/pkg/cri/util/image_test.go b/pkg/cri/util/image_test.go deleted file mode 100644 index 34d3bcd06..000000000 --- a/pkg/cri/util/image_test.go +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright The containerd Authors. - - 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 util - -import ( - "testing" - - "github.com/containerd/containerd/reference" - "github.com/stretchr/testify/assert" -) - -func TestNormalizeImageRef(t *testing.T) { - for _, test := range []struct { - input string - expect string - }{ - { // has nothing - input: "busybox", - expect: "docker.io/library/busybox:latest", - }, - { // only has tag - input: "busybox:latest", - expect: "docker.io/library/busybox:latest", - }, - { // only has digest - input: "busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", - expect: "docker.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", - }, - { // only has path - input: "library/busybox", - expect: "docker.io/library/busybox:latest", - }, - { // only has hostname - input: "docker.io/busybox", - expect: "docker.io/library/busybox:latest", - }, - { // has no tag - input: "docker.io/library/busybox", - expect: "docker.io/library/busybox:latest", - }, - { // has no path - input: "docker.io/busybox:latest", - expect: "docker.io/library/busybox:latest", - }, - { // has no hostname - input: "library/busybox:latest", - expect: "docker.io/library/busybox:latest", - }, - { // full reference - input: "docker.io/library/busybox:latest", - expect: "docker.io/library/busybox:latest", - }, - { // gcr reference - input: "gcr.io/library/busybox", - expect: "gcr.io/library/busybox:latest", - }, - { // both tag and digest - input: "gcr.io/library/busybox:latest@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", - expect: "gcr.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", - }, - } { - t.Run(test.input, func(t *testing.T) { - normalized, err := NormalizeImageRef(test.input) - assert.NoError(t, err) - output := normalized.String() - assert.Equal(t, test.expect, output) - _, err = reference.Parse(output) - assert.NoError(t, err, "%q should be containerd supported reference", output) - }) - } -} From c71a311561c10eaf3a947aaecbd8345770ec6093 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 13 Oct 2022 23:53:59 +0200 Subject: [PATCH 3/5] sys: remove aliases for deprecated EpollCreate1, EpollCtl, EpollWait These have been deprecated since containerd v1.4.0. Signed-off-by: Sebastiaan van Stijn --- sys/epoll.go | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 sys/epoll.go diff --git a/sys/epoll.go b/sys/epoll.go deleted file mode 100644 index 73a57013f..000000000 --- a/sys/epoll.go +++ /dev/null @@ -1,34 +0,0 @@ -//go:build linux -// +build linux - -/* - Copyright The containerd Authors. - - 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 sys - -import "golang.org/x/sys/unix" - -// EpollCreate1 is an alias for unix.EpollCreate1 -// Deprecated: use golang.org/x/sys/unix.EpollCreate1 -var EpollCreate1 = unix.EpollCreate1 - -// EpollCtl is an alias for unix.EpollCtl -// Deprecated: use golang.org/x/sys/unix.EpollCtl -var EpollCtl = unix.EpollCtl - -// EpollWait is an alias for unix.EpollWait -// Deprecated: use golang.org/x/sys/unix.EpollWait -var EpollWait = unix.EpollWait From f0ce2f6d369a35d9b0bf3e6a31404ee3dbfdb9bb Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 13 Oct 2022 23:58:24 +0200 Subject: [PATCH 4/5] remotes/docker: remove deprecated NewAuthorizer alias This was deprecated since containerd v1.3.0. Signed-off-by: Sebastiaan van Stijn --- remotes/docker/authorizer.go | 7 ------- remotes/docker/resolver_test.go | 10 +++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/remotes/docker/authorizer.go b/remotes/docker/authorizer.go index eaa0e5dbd..57479ef63 100644 --- a/remotes/docker/authorizer.go +++ b/remotes/docker/authorizer.go @@ -45,13 +45,6 @@ type dockerAuthorizer struct { onFetchRefreshToken OnFetchRefreshToken } -// NewAuthorizer creates a Docker authorizer using the provided function to -// get credentials for the token server or basic auth. -// Deprecated: Use NewDockerAuthorizer -func NewAuthorizer(client *http.Client, f func(string) (string, string, error)) Authorizer { - return NewDockerAuthorizer(WithAuthClient(client), WithAuthCreds(f)) -} - type authorizerConfig struct { credentials func(string) (string, string, error) client *http.Client diff --git a/remotes/docker/resolver_test.go b/remotes/docker/resolver_test.go index c1311ac0d..4719e75fb 100644 --- a/remotes/docker/resolver_test.go +++ b/remotes/docker/resolver_test.go @@ -68,11 +68,15 @@ func TestBasicResolver(t *testing.T) { }) base, options, close := tlsServer(wrapped) + authorizer := NewDockerAuthorizer( + WithAuthClient(options.Client), + WithAuthCreds(func(host string) (string, string, error) { + return "user1", "password1", nil + }), + ) options.Hosts = ConfigureDefaultRegistries( WithClient(options.Client), - WithAuthorizer(NewAuthorizer(options.Client, func(string) (string, string, error) { - return "user1", "password1", nil - })), + WithAuthorizer(authorizer), ) return base, options, close } From 6142a2a24aa03d552a96429197e2db3b2514a124 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 14 Oct 2022 00:50:24 +0200 Subject: [PATCH 5/5] sys: remove unused GetOpenFds() This was no longer used since 058eea362a94ff8152dc5c62f3c5c2494372e8ba (v1.0.0-alpha0), and there's no external users. Signed-off-by: Sebastiaan van Stijn --- sys/fds.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 sys/fds.go diff --git a/sys/fds.go b/sys/fds.go deleted file mode 100644 index a71a9cd7e..000000000 --- a/sys/fds.go +++ /dev/null @@ -1,35 +0,0 @@ -//go:build !windows && !darwin -// +build !windows,!darwin - -/* - Copyright The containerd Authors. - - 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 sys - -import ( - "os" - "path/filepath" - "strconv" -) - -// GetOpenFds returns the number of open fds for the process provided by pid -func GetOpenFds(pid int) (int, error) { - dirs, err := os.ReadDir(filepath.Join("/proc", strconv.Itoa(pid), "fd")) - if err != nil { - return -1, err - } - return len(dirs), nil -}