{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/29463","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/29463/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/29463/comments","events_url":"https://api.github.com/repos/docker/docker/issues/29463/events","html_url":"https://github.com/docker/docker/pull/29463","id":195945885,"number":29463,"title":"Keep `Spec.Networks` and `Spec.TaskTemplate.Networks` consistent","user":{"login":"yongtang","id":6932348,"avatar_url":"https://avatars.githubusercontent.com/u/6932348?v=3","gravatar_id":"","url":"https://api.github.com/users/yongtang","html_url":"https://github.com/yongtang","followers_url":"https://api.github.com/users/yongtang/followers","following_url":"https://api.github.com/users/yongtang/following{/other_user}","gists_url":"https://api.github.com/users/yongtang/gists{/gist_id}","starred_url":"https://api.github.com/users/yongtang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yongtang/subscriptions","organizations_url":"https://api.github.com/users/yongtang/orgs","repos_url":"https://api.github.com/users/yongtang/repos","events_url":"https://api.github.com/users/yongtang/events{/privacy}","received_events_url":"https://api.github.com/users/yongtang/received_events","type":"User","site_admin":false},"labels":[{"id":175375318,"url":"https://api.github.com/repos/docker/docker/labels/status/1-design-review","name":"status/1-design-review","color":"fef2c0","default":false},{"id":408305378,"url":"https://api.github.com/repos/docker/docker/labels/status/needs-vendoring","name":"status/needs-vendoring","color":"bfdadc","default":false}],"state":"closed","locked":false,"assignee":{"login":"stevvooe","id":120601,"avatar_url":"https://avatars.githubusercontent.com/u/120601?v=3","gravatar_id":"","url":"https://api.github.com/users/stevvooe","html_url":"https://github.com/stevvooe","followers_url":"https://api.github.com/users/stevvooe/followers","following_url":"https://api.github.com/users/stevvooe/following{/other_user}","gists_url":"https://api.github.com/users/stevvooe/gists{/gist_id}","starred_url":"https://api.github.com/users/stevvooe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevvooe/subscriptions","organizations_url":"https://api.github.com/users/stevvooe/orgs","repos_url":"https://api.github.com/users/stevvooe/repos","events_url":"https://api.github.com/users/stevvooe/events{/privacy}","received_events_url":"https://api.github.com/users/stevvooe/received_events","type":"User","site_admin":false},"assignees":[{"login":"stevvooe","id":120601,"avatar_url":"https://avatars.githubusercontent.com/u/120601?v=3","gravatar_id":"","url":"https://api.github.com/users/stevvooe","html_url":"https://github.com/stevvooe","followers_url":"https://api.github.com/users/stevvooe/followers","following_url":"https://api.github.com/users/stevvooe/following{/other_user}","gists_url":"https://api.github.com/users/stevvooe/gists{/gist_id}","starred_url":"https://api.github.com/users/stevvooe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevvooe/subscriptions","organizations_url":"https://api.github.com/users/stevvooe/orgs","repos_url":"https://api.github.com/users/stevvooe/repos","events_url":"https://api.github.com/users/stevvooe/events{/privacy}","received_events_url":"https://api.github.com/users/stevvooe/received_events","type":"User","site_admin":false},{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2016-12-15T23:41:08Z","updated_at":"2017-01-26T19:29:30Z","closed_at":"2017-01-26T19:29:30Z","pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/29463","html_url":"https://github.com/docker/docker/pull/29463","diff_url":"https://github.com/docker/docker/pull/29463.diff","patch_url":"https://github.com/docker/docker/pull/29463.patch"},"body":"**- What I did**\r\n\r\nWhile looking into docker issue #28247 to support network update, noticed several potential issues in the current service spec:\r\n\r\n1. ~~When a service is created, the `Networks` in ServiceSpec are always resolved into Network ID. This guarantees the spec for network. However, tt also means when user is doing a `docker service inspect`, the Spec returned is different from the original Spec as network might\r\nbe changed from `foo` to `d928...`.\r\nThis is quite problematic because if user wants to update the network, there is no match for network-add/network-rm. Instead, user will have to perform a network resolve on the client side, then find out which network to remove and which network to add.~~\r\n\r\n2. Currently there are two places for `Networks`. One is in `Spec.TaskTemplate.Networks` and another is in `Spec.Networks`. As was specified in the code comment,  `Spec.Networks` was deprecated and may be removed in the future. However, `Spec.Networks` is still used in case `Spec.TaskTemplate.Networks` is not present.\r\nFurthermore, in the current implementation when networks are resolved, only the `Spec.TaskTemplate.Networks` is updated. Therefore, a `docker service inspect` actually returns the spec with different `Networks` specifications. The value in `Spec.Networks` is the name while `Spec.TaskTemplate.Networks` is the network ID.\r\n\r\n**- How I did it**\r\nThis fix tries to address the problem by:\r\n1. ~~Add a `Name` field in `NetworkAttachmentConfig` to keep a copy of the original network name. `Target` is still the network ID and is still the one being used. But users will get the original network names they provide with `docker service inspect`.~~\r\n2. In docker daemon, when network names are resolved into network IDs, both `Spec.TaskTemplate.Networks` and `Spec.Networks` are updated so that they are always in sync.\r\n\r\nThis fix will help the implementation of #28247.\r\n\r\n**- How to verify it**\r\n\r\nAn integration test has been added.\r\n\r\n**- Description for the changelog**\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n![world-s-cutest-kitten](https://cloud.githubusercontent.com/assets/6932348/21246329/d3f4fc76-c2dc-11e6-8279-804561fd7beb.jpg)\r\n\r\n~~A swarmkit PR has been opened:~~\r\n~~https://github.com/docker/swarmkit/pull/1813~~\r\n\r\nSigned-off-by: Yong Tang <yong.tang.github@outlook.com>"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/275487526","html_url":"https://github.com/docker/docker/pull/29463#issuecomment-275487526","issue_url":"https://api.github.com/repos/docker/docker/issues/29463","id":275487526,"user":{"login":"yongtang","id":6932348,"avatar_url":"https://avatars.githubusercontent.com/u/6932348?v=3","gravatar_id":"","url":"https://api.github.com/users/yongtang","html_url":"https://github.com/yongtang","followers_url":"https://api.github.com/users/yongtang/followers","following_url":"https://api.github.com/users/yongtang/following{/other_user}","gists_url":"https://api.github.com/users/yongtang/gists{/gist_id}","starred_url":"https://api.github.com/users/yongtang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yongtang/subscriptions","organizations_url":"https://api.github.com/users/yongtang/orgs","repos_url":"https://api.github.com/users/yongtang/repos","events_url":"https://api.github.com/users/yongtang/events{/privacy}","received_events_url":"https://api.github.com/users/yongtang/received_events","type":"User","site_admin":false},"created_at":"2017-01-26T19:29:30Z","updated_at":"2017-01-26T19:29:30Z","body":"@aaronlehmann @stevvooe @LK4D4 Sorry forgot to close this PR. Let me close it."}}
{"actor":{"display_login":"yongtang"}}