File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
5050 }
5151
5252 id := context .Args ().First ()
53+ force := context .Bool ("force" )
5354 container , err := getContainer (context )
5455 if err != nil {
5556 if lerr , ok := err .(libcontainer.Error ); ok && lerr .Code () == libcontainer .ContainerNotExists {
@@ -59,6 +60,9 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
5960 if e := os .RemoveAll (path ); e != nil {
6061 fmt .Fprintf (os .Stderr , "remove %s: %v\n " , path , e )
6162 }
63+ if force {
64+ return nil
65+ }
6266 }
6367 return err
6468 }
@@ -72,7 +76,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
7276 case libcontainer .Created :
7377 return killContainer (container )
7478 default :
75- if context . Bool ( " force" ) {
79+ if force {
7680 return killContainer (container )
7781 } else {
7882 return fmt .Errorf ("cannot delete container %s that is not stopped: %s\n " , id , s )
Original file line number Diff line number Diff line change @@ -46,3 +46,8 @@ function teardown() {
4646 runc state test_busybox
4747 [ " $status " -ne 0 ]
4848}
49+
50+ @test " runc delete --force ignore not exist" {
51+ runc delete --force notexists
52+ [ " $status " -eq 0 ]
53+ }
You can’t perform that action at this time.
0 commit comments