Skip to content

Commit 0134df3

Browse files
committed
add config for disabling async delete
Signed-off-by: Tamilmani <tamanoha@microsoft.com>
1 parent f052db3 commit 0134df3

File tree

5 files changed

+4
-15
lines changed

5 files changed

+4
-15
lines changed

cni/netconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type NetworkConfig struct {
7272
EnableExactMatchForPodName bool `json:"enableExactMatchForPodName,omitempty"`
7373
DisableHairpinOnHostInterface bool `json:"disableHairpinOnHostInterface,omitempty"`
7474
DisableIPTableLock bool `json:"disableIPTableLock,omitempty"`
75+
DisableAsyncDelete bool `json:"disableAsyncDelete,omitempty"`
7576
CNSUrl string `json:"cnsurl,omitempty"`
7677
ExecutionMode string `json:"executionMode,omitempty"`
7778
IPAM IPAM `json:"ipam,omitempty"`

cni/network/network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
10791079
epInfos, err = plugin.nm.GetEndpointState(networkID, args.ContainerID)
10801080
// if stateless CNI fail to get the endpoint from CNS for any reason other than Endpoint Not found
10811081
if err != nil {
1082-
if errors.Is(err, network.ErrConnectionFailure) {
1082+
if errors.Is(err, network.ErrConnectionFailure) && !nwCfg.DisableAsyncDelete {
10831083
logger.Info("failed to connect to CNS", zap.String("containerID", args.ContainerID), zap.Error(err))
10841084
addErr := fsnotify.AddFile(args.ContainerID, args.ContainerID, watcherPath)
10851085
logger.Info("add containerid file for Asynch delete", zap.String("containerID", args.ContainerID), zap.Error(addErr))

cns/endpointmanager/endpointmanager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type EndpointManager struct {
1414
type releaseIPsClient interface {
1515
ReleaseIPs(ctx context.Context, ipconfig cns.IPConfigsRequest) error
1616
GetEndpoint(ctx context.Context, endpointID string) (*restserver.GetEndpointResponse, error)
17-
DeleteEndpointState(ctx context.Context, endpointID string) (*cns.Response, error)
1817
}
1918

2019
func WithPlatformReleaseIPsManager(cli releaseIPsClient) *EndpointManager {

cns/endpointmanager/endpointmanager_windows.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/Azure/azure-container-networking/cns"
77
"github.com/Azure/azure-container-networking/cns/hnsclient"
88
"github.com/Azure/azure-container-networking/cns/logger"
9-
"github.com/Azure/azure-container-networking/cns/types"
109
"github.com/pkg/errors"
1110
)
1211

@@ -18,18 +17,7 @@ func (em *EndpointManager) ReleaseIPs(ctx context.Context, ipconfigreq cns.IPCon
1817
logger.Errorf("failed to remove HNS endpoint %s", err.Error())
1918
}
2019

21-
if err := em.cli.ReleaseIPs(ctx, ipconfigreq); err != nil {
22-
return errors.Wrap(err, "failed to release IP from CNS")
23-
}
24-
25-
res, err := em.cli.DeleteEndpointState(ctx, ipconfigreq.InfraContainerID)
26-
if err != nil {
27-
if res.ReturnCode != types.NotFound {
28-
return errors.Wrap(err, "")
29-
}
30-
}
31-
32-
return nil
20+
return em.cli.ReleaseIPs(ctx, ipconfigreq)
3321
}
3422

3523
// deleteEndpoint API to get the state and then remove assiciated HNS

network/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ func (nm *networkManager) DeleteState(epInfos []*EndpointInfo) error {
773773

774774
if nm.IsStatelessCNIMode() {
775775
for _, epInfo := range epInfos {
776+
// this cleanup happens only for standalone swiftv2 to delete endpoint state from CNS.
776777
if epInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC || epInfo.NICType == cns.NodeNetworkInterfaceAccelnetFrontendNIC {
777778
response, err := nm.CnsClient.DeleteEndpointState(context.TODO(), epInfo.EndpointID)
778779
if err != nil {

0 commit comments

Comments
 (0)