Merge pull request #49559 from thaJeztah/testutil_remove_isErrNotFoundSwarmClassic

testutil: remove isErrNotFoundSwarmClassic
This commit is contained in:
Akihiro Suda
2025-03-04 17:45:15 +09:00
committed by GitHub

View File

@@ -81,7 +81,7 @@ func deleteAllContainers(ctx context.Context, t testing.TB, apiclient client.Con
Force: true,
RemoveVolumes: true,
})
if err == nil || errdefs.IsNotFound(err) || alreadyExists.MatchString(err.Error()) || isErrNotFoundSwarmClassic(err) {
if err == nil || errdefs.IsNotFound(err) || alreadyExists.MatchString(err.Error()) {
continue
}
assert.Check(t, err, "failed to remove %s", ctr.ID)
@@ -140,10 +140,6 @@ func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClien
continue
}
err := c.VolumeRemove(ctx, v.Name, true)
// Docker EE may list volumes that no longer exist.
if isErrNotFoundSwarmClassic(err) {
continue
}
assert.Check(t, err, "failed to remove volume %s", v.Name)
}
}
@@ -186,9 +182,3 @@ func deleteAllPlugins(ctx context.Context, t testing.TB, c client.PluginAPIClien
assert.Check(t, err, "failed to remove plugin %s", p.ID)
}
}
// Swarm classic aggregates node errors and returns a 500 so we need to check
// the error string instead of just IsErrNotFound().
func isErrNotFoundSwarmClassic(err error) bool {
return err != nil && strings.Contains(strings.ToLower(err.Error()), "no such")
}