Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error if hns network exists for transparent network #2877

Merged
merged 5 commits into from
Jul 26, 2024
Merged
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
8 changes: 7 additions & 1 deletion network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,19 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
if err != nil {
return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err)
}

logger.Info("Successfully created hcn network with response", zap.Any("hnsResponse", hnsResponse))
} else {
// we can't validate if the network already exists, don't continue
return nil, fmt.Errorf("Failed to create hcn network: %s, failed to query for existing network with error: %v", hcnNetwork.Name, err)
}
} else {
if hcnNetwork.Type == hcn.Transparent {
// CNI triggers Add() for new pod first and then delete older pod later
// for transparent network type, do not ignore network creation if network already exists
// return error to avoid creating second endpoint
logger.Error("HNS network with name already exists. Returning error for transparent network", zap.String("networkName", hcnNetwork.Name))
return nil, fmt.Errorf("HNS network with name:%s already exists. Returning error for transparent network", hcnNetwork.Name) //nolint
}
logger.Info("Network with name already exists", zap.String("name", hcnNetwork.Name))
}

Expand Down
Loading