When moving the clean function there, this check was not ported and
generated some errors on the CI. `deleteContainer` now fail if any
error but the clean function won't if "no such container" (because of
some races -_-).
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -1261,7 +1261,7 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs( |
| 1261 | 1261 |
readOnly: true, |
| 1262 | 1262 |
volumes: defaultVolumes(testVol), // Our bind mount is at /vol2 |
| 1263 | 1263 |
}) |
| 1264 |
- defer deleteContainer(false, cID) |
|
| 1264 |
+ defer deleteContainer(cID) |
|
| 1265 | 1265 |
|
| 1266 | 1266 |
// Attempt to extract to a symlink in the volume which points to a |
| 1267 | 1267 |
// directory outside the volume. This should cause an error because the |
| ... | ... |
@@ -42,7 +42,7 @@ func setupImageWithTag(c *check.C, tag string) (digest.Digest, error) {
|
| 42 | 42 |
c.Assert(err, checker.IsNil, check.Commentf("image tagging failed: %s", out))
|
| 43 | 43 |
|
| 44 | 44 |
// delete the container as we don't need it any more |
| 45 |
- err = deleteContainer(false, containerName) |
|
| 45 |
+ err = deleteContainer(containerName) |
|
| 46 | 46 |
c.Assert(err, checker.IsNil) |
| 47 | 47 |
|
| 48 | 48 |
// push the image |
| ... | ... |
@@ -2029,7 +2029,7 @@ func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *check.C) {
|
| 2029 | 2029 |
icmd.RunCommand("iptables", "-D", "DOCKER", "-d", fmt.Sprintf("%s/32", ip),
|
| 2030 | 2030 |
"!", "-i", "docker0", "-o", "docker0", "-p", "tcp", "-m", "tcp", "--dport", "23", "-j", "ACCEPT").Assert(c, icmd.Success) |
| 2031 | 2031 |
|
| 2032 |
- if err := deleteContainer(false, id); err != nil {
|
|
| 2032 |
+ if err := deleteContainer(id); err != nil {
|
|
| 2033 | 2033 |
c.Fatal(err) |
| 2034 | 2034 |
} |
| 2035 | 2035 |
|
| ... | ... |
@@ -36,16 +36,8 @@ func daemonHost() string {
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
// FIXME(vdemeester) move this away are remove ignoreNoSuchContainer bool |
| 39 |
-func deleteContainer(ignoreNoSuchContainer bool, container ...string) error {
|
|
| 40 |
- result := icmd.RunCommand(dockerBinary, append([]string{"rm", "-fv"}, container...)...)
|
|
| 41 |
- if ignoreNoSuchContainer && result.Error != nil {
|
|
| 42 |
- // If the error is "No such container: ..." this means the container doesn't exists anymore, |
|
| 43 |
- // we can safely ignore that one. |
|
| 44 |
- if strings.Contains(result.Stderr(), "No such container") {
|
|
| 45 |
- return nil |
|
| 46 |
- } |
|
| 47 |
- } |
|
| 48 |
- return result.Compare(icmd.Success) |
|
| 39 |
+func deleteContainer(container ...string) error {
|
|
| 40 |
+ return icmd.RunCommand(dockerBinary, append([]string{"rm", "-fv"}, container...)...).Compare(icmd.Success)
|
|
| 49 | 41 |
} |
| 50 | 42 |
|
| 51 | 43 |
func getAllContainers(c *check.C) string {
|
| ... | ... |
@@ -58,7 +50,7 @@ func getAllContainers(c *check.C) string {
|
| 58 | 58 |
func deleteAllContainers(c *check.C) {
|
| 59 | 59 |
containers := getAllContainers(c) |
| 60 | 60 |
if containers != "" {
|
| 61 |
- err := deleteContainer(true, strings.Split(strings.TrimSpace(containers), "\n")...) |
|
| 61 |
+ err := deleteContainer(strings.Split(strings.TrimSpace(containers), "\n")...) |
|
| 62 | 62 |
c.Assert(err, checker.IsNil) |
| 63 | 63 |
} |
| 64 | 64 |
} |
| ... | ... |
@@ -346,7 +338,7 @@ func (f *remoteFileServer) Close() error {
|
| 346 | 346 |
if f.container == "" {
|
| 347 | 347 |
return nil |
| 348 | 348 |
} |
| 349 |
- return deleteContainer(false, f.container) |
|
| 349 |
+ return deleteContainer(f.container) |
|
| 350 | 350 |
} |
| 351 | 351 |
|
| 352 | 352 |
func newRemoteFileServer(c *check.C, ctx *FakeContext) *remoteFileServer {
|
| ... | ... |
@@ -53,7 +53,15 @@ func getPausedContainers(t testingT, dockerBinary string) []string {
|
| 53 | 53 |
func deleteAllContainers(t testingT, dockerBinary string) {
|
| 54 | 54 |
containers := getAllContainers(t, dockerBinary) |
| 55 | 55 |
if len(containers) > 0 {
|
| 56 |
- icmd.RunCommand(dockerBinary, append([]string{"rm", "-fv"}, containers...)...).Assert(t, icmd.Success)
|
|
| 56 |
+ result := icmd.RunCommand(dockerBinary, append([]string{"rm", "-fv"}, containers...)...)
|
|
| 57 |
+ if result.Error != nil {
|
|
| 58 |
+ // If the error is "No such container: ..." this means the container doesn't exists anymore, |
|
| 59 |
+ // we can safely ignore that one. |
|
| 60 |
+ if strings.Contains(result.Stderr(), "No such container") {
|
|
| 61 |
+ return |
|
| 62 |
+ } |
|
| 63 |
+ t.Fatalf("error removing containers %v : %v (%s)", containers, result.Error, result.Combined())
|
|
| 64 |
+ } |
|
| 57 | 65 |
} |
| 58 | 66 |
} |
| 59 | 67 |
|