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
50
50
}
51
51
52
52
id := context .Args ().First ()
53
+ force := context .Bool ("force" )
53
54
container , err := getContainer (context )
54
55
if err != nil {
55
56
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
59
60
if e := os .RemoveAll (path ); e != nil {
60
61
fmt .Fprintf (os .Stderr , "remove %s: %v\n " , path , e )
61
62
}
63
+ if force {
64
+ return nil
65
+ }
62
66
}
63
67
return err
64
68
}
@@ -72,7 +76,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
72
76
case libcontainer .Created :
73
77
return killContainer (container )
74
78
default :
75
- if context . Bool ( " force" ) {
79
+ if force {
76
80
return killContainer (container )
77
81
} else {
78
82
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() {
46
46
runc state test_busybox
47
47
[ " $status " -ne 0 ]
48
48
}
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