-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pkg/ip: Return correct error if container name provided exists, and test cases #280
Conversation
@prateekgogia: Thank you for the fix. Could you please update it to follow our contribution guidelines? Specifically:
For this change, the test case is non-trivial. I'd suggest testing |
Hi @rosenhouse Thanks for the feedback. I am not familiar with Ginkgo testing framework. I will read about it and add the test cases soon. |
Hi @rosenhouse - I have made the changes to commit message and added test cases, can you please review and let me know if anything else is required. |
func peerExists(name string) bool { | ||
|
||
link, err := netlink.LinkByName(name) | ||
if link == nil || err != nil { |
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.
The test suite still passes if I simplify this to
_, err := netlink.LinkByName(name)
if err != nil {
...
Hi @prateekgogia, Thank you so much, this test coverage is a huge improvement. I noticed a small code simplification and also left some suggestions for improving the readability of the tests. The Ginkgo / Gomega BDD style is most valuable when the I'd ask that you fix these up, and then squash all of your commits together into a single commit that follows the aforementioned style guidelines. Thanks! |
@rosenhouse: updated and squashed all commits in one commit. Thanks for the review :) |
@@ -41,6 +41,15 @@ func makeVethPair(name, peer string, mtu int) (netlink.Link, error) { | |||
return veth, nil | |||
} | |||
|
|||
func peerExists(name string) bool { | |||
|
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.
Please remove this empty line.
…est cases If interface name for a container provided by a user is already present, Veth creation fails with incorrect error. If os.IsExist error is returned by makeVethPair: * Check for peer name, if exists generate another random peer name, * else, IsExist error is due to container interface present, return error. Fixes #155
@rosenhouse @jellonek addressed. |
LGTM. Any other @containernetworking/cni-maintainers want to give the second 👍 ? |
LGTM, but i'm not maintainer. |
LGTM - merging. |
If interface name for a container provided by a user is already present,
Veth creation fails with incorrect error.
If os.IsExist error is returned by makeVethPair:
Fixes #155