-
Notifications
You must be signed in to change notification settings - Fork 159
Respect the host platform #194
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
Respect the host platform #194
Conversation
generate/generate.go
Outdated
| } | ||
|
|
||
| if *os == "linux" { | ||
| spec.Process.User = rspec.User{} |
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.
User is not only used for Linux, it's also used by solaris.
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.
On Wed, Aug 17, 2016 at 08:38:58AM -0700, Ma Shimiao wrote:
}, Hostname: "mrsdalloway",
Mounts: []rspec.Mount{- }
- if *os == "linux" {
spec.Process.User = rspec.User{}User is not only used for Linux, it's also used by solaris.
We could handle that in two ways. If there is significant overlap
between some Linux and Solaris defaults, we'd want:
if *os == "linux" || *os == "solaris" {
spec.Process.User = rspec.User{}
…other common setup…
}
if *os == "linux" {
spec.Process.Capabilities = …
…other Linux-specific setup…
} else if *os == "solaris" {
spec.Solaris.Milestone = "svc:/milestone/container:default"
…other Solaris-specific setup…
} else {
return generator, fmt.Errorf("no defaults configured for %s", *os)
}
If there is not significant overlap, it's probably easier to have:
if *os == "linux" {
spec.Process.User = rspec.User{}
spec.Process.Capabilities = …
…other Linux-specific setup…
} else if *os == "solaris" {
spec.Process.User = rspec.User{}
spec.Solaris.Milestone = "svc:/milestone/container:default"
…other Solaris-specific setup…
} else {
return generator, fmt.Errorf("no defaults configured for %s", *os)
}
I think it will be easier to tell how much overlap there is once we
have a more detailed Solaris default. I don't think setting up an
empty struct for spec.Process.User is enough to be worth claiming
support for Solaris, though, so I'd rather leave this commit as it
stands until we do have a detailed Solaris default.
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 we can go with second approach for now. It is easier to follow the code if there is one path we walk down per platform.
|
@cyphar had some concerns about this approach 1, but I'm not clear |
|
Right. So my concerns are basically that I don't see why we're setting any OS defaults with a plain |
|
On Thu, Aug 18, 2016 at 05:29:39PM -0700, Aleksa Sarai wrote:
Callers that want to configure everything explicitly can use: $ ocitools generate --template <(echo '{}') to bypass most defaults. Without template, you get the fuller set of
I'm ok with this, although I'd call it --defaults and have it take a
Do such configs exist? There aren't many platform independent
One reason would be “I'm building an ocitools test suite and want to |
That wording was incorrect. What I meant was that we want to be able to do that (create a Linux config on Solaris or whatever) but I'm not sure about the platform option being "current OS you're running on" by default -- how is that meant to interact with things like LX-branded zones (where you're running a Linux binary on illumos). |
|
On Thu, Aug 18, 2016 at 10:32:55PM -0700, Aleksa Sarai wrote:
With this PR you can do that by setting --os, although we currently |
|
I like the idea of defaulting to current OS or specifying alternative via --os. It covers both aspects of easy to use for default case as well as supporting cross platform spec generation. |
|
@wking any updates for this PR? |
217c769 to
1ae6388
Compare
|
Missing a signed-off? |
|
On Mon, Nov 14, 2016 at 11:26:44AM -0800, Mrunal Patel wrote:
My three commits are signed-off. I think PullApprove is confused by |
As @mrunalp said, I also want to keep default current OS or specifying alternative via --os |
1ae6388 to
ea326f0
Compare
|
On Mon, Nov 14, 2016 at 05:21:26PM -0800, Ma Shimiao wrote:
I'm not convinced that's what @mrunalp was saying, but if there's a |
validate/validate.go
Outdated
| } | ||
| msgs = append(msgs, fmt.Sprintf("Operation system %q of the bundle is not supported yet.", platform.OS)) | ||
|
|
||
| if hostCheck { |
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.
hostCheck->v.HostSpecific
cmd/oci-runtime-tool/generate.go
Outdated
| Action: func(context *cli.Context) error { | ||
| // Start from the default template. | ||
| specgen := generate.New() | ||
| specgen, err := generate.New(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.
How about getting --os value before generate.New()?
Then we don't have to pass nil any more.
ea326f0 to
2cb6c62
Compare
|
On Mon, Nov 14, 2016 at 10:43:03PM -0800, Ma Shimiao wrote:
Oops, fixed in ea326f0 → 2cb6c62.
I liked it better when the caller didn't have to have an opinion (what |
|
@opencontainers/runtime-tools-maintainers , @wking |
|
On Tue, Nov 15, 2016 at 05:09:28PM -0800, Ma Shimiao wrote:
Explicit command line options (e.g. ‘--os windows’) should always take As it stands in this PR, the template is getting clobbered by the |
generate/generate.go
Outdated
| }, | ||
| } | ||
| } else { | ||
| return generator, fmt.Errorf("no defaults configured for %s", os) |
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 you need to generate the appropriate configuration for windows and solaris .
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 you need to generate the appropriate configuration for
windowsandsolaris.
I'm creating a very slim Solaris now default with 984db97. I'm happy to add a Window default too if you'll tell me what it should be, but I don't know enough about Windows to be able to figure that out on my own. Since we don't currently support generating defaults for Windows configs, I don't see a problem with leaving that unimplemented for this PR and just adjusting the function signatures to allow it to be added in the future.
If --host-specific is set, but the host OS doesn't match the requested validation platform, add an error, unset HostSpecific, and carry on with the remaining host-agnostic checks. Signed-off-by: W. Trevor King <[email protected]>
2cb6c62 to
984db97
Compare
984db97 to
4aecad2
Compare
Don't fill in a bunch of Linux stuff if runtime.GOOS isn't Linux ;). We don't have sensible defaults for other OSes yet, so error out in those cases. This commit restores the --os argument which had previously been removed in 597c7d4 (Remove platform, 2017-07-05, opencontainers#409). The diff here is fairly large, because many callers depend (directly or indirectly) on the generation code, and now all of those callers need to be on the lookout for errors. Generation will currently fail for all GOOS besides linux and solaris. I doubt the Solaris default is particularly useful either; it has all the POSIX settings from our Linux default, but I don't know enough about Solaris to know which Solaris-specific properties should get defaults. And while some rlimits are OS-specific, RLIMIT_NOFILE (the only one we set in our default config) is in POSIX [1], so I've put the rlimit config in the POSIX block. [1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html Signed-off-by: W. Trevor King <[email protected]>
4aecad2 to
2e6f6ab
Compare
Details in the commit messages, but the net effect is to respect
runtime.GOOS and runtime.GOARCH when --host-specific is set (for both
generate and validate). Also add an argument to generate.New to set
the target OS (falling back to runtime.GOOS).