Skip HotAttachEp from CNM createEndpoint (#332)

* Skip HotAttachEp from CNM create endpoint

* Address review comments
This commit is contained in:
Ashvin Deodhar 2019-04-12 16:17:45 -07:00 коммит произвёл GitHub
Родитель a1f804a912
Коммит e28f5836d0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -452,6 +452,7 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
EnableInfraVnet: enableInfraVnet, EnableInfraVnet: enableInfraVnet,
PODName: k8sPodName, PODName: k8sPodName,
PODNameSpace: k8sNamespace, PODNameSpace: k8sNamespace,
SkipHotAttachEp: false, // Hot attach at the time of endpoint creation
} }
epPolicies := getPoliciesFromRuntimeCfg(nwCfg) epPolicies := getPoliciesFromRuntimeCfg(nwCfg)

Просмотреть файл

@ -229,8 +229,9 @@ func (plugin *netPlugin) createEndpoint(w http.ResponseWriter, r *http.Request)
} }
epInfo := network.EndpointInfo{ epInfo := network.EndpointInfo{
Id: req.EndpointID, Id: req.EndpointID,
IPAddresses: []net.IPNet{*ipv4Address}, IPAddresses: []net.IPNet{*ipv4Address},
SkipHotAttachEp: true, // Skip hot attach endpoint as it's done in Join
} }
epInfo.Data = make(map[string]interface{}) epInfo.Data = make(map[string]interface{})

Просмотреть файл

@ -61,6 +61,7 @@ type EndpointInfo struct {
PODNameSpace string PODNameSpace string
Data map[string]interface{} Data map[string]interface{}
InfraVnetAddressSpace string InfraVnetAddressSpace string
SkipHotAttachEp bool
} }
// RouteInfo contains information about an IP route. // RouteInfo contains information about an IP route.

Просмотреть файл

@ -94,12 +94,17 @@ func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) {
} }
}() }()
// Attach the endpoint. if epInfo.SkipHotAttachEp {
log.Printf("[net] Attaching endpoint %v to container %v.", hnsResponse.Id, epInfo.ContainerID) log.Printf("[net] Skipping attaching the endpoint %v to container %v.",
err = hcsshim.HotAttachEndpoint(epInfo.ContainerID, hnsResponse.Id) hnsResponse.Id, epInfo.ContainerID)
if err != nil { } else {
log.Printf("[net] Failed to attach endpoint: %v.", err) // Attach the endpoint.
return nil, err 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. // Create the endpoint object.