Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic: expose count of loaded plugins #3

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions dynamic/dynamic_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (

// loadPlugins loads all plugins for the OS and Arch
// that containerd is built for inside the provided path
func loadPlugins(path string) error {
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",
Expand All @@ -40,14 +40,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
Expand Down
4 changes: 2 additions & 2 deletions dynamic/dynamic_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading