-
Notifications
You must be signed in to change notification settings - Fork 550
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
Add labels to the state #188
Conversation
On Mon, Sep 14, 2015 at 08:28:06PM -0700, Gao feng wrote:
Hmm, what sort of statistics are you interested in? I think it would
The current state layout doesn't really map to runV-launched |
@wking Runv needs to store an unix socket path in state.json, we can name this socket as .sock. but this socket is totally meaningless for container based runtimes, they should not try to get useful information through the pid stored in state.json. |
On Mon, Sep 14, 2015 at 11:48:02PM -0700, Gao feng wrote:
If you're interested in how many containers a given runtime starts,
We should address situations where there is a functional difference |
@@ -67,4 +67,6 @@ type State struct { | |||
Pid int `json:"pid"` | |||
// Root is the path to the container's bundle directory. | |||
Root string `json:"root"` | |||
// Runtime is the runtime of OCI container | |||
Runtime string `json:"runtime"` |
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 not in favor of adding explicit Runtime specific information to the Spec or State. How about using runtime labels
or annotations
, which are arbitrary strings, for this purpose?
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.
Ah yeah
On Sep 16, 2015 13:47, "Vish Kannan" [email protected] wrote:
In config.go
#188 (comment):@@ -67,4 +67,6 @@ type State struct {
Pid intjson:"pid"
// Root is the path to the container's bundle directory.
Root stringjson:"root"
- // Runtime is the runtime of OCI container
- Runtime string
json:"runtime"
I am not in favor of adding explicit Runtime specific information to the
Spec or State. How about using runtime labels or annotations, which are
arbitrary strings, for this purpose?—
Reply to this email directly or view it on GitHub
https://github.com/opencontainers/specs/pull/188/files#r39661833.
@gao-feng using |
Why restrict labels to the runtime itself? For example, see container
labels in #108. I'd recommend we add an optional “labels” to
config.json holding a list of arbitrary bundle-author-specified JSON.
Then in the state JSON, we would have:
"labels": {
"runtime": …stuff specified by the runtime…,
"bundle": …stuff from config.json's “labels”…
}
|
@wking
it is already in config.json's "labels", right? why we add it to state.json again? the |
@@ -67,4 +67,6 @@ type State struct { | |||
Pid int `json:"pid"` | |||
// BundlePath is the path to the container's bundle directory. | |||
BundlePath string `json:"bundlePath"` | |||
// Lables is the runtime itself specified information. |
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.
Maybe “Labels holds runtime-specified information that is not structured by this specification.”?
On Fri, Oct 09, 2015 at 08:03:29PM -0700, Gao feng wrote:
Ah, fair enough. I guess I'm still convinced that putting the bundle Sticking with the current spec's position that bundlePath is worth the |
@wking Thanks for your suggestion, updated, please check. :) |
@@ -67,4 +67,6 @@ type State struct { | |||
Pid int `json:"pid"` | |||
// BundlePath is the path to the container's bundle directory. | |||
BundlePath string `json:"bundlePath"` | |||
// Labels holds runtime-specified information that is not structured by this specification | |||
Labels map[string]json.RawMessage `json:"labels"` |
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.
sorry, but why json.RawMessage
? I presume for holding structures instead of just a string
, but couldn't that be accomplished with a map[string]interface{}
?
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 Fri, Oct 16, 2015 at 06:51:30AM -0700, Vincent Batts wrote:
@@ -67,4 +67,6 @@ type State struct {
Pid intjson:"pid"
// BundlePath is the path to the container's bundle directory.
BundlePath stringjson:"bundlePath"
- // Labels holds runtime-specified information that is not structured by this specification
- Labels map[string]json.RawMessage
json:"labels"
sorry, but why
json.RawMessage
? I presume for holding structures
instead of just astring
, but couldn't that be accomplished with a
map[string]interface{}
?
+1 to map[string]interface{}. Notes on using that from Go in 1.
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.
Labels are typically used to grouping objects. See in docker and kubernetes.
I'm weary of overloading that concept to hold arbitrary data.
I'd say lets introduce a separate Annotation
field that users can use to pass arbitrary data. Is this information expected to be persisted in the State
?
Also if we switch to protobufs, extensions should let us pass arbitrary data and avoid having to include Annotations
in the Spec.
Any thoughts @vbatts @philips ?
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.
There is value in labels or annotations in the mutable content IMO.
Though, even in it's current form, there is nothing stopping users from provided non-spec required fields in the config.json. i.e. the config is not invalid by having additional fields. And I feel that it should stay this way.
The spec will define behavior on the known fields (regardless required or optional). Should there be other fields added, it is undefined behavior, but not prohibited.
So rather than giving up to allow folks to shit all over the place, better to give a space like labels/annotations for them to dump content that is mutable and a part of the bundle's digest.
Now if there were to be an actual section for arbitrary runtime annotations, would that be separated from arbitrary data? I've not got a concrete example of this besides runtime hints of asking for 2g memory vs. some projects internal version numbering / git commit reference / etc
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.
Can we change this json.RawMessage
to interface{}
?
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.
@vbatts Sure, updated, thanks for your comments.
LGTM |
a878558 looks good to me too.
|
Labels are usually key value pairs elsewhere in docker and kubernetes. They are generally used for grouping. In this PR it looks like we are attempting to store metadata that is opaque to the spec. If that is the case can we store the metadata as a string? The users of the spec can then store anything in the string, including maps serialized to json format. |
@vishh is it the field name of "labels" that feels like a collision to you? I am not attached to that name, but there is frustration with having to unmarshal content just to map in a string typed field. |
On Fri, Oct 30, 2015 at 08:37:29AM -0700, Vish Kannan wrote:
That's my preference, yeah. Why require a particular structure for
That seems like extra (de)serialization work for runtimes that use
I don't really care what the key associated with this unstructured |
@vbatts: Got it. +1 on not using the keyword I'm curious why we are choosing |
On Fri, Oct 30, 2015 at 09:37:45AM -0700, Vish Kannan wrote:
Works for me, although I think all our existing JSON keys start with
Because that doesn't allow deeper nesting if folks want to put more I don't think we have to worry about language support. Many languages |
since it's json can you not just store whatever you want in there without having to add a field like this ? i.e. type MyRuntimeState {
specs.State
MyFields string `json:"myField"`
} Your runtime can unmarshal and marshal exactly what you want, everyone else can ignore fields they don't know about. |
On Mon, Nov 16, 2015 at 01:59:02PM -0800, Michael Crosby wrote:
This PR allocates an approved namespace for that, otherwise you risk |
an approved namespace for putting unapproved things, makes sense ... |
@@ -22,6 +22,8 @@ This allows the hooks to perform cleanup and teardown logic after the runtime de | |||
* **`pid`**: (int) is the ID of the main process within the container, as seen by the host. | |||
* **`bundlePath`**: (string) is the absolute path to the container's bundle directory. | |||
This is provided so that consumers can find the container's configuration and root filesystem on the host. | |||
* **`Labels`**: (map) Labels holds runtime-specified information that is not structured by this specification | |||
The runtime could store experimental information here before it's standardized in this specification. |
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.
Is there a recommended format for the values? Is it byte encoded or string or something else?
`Annotations` is used to store some runtime specified informations, these informations may be meaningless to other runtime, but it's userful for the same runtime to operate this container. Signed-off-by: Gao feng <[email protected]>
@vishh @crosbymichael @wking Updated, thanks you guys. |
@@ -23,6 +23,9 @@ This allows the hooks to perform cleanup and teardown logic after the runtime de | |||
* **`bundlePath`**: (string) is the absolute path to the container's bundle directory. | |||
This is provided so that consumers can find the container's configuration and root filesystem on the host. | |||
|
|||
* **`annotations`**: (interface) holds runtime-specified information that is not structured by this specification. |
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.
What does an interface
mean outside of golang?
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 Mon, Nov 16, 2015 at 07:59:57PM -0800, Vish Kannan wrote:
+*
annotations
: (interface) holds runtime-specified
information that is not structured by this specification.What does an
interface
mean outside of golang?
Data with an unspecified schema. E.g. void* in C 1.
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.
Eh, this is weird. We are already saying this is JSON encoded, so we should just say the type here is an arbitrary JSON type (either an object or a value). "interface" is unhelpful.
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.
+1
On Wed, Dec 16, 2015 at 10:53 AM, Jonathan Boulle [email protected]
wrote:
In runtime.md
#188 (comment):@@ -23,6 +23,9 @@ This allows the hooks to perform cleanup and teardown logic after the runtime de
bundlePath
: (string) is the absolute path to the container's bundle directory.
This is provided so that consumers can find the container's configuration and root filesystem on the host.+*
annotations
: (interface) holds runtime-specified information that is not structured by this specification.Eh, this is weird. We are already saying this is JSON encoded
https://github.com/opencontainers/specs/pull/188/files#diff-b84a8d65d8ed53f4794cd2db7e8ea731L11,
so we should just say the type here is an arbitrary JSON type (either an
object or a value). "interface" is unhelpful.—
Reply to this email directly or view it on GitHub
https://github.com/opencontainers/specs/pull/188/files#r47816296.
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, Dec 16, 2015 at 10:53:41AM -0800, Jonathan Boulle wrote:
+*
annotations
: (interface) holds runtime-specified information that is not structured by this specification.Eh, this is weird. We are already saying this is JSON
encoded,
so we should just say the type here is an arbitrary JSON type
(either an object or a value). "interface" is unhelpful.
“interface” is a Go-ism. So I'm fine with interface in the Go type
and “JSON” in these Markdown docs.
161c98e looks good to me.
|
Just one nit. Otherwise LGTM |
If we do this I really really think we need to tell people to namespace their json fields. If the goal of the state.json is to encourage standard operations then having extensions here seems really dangerous without namespacing.
|
On Tue, Dec 22, 2015 at 10:53:33PM -0800, Brandon Philips wrote:
There is only one author (the runtime) that is allowed to write to "annotations": { |
I am not saying don't make it opaque to the spec, but we really should On Wed, Dec 23, 2015 at 9:40 AM W. Trevor King [email protected]
|
@philips I agree on the encouragement. Perhaps that verbiage ought to start for annotations in the bundled config.json, since that will be from bundle authors (not just the runtime) |
On Mon, Jan 04, 2016 at 10:38:07AM -0800, Vincent Batts wrote:
I think this PR is just about the state JSON and runtime annotations. For this PR, I'd suggest phrasing like 2: Runtimes are encouraged to mark and version any annotations so users
Which will allow consumers to determine with high confidence that
|
On Wed, Mar 09, 2016 at 11:18:12AM -0800, Vish Kannan wrote:
I think we should re-open this PR or land something similar. #331
|
The spec was not very clear on how state annotations are related to [config annotations. In the pull-request that landed state annotations, it sounds like these were supposed to be copied opaquely from the config [1]. It's still not clear to me why we'd copy annotations but not the rest of the config [2], but I'm leaving that alone for now. There was previous interest in runtime-specified annotations [3,4] (e.g. a RunV socket path [5]), but this commit does not allow runtimes to inject additional entries because I don't like: * Relying on config authors to avoid squatting on the namespace used by the runtime (if ties are broken in favor of the config) or * Silently clobbering configured annotations (if ties are broken in favor of the runtime). My preference would be to follow [3] and: * Only include runtime-specified information in the state annotations. * Require state readers to follow 'bundle' to the config.json if they wanted configured annotations (or embed the whole config.json in the state). But with 1.0 released and spec-maintainer comments like [1], I think it's too late to return to that approach. If we want to expose runtime-specified annotations, I think we'll need a new state property. There has been previous discussion of using "labels" and "annotations" to carry both types of information in the state [6], and while it's not as elegant as a full config copy, the labels/annotations approach is still viable. [1]: opencontainers#484 (comment) [2]: opencontainers#484 (comment) [3]: opencontainers#188 [4]: opencontainers#331 (comment) [5]: opencontainers#188 (comment) [6]: opencontainers#331 (comment) Signed-off-by: W. Trevor King <[email protected]>
The spec was not very clear on how state annotations are related to config annotations. In the pull-request that landed state annotations, it sounds like these were supposed to be copied opaquely from the config [1]. It's still not clear to me why we'd copy annotations but not the rest of the config [2], but I'm leaving that alone for now. There was previous interest in runtime-specified annotations [3,4] (e.g. a RunV socket path [5]), but this commit does not allow runtimes to inject additional entries because I don't like: * Relying on config authors to avoid squatting on the namespace used by the runtime (if ties are broken in favor of the config) or * Silently clobbering configured annotations (if ties are broken in favor of the runtime). My preference would be to follow [3] and: * Only include runtime-specified information in the state annotations. * Require state readers to follow 'bundle' to the config.json if they wanted configured annotations (or embed the whole config.json in the state). But with 1.0 released and spec-maintainer comments like [1], I think it's too late to return to that approach. If we want to expose runtime-specified annotations, I think we'll need a new state property. There has been previous discussion of using "labels" and "annotations" to carry both types of information in the state [6], and while it's not as elegant as a full config copy, the labels/annotations approach is still viable. [1]: opencontainers#484 (comment) [2]: opencontainers#484 (comment) [3]: opencontainers#188 [4]: opencontainers#331 (comment) [5]: opencontainers#188 (comment) [6]: opencontainers#331 (comment) Signed-off-by: W. Trevor King <[email protected]>
Labels
is used to store some runtime specified informations,these informations may be meaningless to other runtime, but it's
userful for the same runtime to operate this container.
Signed-off-by: Gao feng [email protected]