server: get hooks after we've check if a sandbox is already stopped
@@ -25,17 +25,17 @@ func (s *Server) stopPodSandbox(ctx context.Context, sb *sandbox.Sandbox) error
return err
}
+ if sb.Stopped() {
+ log.Infof(ctx, "Stopped pod sandbox (already stopped): %s", sb.ID())
+ return nil
+ }
+
// Get high-performance runtime hook to trigger preStop step for each container
hooks, err := runtimehandlerhooks.GetRuntimeHandlerHooks(ctx, &s.config, sb.RuntimeHandler(), sb.Annotations())
if err != nil {
return fmt.Errorf("failed to get runtime handler %q hooks", sb.RuntimeHandler())
}
- if sb.Stopped() {
- log.Infof(ctx, "Stopped pod sandbox (already stopped): %s", sb.ID())
- return nil
- }
-
podInfraContainer := sb.InfraContainer()
containers := sb.Containers().List()
containers = append(containers, podInfraContainer)
