2016-11-22 17:49:54 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2017-11-09 11:10:35 +01:00
|
|
|
"time"
|
|
|
|
|
2017-08-05 07:40:46 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2016-11-22 17:49:54 +01:00
|
|
|
"golang.org/x/net/context"
|
2017-08-04 13:13:19 +02:00
|
|
|
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
2016-11-22 17:49:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// StopContainer stops a running container with a grace period (i.e., timeout).
|
2017-11-09 11:10:35 +01: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 17:49:54 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2017-11-09 11:10:35 +01:00
|
|
|
resp = &pb.StopContainerResponse{}
|
2017-08-30 16:03:26 -04:00
|
|
|
logrus.Debugf("StopContainerResponse %s: %+v", req.ContainerId, resp)
|
2016-11-22 17:49:54 +01:00
|
|
|
return resp, nil
|
|
|
|
}
|