Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

app/add: Allow to define annotations for app from CLI #3814

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

nhlfr
Copy link
Contributor

@nhlfr nhlfr commented Sep 26, 2017

Before this change, "app add" CLI allowed only to define
user annotations. User annotations were designed mostly
to store annotations from Kubernetes API. At the same time,
we want to store some data related to rktlet which aren't
k8s annotations (i.e. log directories for CRI-compatible
logs).

Defining annotations is allowed here by --annotation
CLI option (i.e. --annotation=foo=bar).

Ref #3813


TODO:

  • implementation
  • tests

Copy link
Member

@iaguis iaguis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small comments. Looks good after that (given tests).

stage0/common.go Outdated
}
kAci, err := types.NewACIdentifier(k)
if err != nil {
return ra, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do

return errwrap.Wrap(fmt.Errorf("error parsing annotation key %q", k), err)

I'd like to avoid confusing errors like these:

> sudo -E rkt --debug app add  64a8c4bf  kinvolk.io/aci/busybox --annotation=FOO=BAR --name=buzyboxz
stage0: locking pod manifest
stage0: Loading image sha512-140375b2a2bd836559a7c978f36762b75b80a7665e5d922db055d1792d6a4182
stage0: Writing image manifest
add: error adding app to pod
  └─ACIdentifier must contain only lower case alphanumeric characters plus "-._~/"

rkt/cli_apps.go Outdated
@@ -600,12 +600,49 @@ func (au *appName) Type() string {
return "appName"
}

// appAnnotation is for --user-annotation flags in the form of: --user-annotation=NAME=VALUE.
// appAnnotation is for --annotation flags in the form of: --annotation=NAME=VALUE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do --annotation=name=value since for annotations the key has to be an ACIdentifier and can't be upper case.

@iaguis
Copy link
Member

iaguis commented Sep 27, 2017

You could also add a functional test in https://github.com/rkt/rkt/blob/master/tests/rkt_metadata_service_test.go that starts pods with --annotation and checks they're there.

@nhlfr nhlfr force-pushed the nhlfr/app-add-annotations-cli branch 2 times, most recently from e3acbb3 to b7904c2 Compare September 27, 2017 17:16
@nhlfr nhlfr changed the title [WIP] app/add: Allow to define annotations for app from CLI app/add: Allow to define annotations for app from CLI Sep 27, 2017
@nhlfr
Copy link
Contributor Author

nhlfr commented Sep 27, 2017

@iaguis done, PTAL

Copy link
Member

@iaguis iaguis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit and LGTM after that.

}{
{
args: []string{
"--annotation=foo=bar",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use different key/value to differentiate from user annotations here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Before this change, "app add" CLI allowed only to define
user annotations. User annotations were designed mostly
to store annotations from Kubernetes API. At the same time,
we want to store some data related to rktlet which aren't
k8s annotations (i.e. log directories for CRI-compatible
logs).

Defining annotations is allowed here by --annotation
CLI option (i.e. --annotation=foo=bar).

Ref rkt#3813
@nhlfr nhlfr force-pushed the nhlfr/app-add-annotations-cli branch from b7904c2 to 18f7624 Compare September 28, 2017 09:34
@iaguis iaguis added this to the 1.29.0 milestone Sep 28, 2017
@iaguis iaguis merged commit 92ed2ce into rkt:master Sep 28, 2017
@nhlfr nhlfr deleted the nhlfr/app-add-annotations-cli branch September 28, 2017 16:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants