mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
api: Deprecate response fields from GET /containers/{id}/json
The Docker API 1.44 deprecates the fields HairpinMode, LinkLocalIPv6Address,
LinkLocalIPv6PrefixLen, SecondaryIPAddresses, SecondaryIPv6Addresses available in
NetworkSettings when calling GET /containers/{id}/json and will be removed in a future release.
You should instead look for the default network in NetworkSettings.Networks.
The fields are removed in 1.52. Version gate SecondaryIPAddresses, SecondaryIPv6Addresses
in the handler and update test. HairpinMode, LinkLocalIPv6Address, LinkLocalIPv6PrefixLen
are not returned by the compat endpoint as the response is serialized
to the moby/moby/api structure missing these fields.
Fixes: https://redhat.atlassian.net/browse/RUN-3323
Signed-off-by: Marek Simek <msimek@redhat.com>
This commit is contained in:
parent
f4925bae8c
commit
612c7b71b4
2 changed files with 17 additions and 2 deletions
|
|
@ -212,6 +212,12 @@ func GetContainer(w http.ResponseWriter, r *http.Request) {
|
|||
utils.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
if _, err := utils.SupportedVersion(r, ">=1.52.0"); err == nil || errors.Is(err, apiutil.ErrVersionNotGiven) {
|
||||
if api.NetworkSettings != nil {
|
||||
api.NetworkSettings.SecondaryIPAddresses = nil
|
||||
api.NetworkSettings.SecondaryIPv6Addresses = nil
|
||||
}
|
||||
}
|
||||
utils.WriteResponse(w, http.StatusOK, api)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -535,13 +535,22 @@ class ContainerCompatibleAPITestCase(APITestCase):
|
|||
r = requests.post(self.uri(self.resolve_container("/containers/{}/start")))
|
||||
self.assertIn(r.status_code, (204, 304), r.text)
|
||||
|
||||
r = requests.get(self.compat_uri(self.resolve_container("/containers/{}/json")))
|
||||
container_uri = self.resolve_container("/containers/{}/json")
|
||||
|
||||
# SecondaryIPAddresses present for API < v1.52
|
||||
r = requests.get(self.podman_url + "/v1.44/" + container_uri)
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
self.assertId(r.content)
|
||||
out = r.json()
|
||||
|
||||
self.assertEqual("10.0.2.0", out["NetworkSettings"]["SecondaryIPAddresses"][0]["Addr"])
|
||||
self.assertEqual(24, out["NetworkSettings"]["SecondaryIPAddresses"][0]["PrefixLen"])
|
||||
|
||||
# SecondaryIPAddresses removed for API >= v1.52
|
||||
r = requests.get(self.podman_url + "/v1.52/" + container_uri)
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
self.assertId(r.content)
|
||||
out = r.json()
|
||||
self.assertIsNone(out["NetworkSettings"].get("SecondaryIPAddresses"))
|
||||
finally:
|
||||
delete_named_network_ns(network_ns_name)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue