@@ -94,6 +94,13 @@ var stopContainerCommand = cli.Command{
94
94
Name : "stop" ,
95
95
Usage : "Stop a running container" ,
96
96
ArgsUsage : "CONTAINER" ,
97
+ Flags : []cli.Flag {
98
+ cli.Int64Flag {
99
+ Name : "timeout, t" ,
100
+ Value : 10 ,
101
+ Usage : "Seconds to wait to kill the container after a graceful stop is requested" ,
102
+ },
103
+ },
97
104
Action : func (context * cli.Context ) error {
98
105
containerID := context .Args ().First ()
99
106
if containerID == "" {
@@ -104,7 +111,7 @@ var stopContainerCommand = cli.Command{
104
111
return err
105
112
}
106
113
107
- err := StopContainer (runtimeClient , containerID )
114
+ err := StopContainer (runtimeClient , containerID , context . Int64 ( "timeout" ) )
108
115
if err != nil {
109
116
return fmt .Errorf ("Stopping the container failed: %v" , err )
110
117
}
@@ -280,12 +287,13 @@ func StartContainer(client pb.RuntimeServiceClient, ID string) error {
280
287
281
288
// StopContainer sends a StopContainerRequest to the server, and parses
282
289
// the returned StopContainerResponse.
283
- func StopContainer (client pb.RuntimeServiceClient , ID string ) error {
290
+ func StopContainer (client pb.RuntimeServiceClient , ID string , timeout int64 ) error {
284
291
if ID == "" {
285
292
return fmt .Errorf ("ID cannot be empty" )
286
293
}
287
294
request := & pb.StopContainerRequest {
288
295
ContainerId : ID ,
296
+ Timeout : timeout ,
289
297
}
290
298
logrus .Debugf ("StopContainerRequest: %v" , request )
291
299
r , err := client .StopContainer (context .Background (), request )
0 commit comments