Signed-off-by: Madhan Raj Mookkandy <madhanm@microsoft.com>
| ... | ... |
@@ -107,7 +107,8 @@ type Container struct {
|
| 107 | 107 |
NoNewPrivileges bool |
| 108 | 108 |
|
| 109 | 109 |
// Fields here are specific to Windows |
| 110 |
- NetworkSharedContainerID string |
|
| 110 |
+ NetworkSharedContainerID string `json:"-"` |
|
| 111 |
+ SharedEndpointList []string `json:"-"` |
|
| 111 | 112 |
} |
| 112 | 113 |
|
| 113 | 114 |
// NewBaseContainer creates a new container with its |
| ... | ... |
@@ -886,7 +886,12 @@ func (daemon *Daemon) initializeNetworking(container *container.Container) error |
| 886 | 886 |
if err != nil {
|
| 887 | 887 |
return err |
| 888 | 888 |
} |
| 889 |
- initializeNetworkingPaths(container, nc) |
|
| 889 |
+ |
|
| 890 |
+ err = daemon.initializeNetworkingPaths(container, nc) |
|
| 891 |
+ if err != nil {
|
|
| 892 |
+ return err |
|
| 893 |
+ } |
|
| 894 |
+ |
|
| 890 | 895 |
container.Config.Hostname = nc.Config.Hostname |
| 891 | 896 |
container.Config.Domainname = nc.Config.Domainname |
| 892 | 897 |
return nil |
| ... | ... |
@@ -42,5 +42,6 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[] |
| 42 | 42 |
return nil |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
-func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
|
|
| 45 |
+func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
|
|
| 46 |
+ return nil |
|
| 46 | 47 |
} |
| ... | ... |
@@ -349,8 +349,9 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[] |
| 349 | 349 |
return nil |
| 350 | 350 |
} |
| 351 | 351 |
|
| 352 |
-func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
|
|
| 352 |
+func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
|
|
| 353 | 353 |
container.HostnamePath = nc.HostnamePath |
| 354 | 354 |
container.HostsPath = nc.HostsPath |
| 355 | 355 |
container.ResolvConfPath = nc.ResolvConfPath |
| 356 |
+ return nil |
|
| 356 | 357 |
} |
| ... | ... |
@@ -160,6 +160,43 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[] |
| 160 | 160 |
return nil |
| 161 | 161 |
} |
| 162 | 162 |
|
| 163 |
-func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
|
|
| 163 |
+func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
|
|
| 164 |
+ |
|
| 165 |
+ if nc.HostConfig.Isolation.IsHyperV() {
|
|
| 166 |
+ return fmt.Errorf("sharing of hyperv containers network is not supported")
|
|
| 167 |
+ } |
|
| 168 |
+ |
|
| 164 | 169 |
container.NetworkSharedContainerID = nc.ID |
| 170 |
+ |
|
| 171 |
+ if nc.NetworkSettings != nil {
|
|
| 172 |
+ for n := range nc.NetworkSettings.Networks {
|
|
| 173 |
+ sn, err := daemon.FindNetwork(n) |
|
| 174 |
+ if err != nil {
|
|
| 175 |
+ continue |
|
| 176 |
+ } |
|
| 177 |
+ |
|
| 178 |
+ ep, err := nc.GetEndpointInNetwork(sn) |
|
| 179 |
+ if err != nil {
|
|
| 180 |
+ continue |
|
| 181 |
+ } |
|
| 182 |
+ |
|
| 183 |
+ data, err := ep.DriverInfo() |
|
| 184 |
+ if err != nil {
|
|
| 185 |
+ continue |
|
| 186 |
+ } |
|
| 187 |
+ |
|
| 188 |
+ if data["GW_INFO"] != nil {
|
|
| 189 |
+ gwInfo := data["GW_INFO"].(map[string]interface{})
|
|
| 190 |
+ if gwInfo["hnsid"] != nil {
|
|
| 191 |
+ container.SharedEndpointList = append(container.SharedEndpointList, gwInfo["hnsid"].(string)) |
|
| 192 |
+ } |
|
| 193 |
+ } |
|
| 194 |
+ |
|
| 195 |
+ if data["hnsid"] != nil {
|
|
| 196 |
+ container.SharedEndpointList = append(container.SharedEndpointList, data["hnsid"].(string)) |
|
| 197 |
+ } |
|
| 198 |
+ } |
|
| 199 |
+ } |
|
| 200 |
+ |
|
| 201 |
+ return nil |
|
| 165 | 202 |
} |
| ... | ... |
@@ -150,7 +150,11 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 150 | 150 |
var networkSharedContainerID string |
| 151 | 151 |
if container.HostConfig.NetworkMode.IsContainer() {
|
| 152 | 152 |
networkSharedContainerID = container.NetworkSharedContainerID |
| 153 |
+ for _, ep := range container.SharedEndpointList {
|
|
| 154 |
+ epList = append(epList, ep) |
|
| 155 |
+ } |
|
| 153 | 156 |
} |
| 157 |
+ |
|
| 154 | 158 |
createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{
|
| 155 | 159 |
Endpoints: epList, |
| 156 | 160 |
AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery, |