-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Forbid adding duplicated namespace #1169
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
Forbid adding duplicated namespace #1169
Conversation
Signed-off-by: Yuanhong Peng <[email protected]>
8a8d6d0 to
aa06c0a
Compare
| } | ||
| (*n)[i].Path = path | ||
| return false | ||
| } |
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.
You haven't changed any of the callers of .Add to check the return value, so we're now ignoring duplicates. Please fix that.
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.
I don't think this is right.
This function is not only for adding new namespaces, but also for modifying path of existing namespace, you shouldn't disable this function. Also as @cyphar said, you didn't modify any caller so the return false/true is meaningless.
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.
Except the code I quoted before, I only find the callers of Add() in some test code. I know that this function is also used for modifying path of existing namespace, but I still think it would be better that if we want to modify path of existing namespace, we should remove it first, and then add it. If this idea is acceptable, I will fix those test functions then.
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.
Hmmmm.....If we must remove and then add to modify path of an existing namespace, then I think we won't need any check in Add().
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.
Actually, I'm confused. The code you quoted already doesn't allow for duplicate namespaces -- what's the benefit of this PR (it also appears to have broken the tests)?
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.
At the beginning, I just mistakenly thought the last line of code in Add() is redundant. But now it seems that my PR is meaningless and it's better to remain unchanged. Thanks for all your comments. I will close this PR later.
We now forbid duplicated namespace in spec(#1150), if there is a duplicated namespace, then it'll just return with error in
CreateLibcontainerConfig():So, as far as I can see, the last line of code in
Add()will never be reached here. Therefore, I just modified this func to be consistent withRemove(). Besides, this modification also forbids adding duplicated namespace to make the logic more clear.Signed-off-by: Yuanhong Peng [email protected]