fix high performance hook self-exit container issue
@@ -9,6 +9,7 @@ import (
"github.com/cri-o/cri-o/internal/lib/sandbox"
"github.com/cri-o/cri-o/internal/log"
oci "github.com/cri-o/cri-o/internal/oci"
+ "github.com/cri-o/cri-o/internal/runtimehandlerhooks"
"github.com/pkg/errors"
"golang.org/x/net/context"
"golang.org/x/sync/errgroup"
@@ -41,6 +42,9 @@ func (s *Server) stopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
return nil, err
}
+ // Get high-performance runtime hook to trigger preStop step for each container
+ hooks := runtimehandlerhooks.GetRuntimeHandlerHooks(sb.RuntimeHandler())
+
if sb.Stopped() {
log.Infof(ctx, "Stopped pod sandbox (already stopped): %s", sb.ID())
return resp, nil
@@ -80,6 +84,11 @@ func (s *Server) stopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
return nil
})
}
+ if hooks != nil {
+ if err := hooks.PreStop(ctx, ctr, sb); err != nil {
+ log.Warnf(ctx, "failed to run PreStop hook for container %s in pod sandbox %s: %v", ctr.Name(), sb.ID(), err)
+ }
+ }
}
if err := waitGroup.Wait(); err != nil {
return nil, err
