Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
EnableInfraVnet: enableInfraVnet,
PODName: k8sPodName,
PODNameSpace: k8sNamespace,
SkipHotAttachEp: false, // Hot attach at the time of endpoint creation
}

epPolicies := getPoliciesFromRuntimeCfg(nwCfg)
Expand Down
5 changes: 3 additions & 2 deletions cnm/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ func (plugin *netPlugin) createEndpoint(w http.ResponseWriter, r *http.Request)
}

epInfo := network.EndpointInfo{
Id: req.EndpointID,
IPAddresses: []net.IPNet{*ipv4Address},
Id: req.EndpointID,
IPAddresses: []net.IPNet{*ipv4Address},
SkipHotAttachEp: true, // Skip hot attach endpoint as it's done in Join
}

epInfo.Data = make(map[string]interface{})
Expand Down
1 change: 1 addition & 0 deletions network/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type EndpointInfo struct {
PODNameSpace string
Data map[string]interface{}
InfraVnetAddressSpace string
SkipHotAttachEp bool
}

// RouteInfo contains information about an IP route.
Expand Down
17 changes: 11 additions & 6 deletions network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) {
}
}()

// Attach the endpoint.
log.Printf("[net] Attaching endpoint %v to container %v.", hnsResponse.Id, epInfo.ContainerID)
err = hcsshim.HotAttachEndpoint(epInfo.ContainerID, hnsResponse.Id)
if err != nil {
log.Printf("[net] Failed to attach endpoint: %v.", err)
return nil, err
if epInfo.SkipHotAttachEp {
log.Printf("[net] Skipping attaching the endpoint %v to container %v.",
hnsResponse.Id, epInfo.ContainerID)
} else {
// Attach the endpoint.
log.Printf("[net] Attaching endpoint %v to container %v.", hnsResponse.Id, epInfo.ContainerID)
err = hcsshim.HotAttachEndpoint(epInfo.ContainerID, hnsResponse.Id)
if err != nil {
log.Printf("[net] Failed to attach endpoint: %v.", err)
return nil, err
}
}

// Create the endpoint object.
Expand Down