From f8bf690ea1bce02c9e9801354925d3975dda12df Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 4 May 2026 16:02:09 +0200 Subject: [PATCH] vendor: github.com/containerd/plugin v1.1.0 - Simply handling of disabled and added plugins - Fix comparison of children in graph generation - Add check for plugin requiring itself - Fix circular dependency detection full diff: https://github.com/containerd/plugin/compare/v1.0.0...v1.1.0 Signed-off-by: Sebastiaan van Stijn --- go.mod | 2 +- go.sum | 4 +- .../containerd/plugin/.golangci.yml | 61 ++++++++++++------- vendor/github.com/containerd/plugin/plugin.go | 47 ++++++++------ vendor/modules.txt | 4 +- 5 files changed, 72 insertions(+), 46 deletions(-) diff --git a/go.mod b/go.mod index 8ab11ffa60..bce53ba023 100644 --- a/go.mod +++ b/go.mod @@ -163,7 +163,7 @@ require ( github.com/containerd/go-cni v1.1.13 // indirect github.com/containerd/go-runc v1.1.0 // indirect github.com/containerd/nydus-snapshotter v0.15.15 // indirect - github.com/containerd/plugin v1.0.0 // indirect + github.com/containerd/plugin v1.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect github.com/containerd/ttrpc v1.2.9 // indirect github.com/containernetworking/cni v1.3.0 // indirect diff --git a/go.sum b/go.sum index 51696846a5..dcd354d7bc 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/containerd/nydus-snapshotter v0.15.15 h1:kVYbFpYA4K43qxGVoc/VBwRXLAVW github.com/containerd/nydus-snapshotter v0.15.15/go.mod h1:L96yO+4iE6qqDiqXKhxMXBoPeaE7JgzXir9yanUVuOY= github.com/containerd/platforms v1.0.0-rc.4 h1:M42JrUT4zfZTqtkUwkr0GzmUWbfyO5VO0Q5b3op97T4= github.com/containerd/platforms v1.0.0-rc.4/go.mod h1:lKlMXyLybmBedS/JJm11uDofzI8L2v0J2ZbYvNsbq1A= -github.com/containerd/plugin v1.0.0 h1:c8Kf1TNl6+e2TtMHZt+39yAPDbouRH9WAToRjex483Y= -github.com/containerd/plugin v1.0.0/go.mod h1:hQfJe5nmWfImiqT1q8Si3jLv3ynMUIBB47bQ+KexvO8= +github.com/containerd/plugin v1.1.0 h1:O+7lczNJVMy8rz0YNx3xGB8tTf5qY4i5abF041Ew19U= +github.com/containerd/plugin v1.1.0/go.mod h1:qBTum+A8lJ6lO44A19Eo7y1OlcLj4OWFH1DA/vnHmcc= github.com/containerd/stargz-snapshotter/estargz v0.18.2 h1:yXkZFYIzz3eoLwlTUZKz2iQ4MrckBxJjkmD16ynUTrw= github.com/containerd/stargz-snapshotter/estargz v0.18.2/go.mod h1:XyVU5tcJ3PRpkA9XS2T5us6Eg35yM0214Y+wvrZTBrY= github.com/containerd/ttrpc v1.2.9 h1:ha0ak962T0s3CA/RoZ6S6xiWZQF24GrBaEpiGX1uihg= diff --git a/vendor/github.com/containerd/plugin/.golangci.yml b/vendor/github.com/containerd/plugin/.golangci.yml index d574fe11d7..d02cfb8f1d 100644 --- a/vendor/github.com/containerd/plugin/.golangci.yml +++ b/vendor/github.com/containerd/plugin/.golangci.yml @@ -1,32 +1,49 @@ +version: "2" linters: enable: - copyloopvar - - gofmt - - goimports + - dupword - gosec - - ineffassign - misspell - nolintlint - revive - - staticcheck - - tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17 - unconvert - - unused - - govet - - dupword # Checks for duplicate words in the source code disable: - errcheck - -run: - timeout: 5m - -issues: - exclude-dirs: - - api - - cluster - - design - - docs - - docs/man - - releases - - reports - - test # e2e scripts + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - api + - cluster + - design + - docs + - docs/man + - releases + - reports + - test + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - api + - cluster + - design + - docs + - docs/man + - releases + - reports + - test + - third_party$ + - builtin$ + - examples$ diff --git a/vendor/github.com/containerd/plugin/plugin.go b/vendor/github.com/containerd/plugin/plugin.go index f7899e184f..e31b221c5c 100644 --- a/vendor/github.com/containerd/plugin/plugin.go +++ b/vendor/github.com/containerd/plugin/plugin.go @@ -39,6 +39,8 @@ var ( ErrPluginNotFound = errors.New("plugin: not found") // ErrPluginMultipleInstances is used when a plugin is expected a single instance but has multiple ErrPluginMultipleInstances = errors.New("plugin: multiple instances") + // ErrPluginCircularDependency is used when the graph detect a circular plugin dependency + ErrPluginCircularDependency = errors.New("plugin: dependency loop detected") // ErrInvalidRequires will be thrown if the requirements for a plugin are // defined in an invalid manner. @@ -110,36 +112,43 @@ type Registry []*Registration // Graph computes the ordered list of registrations based on their dependencies, // filtering out any plugins which match the provided filter. func (registry Registry) Graph(filter DisableFilter) []Registration { - disabled := map[*Registration]bool{} - for _, r := range registry { - if filter(r) { - disabled[r] = true + handled := make(map[*Registration]struct{}, len(registry)) + if filter != nil { + for _, r := range registry { + if filter(r) { + handled[r] = struct{}{} + } } } - ordered := make([]Registration, 0, len(registry)-len(disabled)) - added := map[*Registration]bool{} + ordered := make([]Registration, 0, len(registry)-len(handled)) + stack := make([]*Registration, 0, cap(ordered)) for _, r := range registry { - if disabled[r] { + if _, ok := handled[r]; ok { continue } - children(r, registry, added, disabled, &ordered) - if !added[r] { - ordered = append(ordered, *r) - added[r] = true - } + children(append(stack, r), registry, handled, &ordered) + handled[r] = struct{}{} + ordered = append(ordered, *r) } return ordered } -func children(reg *Registration, registry []*Registration, added, disabled map[*Registration]bool, ordered *[]Registration) { +func children(stack []*Registration, registry []*Registration, handled map[*Registration]struct{}, ordered *[]Registration) { + reg := stack[len(stack)-1] for _, t := range reg.Requires { for _, r := range registry { - if !disabled[r] && r.URI() != reg.URI() && (t == "*" || r.Type == t) { - children(r, registry, added, disabled, ordered) - if !added[r] { + if (t == "*" || r.Type == t) && r != reg { + if _, ok := handled[r]; !ok { + // Ensure not in current stack + for _, p := range stack[:len(stack)-1] { + if p == r { + panic(fmt.Errorf("circular plugin dependency at %s: %w", r.URI(), ErrPluginCircularDependency)) + } + } + children(append(stack, r), registry, handled, ordered) + handled[r] = struct{}{} *ordered = append(*ordered, *r) - added[r] = true } } } @@ -160,7 +169,7 @@ func (registry Registry) Register(r *Registration) Registry { } for _, requires := range r.Requires { - if requires == "*" && len(r.Requires) != 1 { + if (requires == "*" && len(r.Requires) != 1) || requires == r.Type { panic(ErrInvalidRequires) } } @@ -170,7 +179,7 @@ func (registry Registry) Register(r *Registration) Registry { func checkUnique(registry Registry, r *Registration) error { for _, registered := range registry { - if r.URI() == registered.URI() { + if r.Type == registered.Type && r.ID == registered.ID { return fmt.Errorf("%s: %w", r.URI(), ErrIDRegistered) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index b6969284d7..e91c480414 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -531,8 +531,8 @@ github.com/containerd/nydus-snapshotter/pkg/label # github.com/containerd/platforms v1.0.0-rc.4 ## explicit; go 1.24 github.com/containerd/platforms -# github.com/containerd/plugin v1.0.0 -## explicit; go 1.20 +# github.com/containerd/plugin v1.1.0 +## explicit; go 1.22 github.com/containerd/plugin # github.com/containerd/stargz-snapshotter/estargz v0.18.2 ## explicit; go 1.24.0