Skip to content

Commit

Permalink
[Windows] Remove HNSEndpoint only if infra container fails to create (#…
Browse files Browse the repository at this point in the history
…2976)

For non-infra containers, there's no need to remove HNSEndpoint at
failure since it will be done when the Pod is removed.

Signed-off-by: Zhecheng Li <[email protected]>
  • Loading branch information
lzhecheng authored Nov 11, 2021
1 parent c8f65f1 commit ff17f09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/agent/cniserver/interface_configuration_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ func (ic *ifConfigurator) configureContainerLink(
containerIface, err := attachContainerLink(endpoint, containerID, containerNetNS, containerIFDev)
if err != nil {
klog.V(2).Infof("Failed to attach HNS Endpoint to the container, remove it.")
ic.removeHNSEndpoint(endpoint, containerID)
if isInfraContainer(containerID) {
ic.removeHNSEndpoint(endpoint, containerID)
}
return fmt.Errorf("failed to configure container IP: %v", err)
}

Expand Down Expand Up @@ -299,9 +301,7 @@ func attachContainerLink(ep *hcsshim.HNSEndpoint, containerID, sandbox, containe
if hcnEp == nil {
// Docker runtime
if err := hcsshim.HotAttachEndpoint(containerID, ep.Id); err != nil {
if isInfraContainer(sandbox) || hcsshim.ErrComputeSystemDoesNotExist != err {
return nil, err
}
return nil, err
}
} else {
// Containerd runtime
Expand Down

0 comments on commit ff17f09

Please sign in to comment.