-
Notifications
You must be signed in to change notification settings - Fork 260
Skip network creation if network already exists in HNS #1300
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
Conversation
| return network.GetHCNObj(), nil | ||
| } | ||
| return &hcn.HostComputeNetwork{}, nil | ||
| return nil, hcn.NetworkNotFoundError{} |
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.
just make sure cni code doesn't dereference pointer without checking for error
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.
this is the hns mock wrapper and only used by test code, no real cni code uses this type so there's no concerns.
| log.Printf("[net] Creating hcn network: %+v", hcnNetwork) | ||
| hnsResponse, err := hnsv2.CreateNetwork(hcnNetwork) | ||
| // check if network exists, only create the network does not exist | ||
| hnsResponse, err := hnsv2.GetNetworkByName(hcnNetwork.Name) |
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.
can you also log if network exists
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.
sure, added it when err is empty
| return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err) | ||
| } | ||
| // if network not found, create the HNS network. | ||
| if errors.As(err, &hcn.NetworkNotFoundError{}) { |
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.
can you add ut for testing these cases?
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.
added
tamilmani1989
left a comment
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.
lgtm 🚢
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
* skip network creation if network already exists * address comments * address feedback
Reason for Change:
Issue Fixed:
Requirements:
Notes: