-
Notifications
You must be signed in to change notification settings - Fork 240
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
fix: fixing HNS network already exist error in Stateless CNI #3297
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,10 +360,20 @@ | |
if errors.As(err, &hcn.NetworkNotFoundError{}) { | ||
logger.Info("Creating hcn network", zap.Any("hcnNetwork", hcnNetwork)) | ||
hnsResponse, err = Hnsv2.CreateNetwork(hcnNetwork) | ||
if err != nil { | ||
return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err) | ||
if err == nil { | ||
logger.Info("Successfully created hcn network with response", zap.Any("hnsResponse", hnsResponse)) | ||
} else { | ||
if strings.Contains(err.Error(), "already exists") { | ||
// fetch the network name again since the parallel CNI Add call has created the HNS network | ||
hnsResponse, err = Hnsv2.GetNetworkByName(hcnNetwork.Name) | ||
tamilmani1989 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return nil, fmt.Errorf("Failed to get hcn network: %s due to error: %v", hcnNetwork.Name, err) | ||
Check failure on line 370 in network/network_windows.go GitHub Actions / Lint (1.22.x, windows-latest)
Check failure on line 370 in network/network_windows.go GitHub Actions / Lint (1.23.x, windows-latest)
|
||
} | ||
logger.Info("Successfully fetched hcn network with response", zap.Any("hnsResponse", hnsResponse)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you are logging whole struct, lets make sure its not printing any byte array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Printed hnsreponse.ID instead in new commit |
||
} else { | ||
return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err) | ||
Check failure on line 374 in network/network_windows.go GitHub Actions / Lint (1.22.x, windows-latest)
Check failure on line 374 in network/network_windows.go GitHub Actions / Lint (1.23.x, windows-latest)
|
||
} | ||
} | ||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add a log printing err.Error() before calling get hns network
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done