-
Notifications
You must be signed in to change notification settings - Fork 142
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
translate: Stub in a translation framework #54
Conversation
I tried 'reflect' to convert an interface to a struct before. But later I choose json.Marshal/Unmarshal, it feels not good but make the implementation easy and right.
|
The purpose is converting between different specs, like between rkt and oci, right? How about maintain a list like this:
Otherwise it feels so special to see these certain field names: 'linux', 'namespace', 'path'. |
Add tooling to translate higher-level configs into the basic OCI config. On IRC, Julz floated a linux.namespaces[].fromContainer as a higher-level version of linux.namespaces[].path for emulating exec [1]. That makes sense to me, and Mrunal is open to something like [2]: $ ocitools generate --template=high-level-config.json --translate=fromContainer --runtime=runc The interface{} -> rspec.Spec conversion happens through a JSON serialization trick suggested by 梁辰晔 (Liang Chenye) [3] after the translations, because before the translations the template may contain JSON that's not represented in the OCI Spec structure (e.g. fromContainer in namespace entries). This commit still needs: * The state JSON lookup and path logic from [4]. * Adjustments to setupNamespaces to avoid clobbering the template. [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-27.log.html#t2016-04-27T20:32:09 [2]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-28.log.html#t2016-04-28T16:12:48 [3]: opencontainers#54 (comment) [4]: opencontainers/runtime-spec#391 Signed-off-by: W. Trevor King <[email protected]>
On Tue, May 03, 2016 at 04:18:46AM -0700, 梁辰晔 (Liang Chenye) wrote:
Going through JSON to setup strictSpec works for me. Done in 215cee9 Now that that's working, testing turned up setupNamespaces clobbering |
On Tue, May 03, 2016 at 04:48:19AM -0700, 梁辰晔 (Liang Chenye) wrote:
It's currently * → OCI. The fromNamespace translator is (OCI +
I'm not sure where you're going with your from / to list. Can you |
Add tooling to translate higher-level configs into the basic OCI config. On IRC, Julz floated a linux.namespaces[].fromContainer as a higher-level version of linux.namespaces[].path for emulating exec [1]. That makes sense to me, and Mrunal is open to something like [2]: $ ocitools generate --template=high-level-config.json --translate=fromContainer --runtime=runc The interface{} -> rspec.Spec conversion happens through a JSON serialization trick suggested by 梁辰晔 (Liang Chenye) [3] after the translations, because before the translations the template may contain JSON that's not represented in the OCI Spec structure (e.g. fromContainer in namespace entries). This commit still needs: * The state JSON lookup and path logic from [4]. * Adjustments to setupNamespaces to avoid clobbering the template. [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-27.log.html#t2016-04-27T20:32:09 [2]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-28.log.html#t2016-04-28T16:12:48 [3]: opencontainers#54 (comment) [4]: opencontainers/runtime-spec#391 Signed-off-by: W. Trevor King <[email protected]>
Add tooling to translate higher-level configs into the basic OCI config. On IRC, Julz floated a linux.namespaces[].fromContainer as a higher-level version of linux.namespaces[].path for emulating exec [1]. That makes sense to me, and Mrunal is open to something like [2]: $ ocitools generate --template=high-level-config.json --translate=fromContainer --runtime=runc The interface{} -> rspec.Spec conversion happens through a JSON serialization trick suggested by 梁辰晔 (Liang Chenye) [3] after the translations, because before the translations the template may contain JSON that's not represented in the OCI Spec structure (e.g. fromContainer in namespace entries). This commit still needs (marked by FIXMEs): * Lookup /proc in /proc/self/mounts (recursive?). * Compare /proc with state JSON namespace [4]. * Adjustments to setupNamespaces to avoid clobbering the template. * Better handling for user-namespace injection. * A way to handle nested definition lists in man pages. I expect we should drop go-md2man in favor of a more established man-page format (e.g. AsciiDoc). [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-27.log.html#t2016-04-27T20:32:09 [2]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-28.log.html#t2016-04-28T16:12:48 [3]: opencontainers#54 (comment) [4]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/ujtABQoCmgk Subject: Linux: Adding the PID namespace inode to state JSON Date: Wed, 30 Dec 2015 21:34:57 -0800 Message-ID: <[email protected]> Signed-off-by: W. Trevor King <[email protected]>
I just pushed c565214 → dae2098, which:
Still todo (marked by FIXMEs):
|
@wking I was thinking of having a framework for translation, most of your codes could be reuse if someone want to implement another extension, like rkt to oci. I'll try to find out a case and explain it in code. |
A rkt -> OCI translator should fit cleanly into what I have now. You'd only need to rethink things if you wanted to cover OCI -> rkt, and other translation chains that don't end in OCI. |
On Tue, May 03, 2016 at 03:47:16PM -0700, W. Trevor King wrote:
I've pushed fixes for the namespace-setup issues in #60. I'll rebase |
Add tooling to translate higher-level configs into the basic OCI config. On IRC, Julz floated a linux.namespaces[].fromContainer as a higher-level version of linux.namespaces[].path for emulating exec [1]. That makes sense to me, and Mrunal is open to something like [2]: $ ocitools generate --template=high-level-config.json --translate=fromContainer --runtime=runc The interface{} -> rspec.Spec conversion happens through a JSON serialization trick suggested by 梁辰晔 (Liang Chenye) [3] after the translations, because before the translations the template may contain JSON that's not represented in the OCI Spec structure (e.g. fromContainer in namespace entries). This commit still needs (marked by FIXMEs): * Lookup /proc in /proc/self/mounts (recursive?). * Compare /proc with state JSON namespace [4]. * A way to handle nested definition lists in man pages. I expect we should drop go-md2man in favor of a more established man-page format (e.g. AsciiDoc). [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-27.log.html#t2016-04-27T20:32:09 [2]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-28.log.html#t2016-04-28T16:12:48 [3]: opencontainers#54 (comment) [4]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/ujtABQoCmgk Subject: Linux: Adding the PID namespace inode to state JSON Date: Wed, 30 Dec 2015 21:34:57 -0800 Message-ID: <[email protected]> Signed-off-by: W. Trevor King <[email protected]>
On Sat, May 07, 2016 at 12:01:18AM -0700, W. Trevor King wrote:
Rebased with dae2098 → f7f25b3. Still a few TODOs in the commit |
Add tooling to translate higher-level configs into the basic OCI config. On IRC, Julz floated a linux.namespaces[].fromContainer as a higher-level version of linux.namespaces[].path for emulating exec [1]. That makes sense to me, and Mrunal is open to something like [2]: $ ocitools generate --template=high-level-config.json --translate=fromContainer --runtime=runc The interface{} -> rspec.Spec conversion happens through a JSON serialization trick suggested by 梁辰晔 (Liang Chenye) [3] after the translations, because before the translations the template may contain JSON that's not represented in the OCI Spec structure (e.g. fromContainer in namespace entries). The /proc lookup could still be improved: * Lookup the mount path (currently hard-coded to /proc) in /proc/self/mounts. This would extend support to users who had mounted proc at a different location, but it's hard to find self/mounts unless you already know where proc is mounted ;). * Compare /proc with the state JSON's implied PID namespace [4]. This would extend support to users in a different PID namespace than the one in which the state JSON's 'pid' entry applied. But those are likely to be corner cases (and until something like [4] lands, the latter is not possible). So I'm punting them into the future, where they can be fixed as we discover methods to fix them. [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-27.log.html#t2016-04-27T20:32:09 [2]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-04-28.log.html#t2016-04-28T16:12:48 [3]: opencontainers#54 (comment) [4]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/ujtABQoCmgk Subject: Linux: Adding the PID namespace inode to state JSON Date: Wed, 30 Dec 2015 21:34:57 -0800 Message-ID: <[email protected]> Signed-off-by: W. Trevor King <[email protected]>
On Fri, May 13, 2016 at 04:58:56PM -0700, W. Trevor King wrote:
Moved the “available translations” docs to a subsection in f7f25b3 → |
On Tue, May 03, 2016 at 03:47:16PM -0700, W. Trevor King wrote:
We may be able to do this with ‘mount -l -t proc’, but mount(8) says |
On Sat, May 14, 2016 at 03:15:43PM -0700, W. Trevor King wrote:
I'm not sure why strace only shows entries like: open(0x7ff987f091ba, …) for the ‘mount -l …’ call, but it appears to be using a hard-coded $ LIBMOUNT_DEBUG=tab mount -l -t proc So I'm currently back to having no ideas about detecting alternative |
I am okay adding this but will wait for rebase after #131 |
On Tue, Jul 12, 2016 at 05:12:08PM -0700, Mrunal Patel wrote:
I think I'm going to need some guidance about how much to change after a. Update Generator to hold an interface{} but that makes manipulating None of those sound perfect to me. I'm leaning towards (c) at the |
I think currently this doesn't make too much sense. I prefer to reject this one. |
@Mashimiao I just quickly reviewed this thread. I did not see the user scenario here. +1 for close this. |
closing it |
Add tooling to translate higher-level configs into the basic OCI config. On IRC, @julz floated a
linux.namespaces[].fromContainer
as a higher-level version oflinux.namespaces[].path
for emulating exec (opencontainers/runtime-spec#391). That makes sense to me, with a UI like:This commit still needs:
interface{}
to anrspec.Spec
(the current FIXME raises:FATA[0000] translated template has an invalid schema
).I'm comfortable working through the former, but would appreciate pointers on the latter from anyone who is more Go-literate than I.
More generally, I'm curious to know what folks think of this approach. I'd rather make those before grinding through the implementation details ;).