dynamic: record deprecation for dynamic plugins

Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
Samuel Karp
2023-10-17 23:36:43 -07:00
parent 260e71abc4
commit 079383dbec
5 changed files with 22 additions and 24 deletions

View File

@@ -23,7 +23,7 @@ import "fmt"
// Load is currently only implemented on non-static, non-gccgo builds for amd64
// and arm64, and plugins must be built with the exact same version of Go as
// containerd itself.
func Load(path string) (err error) {
func Load(path string) (loaded int, err error) {
defer func() {
if v := recover(); v != nil {
rerr, ok := v.(error)

View File

@@ -25,12 +25,13 @@ import (
"runtime"
)
// loadPlugins loads all plugins for the OS and Arch
// that containerd is built for inside the provided path
func loadPlugins(path string) error {
// loadPlugins loads all plugins for the OS and Arch that containerd is built
// for inside the provided path and returns the count of successfully-loaded
// plugins
func loadPlugins(path string) (int, error) {
abs, err := filepath.Abs(path)
if err != nil {
return err
return 0, err
}
pattern := filepath.Join(abs, fmt.Sprintf(
"*-%s-%s.%s",
@@ -40,14 +41,16 @@ func loadPlugins(path string) error {
))
libs, err := filepath.Glob(pattern)
if err != nil {
return err
return 0, err
}
loaded := 0
for _, lib := range libs {
if _, err := plugin.Open(lib); err != nil {
return err
return loaded, err
}
loaded++
}
return nil
return loaded, nil
}
// getLibExt returns a platform specific lib extension for

View File

@@ -23,6 +23,6 @@ package dynamic
// - with gccgo: gccgo has no plugin support golang/go#36403
// - on static builds; https://github.com/containerd/containerd/commit/0d682e24a1ba8e93e5e54a73d64f7d256f87492f
// - on architectures other than amd64 and arm64 (other architectures need to be tested)
func loadPlugins(path string) error {
return nil
func loadPlugins(path string) (int, error) {
return 0, nil
}