This repository was archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 315
Change namespaces config to include path for setns #279
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,12 +64,12 @@ func TestConfigJsonFormat(t *testing.T) { | |
| t.Fail() | ||
| } | ||
|
|
||
| if !container.Namespaces["NEWNET"] { | ||
| if getNamespaceIndex(container, "NEWNET") == -1 { | ||
| t.Log("namespaces should contain NEWNET") | ||
| t.Fail() | ||
| } | ||
|
|
||
| if container.Namespaces["NEWUSER"] { | ||
| if getNamespaceIndex(container, "NEWUSER") != -1 { | ||
| t.Log("namespaces should not contain NEWUSER") | ||
| t.Fail() | ||
| } | ||
|
|
@@ -158,3 +158,12 @@ func TestSelinuxLabels(t *testing.T) { | |
| t.Fatalf("expected mount label %q but received %q", label, container.MountConfig.MountLabel) | ||
| } | ||
| } | ||
|
|
||
| func getNamespaceIndex(config *Config, name string) int { | ||
|
Contributor
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. I actually didn't got this trick. This is something like
Contributor
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. Ah, got it. Sorry. |
||
| for i, v := range config.Namespaces { | ||
| if v.Name == name { | ||
| return i | ||
| } | ||
| } | ||
| return -1 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think it can me more convenient for usage if we'd use map[string]string. Because with array you need rewrite it totally to disable one namespace. Also there can be conflicting names.
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.
Are you suggesting map from name to path? Does that stop us from evolving the Namespace struct in future?
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 think they are saying something like
Namespaces map[string]NamespaceI'm not a big fan because you could have they key of the map say
NEWNETand the Name in the struct say some other namespace, it does not enforce data consistency.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.
For a map[string]Namespace, I think we'll end up never checking the key and always iterate over it. Basically, we'll end up using it as an array anyway. What we have now looks fine.
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 am okay with not doing a map since we are only talking about a few namespaces.
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.
Yes, I propose name to path mapping and I think that this datastructure won't evolve in fields-way anyway because it is used in Config and this will be PITA for user to fill some complicated structures for config.
And I don't see what bad with map for now, apart from that we don't need abominations like
getNamespaceIndexThere 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.
libcontainer is a low level API so i don't think this is a big issue for people, it maybe a little harder but I would rather have a flexible and consistent way to enforce the changes then the
map[string]stringwhere you don't know what is supposed to be in the key and why some have an empty string as the value.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.
Also, there is similar
namespaces.Namespace, maybe we can at least have one datastructure?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.
@LK4D4 updated
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.
Hope that this won't lead to circular dependencies later :)