API v1.20 and up produces an error when signalling / killing a non-running
container (see c92377e300d2e9863ffa8eda9c3166a039b60e09). Older API versions
allowed this, and an exception was added in 621e3d8587bbee86b4e36d0b7822662bfbedd76c.
API v1.23 and older are deprecated, so we can remove this handling.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -248,25 +248,14 @@ func (s *containerRouter) postContainersStop(ctx context.Context, w http.Respons |
| 248 | 248 |
return nil |
| 249 | 249 |
} |
| 250 | 250 |
|
| 251 |
-func (s *containerRouter) postContainersKill(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 251 |
+func (s *containerRouter) postContainersKill(_ context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 252 | 252 |
if err := httputils.ParseForm(r); err != nil {
|
| 253 | 253 |
return err |
| 254 | 254 |
} |
| 255 | 255 |
|
| 256 | 256 |
name := vars["name"] |
| 257 | 257 |
if err := s.backend.ContainerKill(name, r.Form.Get("signal")); err != nil {
|
| 258 |
- var isStopped bool |
|
| 259 |
- if errdefs.IsConflict(err) {
|
|
| 260 |
- isStopped = true |
|
| 261 |
- } |
|
| 262 |
- |
|
| 263 |
- // Return error that's not caused because the container is stopped. |
|
| 264 |
- // Return error if the container is not running and the api is >= 1.20 |
|
| 265 |
- // to keep backwards compatibility. |
|
| 266 |
- version := httputils.VersionFromContext(ctx) |
|
| 267 |
- if versions.GreaterThanOrEqualTo(version, "1.20") || !isStopped {
|
|
| 268 |
- return errors.Wrapf(err, "Cannot kill container: %s", name) |
|
| 269 |
- } |
|
| 258 |
+ return errors.Wrapf(err, "cannot kill container: %s", name) |
|
| 270 | 259 |
} |
| 271 | 260 |
|
| 272 | 261 |
w.WriteHeader(http.StatusNoContent) |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
containertypes "github.com/docker/docker/api/types/container" |
| 9 |
- "github.com/docker/docker/client" |
|
| 10 | 9 |
"github.com/docker/docker/integration/internal/container" |
| 11 | 10 |
"github.com/docker/docker/testutil" |
| 12 | 11 |
"github.com/docker/docker/testutil/request" |
| ... | ... |
@@ -133,15 +132,6 @@ func TestKillStoppedContainer(t *testing.T) {
|
| 133 | 133 |
assert.Assert(t, is.Contains(err.Error(), "is not running")) |
| 134 | 134 |
} |
| 135 | 135 |
|
| 136 |
-func TestKillStoppedContainerAPIPre120(t *testing.T) {
|
|
| 137 |
- skip.If(t, testEnv.DaemonInfo.OSType == "windows", "Windows only supports 1.25 or later") |
|
| 138 |
- ctx := setupTest(t) |
|
| 139 |
- apiClient := request.NewAPIClient(t, client.WithVersion("1.19"))
|
|
| 140 |
- id := container.Create(ctx, t, apiClient) |
|
| 141 |
- err := apiClient.ContainerKill(ctx, id, "SIGKILL") |
|
| 142 |
- assert.NilError(t, err) |
|
| 143 |
-} |
|
| 144 |
- |
|
| 145 | 136 |
func TestKillDifferentUserContainer(t *testing.T) {
|
| 146 | 137 |
// TODO Windows: Windows does not yet support -u (Feb 2016). |
| 147 | 138 |
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "User containers (container.Config.User) are not yet supported on %q platform", testEnv.DaemonInfo.OSType) |