2016-11-22 16:49:54 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2017-11-09 10:10:35 +00:00
|
|
|
"time"
|
|
|
|
|
2017-08-05 11:40:46 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2016-11-22 16:49:54 +00:00
|
|
|
"golang.org/x/net/context"
|
2018-02-12 20:13:07 +00:00
|
|
|
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
2016-11-22 16:49:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// StopContainer stops a running container with a grace period (i.e., timeout).
|
2017-11-09 10:10:35 +00:00
|
|
|
func (s *Server) StopContainer(ctx context.Context, req *pb.StopContainerRequest) (resp *pb.StopContainerResponse, err error) {
|
|
|
|
const operation = "stop_container"
|
|
|
|
defer func() {
|
|
|
|
recordOperation(operation, time.Now())
|
|
|
|
recordError(operation, err)
|
|
|
|
}()
|
|
|
|
logrus.Debugf("StopContainerRequest %+v", req)
|
|
|
|
|
|
|
|
_, err = s.ContainerServer.ContainerStop(ctx, req.ContainerId, req.Timeout)
|
2016-11-22 16:49:54 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:10:35 +00:00
|
|
|
resp = &pb.StopContainerResponse{}
|
2017-08-30 20:03:26 +00:00
|
|
|
logrus.Debugf("StopContainerResponse %s: %+v", req.ContainerId, resp)
|
2016-11-22 16:49:54 +00:00
|
|
|
return resp, nil
|
|
|
|
}
|