Skip to content

Commit

Permalink
plugins: update plugins for stub changes.
Browse files Browse the repository at this point in the history
Update plugin event handlers with the updated stub
interfaces.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
  • Loading branch information
klihub committed May 22, 2023
1 parent b4bd301 commit f5d0f51
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion plugins/device-injector/device-injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type plugin struct {
}

// CreateContainer handles container creation requests.
func (p *plugin) CreateContainer(pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
func (p *plugin) CreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
var (
ctrName string
devices []device
Expand Down
28 changes: 14 additions & 14 deletions plugins/differ/nri-differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
indices map[int]pluginIndex
)

func (p *plugin) Configure(nriCfg string) (stub.EventMask, error) {
func (p *plugin) Configure(_ context.Context, nriCfg string) (stub.EventMask, error) {
log.Infof("got configuration data: %q", nriCfg)
if nriCfg == "" {
return p.mask, nil
Expand Down Expand Up @@ -177,74 +177,74 @@ func (p *plugin) differ(apifunc string, pod *api.PodSandbox, container *api.Cont
}
}

func (p *plugin) Synchronize(pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) Synchronize(_ context.Context, pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
if cfg.VerboseLevel > 2 {
p.dump("Synchronize", "pods", pods, "containers", containers)
}

return nil, nil
}

func (p *plugin) Shutdown() {
func (p *plugin) Shutdown(_ context.Context) {
p.dump("Shutdown")
}

func (p *plugin) RunPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error {
p.differ("RunPodSandbox", pod, nil)
return nil
}

func (p *plugin) StopPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) StopPodSandbox(_ context.Context, pod *api.PodSandbox) error {
p.differ("StopPodSandbox", pod, nil)
return nil
}

func (p *plugin) RemovePodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RemovePodSandbox(_ context.Context, pod *api.PodSandbox) error {
p.differ("RemovePodSandbox", pod, nil)
return nil
}

func (p *plugin) CreateContainer(pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
func (p *plugin) CreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
p.differ("CreateContainer", pod, container)

adjust := &api.ContainerAdjustment{}

return adjust, nil, nil
}

func (p *plugin) PostCreateContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostCreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
p.differ("PostCreateContainer", pod, container)
return nil
}

func (p *plugin) StartContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) StartContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
p.differ("StartContainer", pod, container)
return nil
}

func (p *plugin) PostStartContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostStartContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
p.differ("PostStartContainer", pod, container)
return nil
}

func (p *plugin) UpdateContainer(pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) UpdateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
p.differ("UpdateContainer", pod, container)

return nil, nil
}

func (p *plugin) PostUpdateContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostUpdateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
p.differ("PostUpdateContainer", pod, container)
return nil
}

func (p *plugin) StopContainer(pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) StopContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
p.differ("StopContainer", pod, container)

return nil, nil
}

func (p *plugin) RemoveContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) RemoveContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
p.differ("RemoveContainer", pod, container)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/hook-injector/hook-injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type plugin struct {
mgr *hooks.Manager
}

func (p *plugin) CreateContainer(pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
func (p *plugin) CreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
ctrName := containerName(pod, container)

if verbose {
Expand Down
26 changes: 13 additions & 13 deletions plugins/logger/nri-logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
_ = stub.ConfigureInterface(&plugin{})
)

func (p *plugin) Configure(config, runtime, version string) (stub.EventMask, error) {
func (p *plugin) Configure(_ context.Context, config, runtime, version string) (stub.EventMask, error) {
log.Infof("got configuration data: %q from runtime %s %s", config, runtime, version)
if config == "" {
return p.mask, nil
Expand Down Expand Up @@ -79,7 +79,7 @@ func (p *plugin) Configure(config, runtime, version string) (stub.EventMask, err
return p.mask, nil
}

func (p *plugin) Synchronize(pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) Synchronize(_ context.Context, pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
dump("Synchronize", "pods", pods, "containers", containers)
return nil, nil
}
Expand All @@ -88,22 +88,22 @@ func (p *plugin) Shutdown() {
dump("Shutdown")
}

func (p *plugin) RunPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error {
dump("RunPodSandbox", "pod", pod)
return nil
}

func (p *plugin) StopPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) StopPodSandbox(_ context.Context, pod *api.PodSandbox) error {
dump("StopPodSandbox", "pod", pod)
return nil
}

func (p *plugin) RemovePodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RemovePodSandbox(_ context.Context, pod *api.PodSandbox) error {
dump("RemovePodSandbox", "pod", pod)
return nil
}

func (p *plugin) CreateContainer(pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
func (p *plugin) CreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
dump("CreateContainer", "pod", pod, "container", container)

adjust := &api.ContainerAdjustment{}
Expand All @@ -126,37 +126,37 @@ func (p *plugin) CreateContainer(pod *api.PodSandbox, container *api.Container)
return adjust, nil, nil
}

func (p *plugin) PostCreateContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostCreateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
dump("PostCreateContainer", "pod", pod, "container", container)
return nil
}

func (p *plugin) StartContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) StartContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
dump("StartContainer", "pod", pod, "container", container)
return nil
}

func (p *plugin) PostStartContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostStartContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
dump("PostStartContainer", "pod", pod, "container", container)
return nil
}

func (p *plugin) UpdateContainer(pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) UpdateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
dump("UpdateContainer", "pod", pod, "container", container)
return nil, nil
}

func (p *plugin) PostUpdateContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) PostUpdateContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
dump("PostUpdateContainer", "pod", pod, "container", container)
return nil
}

func (p *plugin) StopContainer(pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) StopContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) ([]*api.ContainerUpdate, error) {
dump("StopContainer", "pod", pod, "container", container)
return nil, nil
}

func (p *plugin) RemoveContainer(pod *api.PodSandbox, container *api.Container) error {
func (p *plugin) RemoveContainer(_ context.Context, pod *api.PodSandbox, container *api.Container) error {
dump("RemoveContainer", "pod", pod, "container", container)
return nil
}
Expand Down
28 changes: 14 additions & 14 deletions plugins/template/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
log *logrus.Logger
)

func (p *plugin) Configure(config, runtime, version string) (stub.EventMask, error) {
func (p *plugin) Configure(_ context.Context, config, runtime, version string) (stub.EventMask, error) {
log.Infof("Connected to %s/%s...", runtime, version)

if config == "" {
Expand All @@ -60,31 +60,31 @@ func (p *plugin) Configure(config, runtime, version string) (stub.EventMask, err
return 0, nil
}

func (p *plugin) Synchronize(pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) Synchronize(_ context.Context, pods []*api.PodSandbox, containers []*api.Container) ([]*api.ContainerUpdate, error) {
log.Info("Synchronizing state with the runtime...")
return nil, nil
}

func (p *plugin) Shutdown() {
func (p *plugin) Shutdown(_ context.Context) {
log.Info("Runtime shutting down...")
}

func (p *plugin) RunPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error {
log.Infof("Started pod %s/%s...", pod.GetNamespace(), pod.GetName())
return nil
}

func (p *plugin) StopPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) StopPodSandbox(_ context.Context, pod *api.PodSandbox) error {
log.Infof("Stopped pod %s/%s...", pod.GetNamespace(), pod.GetName())
return nil
}

func (p *plugin) RemovePodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RemovePodSandbox(_ context.Context, pod *api.PodSandbox) error {
log.Infof("Removed pod %s/%s...", pod.GetNamespace(), pod.GetName())
return nil
}

func (p *plugin) CreateContainer(pod *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
func (p *plugin) CreateContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
log.Infof("Creating container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())

//
Expand All @@ -105,22 +105,22 @@ func (p *plugin) CreateContainer(pod *api.PodSandbox, ctr *api.Container) (*api.
return adjustment, updates, nil
}

func (p *plugin) PostCreateContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) PostCreateContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Created container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())
return nil
}

func (p *plugin) StartContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) StartContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Starting container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())
return nil
}

func (p *plugin) PostStartContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) PostStartContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Started container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())
return nil
}

func (p *plugin) UpdateContainer(pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) UpdateContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
log.Infof("Updating container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())

//
Expand All @@ -137,12 +137,12 @@ func (p *plugin) UpdateContainer(pod *api.PodSandbox, ctr *api.Container) ([]*ap
return updates, nil
}

func (p *plugin) PostUpdateContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) PostUpdateContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Updated container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())
return nil
}

func (p *plugin) StopContainer(pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) StopContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
log.Infof("Stopped container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())

//
Expand All @@ -154,7 +154,7 @@ func (p *plugin) StopContainer(pod *api.PodSandbox, ctr *api.Container) ([]*api.
return []*api.ContainerUpdate{}, nil
}

func (p *plugin) RemoveContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) RemoveContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Removed container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/v010-adapter/v010-adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ var (
log *logrus.Logger
)

func (p *plugin) Configure(config, runtime, version string) (stub.EventMask, error) {
func (p *plugin) Configure(_ context.Context, config, runtime, version string) (stub.EventMask, error) {
log.Infof("Connected to %s/%s...", runtime, version)
return 0, nil
}

func (p *plugin) Shutdown() {
func (p *plugin) Shutdown(_ context.Context) {
log.Info("Runtime shutting down...")
}

func (p *plugin) RunPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error {
log.Infof("Started pod %s/%s...", pod.GetNamespace(), pod.GetName())

nric, err := nri.New()
Expand All @@ -72,7 +72,7 @@ func (p *plugin) RunPodSandbox(pod *api.PodSandbox) error {
return nil
}

func (p *plugin) StopPodSandbox(pod *api.PodSandbox) error {
func (p *plugin) StopPodSandbox(_ context.Context, pod *api.PodSandbox) error {
log.Infof("Stopped pod %s/%s...", pod.GetNamespace(), pod.GetName())

nric, err := nri.New()
Expand All @@ -97,7 +97,7 @@ func (p *plugin) StopPodSandbox(pod *api.PodSandbox) error {
return nil
}

func (p *plugin) StartContainer(pod *api.PodSandbox, ctr *api.Container) error {
func (p *plugin) StartContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) error {
log.Infof("Starting container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())

nric, err := nri.New()
Expand All @@ -122,7 +122,7 @@ func (p *plugin) StartContainer(pod *api.PodSandbox, ctr *api.Container) error {
return nil
}

func (p *plugin) StopContainer(pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
func (p *plugin) StopContainer(_ context.Context, pod *api.PodSandbox, ctr *api.Container) ([]*api.ContainerUpdate, error) {
log.Infof("Stopped container %s/%s/%s...", pod.GetNamespace(), pod.GetName(), ctr.GetName())

nric, err := nri.New()
Expand Down

0 comments on commit f5d0f51

Please sign in to comment.