Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Edge Agent Docker-mode's handling of create-container request bod…
…y. (Azure#1695) With 5a6d506, the Docker-mode `CreateCommand` has to do a round-trip serialization of the create-container request body to convert it from `Edge.Agent.Docker.Models.CreateContainerParameters` to `Docker.DotNet.Models.CreateContainerParameters`. However, the original definition had a `Name` property that would be serialized into the JSON body as a "Name" field. This is not actually how the property is supposed to be serialized. It's supposed to be transmitted separately as a query-string parameter named "name". The Docker.DotNet type does have a `Name` property, but it's annotated with their custom `QueryStringParameterAttribute` so that it's serialized into the querystring. Because of this mismatch, the round-trip would ignore the field and the resulting object would have `Name = null`, causing Docker to choose a random name. This broke the Docker-mode tests that run in our CI. Technically the `Name` property does not belong in this type, since it ought to represent the request body. However Docker.DotNet has it, and Edge Agent code has been written to use it rather than storing the module name separately. So this commit fixes the state of affairs by leaving the `Name` property in the `Edge.Agent.Docker.Models.CreateContainerParameters` type, but fixing its annotation so that it's ignored rather than serialized. Then, after `Microsoft.Azure.Devices.Edge.Agent.Docker.CreateCommand` does the serialization round-trip, it manually copies the `Name` property over. This also fixes one more test issue I found while running the tests locally. The `TestUdpModuleConfig` test set a single log config and expected to get a single log config back when inspecting the container. But if other log configs were configured in the Docker `daemon.json`, there would be more than one. This change fixes the test to expect at least one log config.
- Loading branch information