Skip to content
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

Plugable secrets backend #366

Merged
merged 1 commit into from
Sep 18, 2017

Conversation

liron-l
Copy link
Contributor

@liron-l liron-l commented Jul 20, 2017

This commit extends SwarmKit secret management with pluggable secret
backends support.
Following previous commits:

  1. moby/swarmkit@eebac27
  2. moby/moby@08f7cf0

Added driver parameter to docker secret command.
Specifically:

  1. docker secret create [secret_name] --driver [driver_name]
  2. Displaying the driver in
    $ docker secret ls
    $ docker secret inspect [secret_name]
    $ docker secret inspect [secret_name] -pretty

Signed-off-by: Liron Levin liron@twistlock.com

@codecov-io
Copy link

codecov-io commented Jul 20, 2017

Codecov Report

Merging #366 into master will increase coverage by 0.04%.
The diff coverage is 72.09%.

@@            Coverage Diff             @@
##           master     #366      +/-   ##
==========================================
+ Coverage   49.01%   49.06%   +0.04%     
==========================================
  Files         199      199              
  Lines       16392    16422      +30     
==========================================
+ Hits         8035     8057      +22     
- Misses       7939     7946       +7     
- Partials      418      419       +1

@liron-l
Copy link
Contributor Author

liron-l commented Jul 20, 2017

@dnephin @thaJeztah I closed and re-opend #348 since the tests did not get triggered on push.
I hope it's OK if we continue the discussion here.

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

@liron-l
Copy link
Contributor Author

liron-l commented Jul 20, 2017

@dnephin thanks! I think that the commit approval is what's causing the builds to stop.

@dnephin
Copy link
Contributor

dnephin commented Jul 20, 2017

Hmm, I don't know about that. We approve plenty of PRs that are still able to build afterward.

I think it's something about the files/changes. On my PR which had this issue (#107) I also retried recreating it, and after the first build it also stopped building again, and the new PR doesn't have any approvals.

@liron-l
Copy link
Contributor Author

liron-l commented Jul 20, 2017

Makes sense @dnephin. Let me know what further steps are required to complete this PR.

@dnephin
Copy link
Contributor

dnephin commented Jul 20, 2017

Once someone else gives their approval we can run the tests manually and merge. Let's not worry about the github bug for now

@liron-l
Copy link
Contributor Author

liron-l commented Jul 20, 2017

Great @dnephin thanks!

@liron-l
Copy link
Contributor Author

liron-l commented Jul 25, 2017

@thaJeztah PTAL, I separated vendor.conf bump to another commit.
Let me know if I need to bump additional packages. Thanks!

@liron-l liron-l force-pushed the plugable_secrets_backend branch 2 times, most recently from 8c158ce to 4064118 Compare July 30, 2017 11:33
@liron-l
Copy link
Contributor Author

liron-l commented Jul 30, 2017

@thaJeztah @cpuguy83 please take a look, I've updated the docker vendor dependencies again. Thanks!

Copy link
Collaborator

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸
/cc @thaJeztah needs some docs update ? 👼

@liron-l
Copy link
Contributor Author

liron-l commented Aug 9, 2017

@thaJeztah PTAL

@liron-l
Copy link
Contributor Author

liron-l commented Aug 13, 2017

@vdemeester, @cpuguy83, @diogomonica, @thaJeztah, should I add additional changes to this commit?

return runSecretCreate(dockerCli, options)
},
}
flags := cmd.Flags()
flags.VarP(&options.labels, "label", "l", "Secret labels")
flags.StringVar(&options.driver, "driver", "", "Secret driver")
Copy link
Member

Choose a reason for hiding this comment

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

This flag needs to have a version annotation, so that it is hidden / produces an error on older API versions

Copy link
Member

Choose a reason for hiding this comment

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

Also, to be consistent with docker network create, docker volume create, in this case I would be +1 to add a -d shorthand as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @thaJeztah I set the version annotation to 1.31, hope this makes sense.

in = file
defer file.Close()
if options.driver != "" && options.file != "" {
return errors.Errorf("When using secret driver secret data must be empty")
Copy link
Member

@thaJeztah thaJeztah Aug 14, 2017

Choose a reason for hiding this comment

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

Could this be handled by the (external) driver? IIUC, with this change the secret's value is taken from the external store, so

$ docker secret create --driver external mysecret

Doesn't really "create" a secret, but "associates" the external secret with a secret in Docker.

Do we need to keep the option open to have external secret stores create new secrets from the Docker CLI? i.e.

$ echo "new secret" | docker secret create --driver external mysecret -

If so, this validation should be done by the driver (just like currently checking for empty values is done in the backend)

$ docker secret create foo
Error response from daemon: rpc error: code = InvalidArgument desc = secret data must be larger than 0 and less than 512000 bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thaJeztah according to the secrets plugin subsystem design, the secrets plugin will be readonly (that is, swarm will not populate the secret values).
I think it might be better to prevent incorrect usage as soon as possible (since file is a cli only option).

@liron-l
Copy link
Contributor Author

liron-l commented Aug 14, 2017

Thanks @thaJeztah, I've updated the review according to your comments.

  1. Set minimum version for --secret parameter (1.31)
  2. Kept the CLI validation, according to the secret plugin design, we will never populate the secrets from the cli. In the context of plugins, the creation means that we create a real secret in swarmkit (secret name and metadata) and only the value is fetched from the plugin.

@liron-l liron-l force-pushed the plugable_secrets_backend branch 4 times, most recently from 3bf9d64 to 74c55de Compare August 18, 2017 19:23
@liron-l
Copy link
Contributor Author

liron-l commented Aug 18, 2017

@thaJeztah @diogomonica I've updated the code, please take a look if the new secrets driver API makes sense.

@liron-l
Copy link
Contributor Author

liron-l commented Aug 21, 2017

@diogomonica @thaJeztah PTAL.

@liron-l liron-l force-pushed the plugable_secrets_backend branch 3 times, most recently from 1920e7e to 93292ff Compare August 27, 2017 20:05
@liron-l
Copy link
Contributor Author

liron-l commented Aug 27, 2017

@thaJeztah PTAL, let me know if additional changes are required.

@liron-l liron-l force-pushed the plugable_secrets_backend branch 2 times, most recently from bc8f58d to 736f0a4 Compare September 3, 2017 20:32
@liron-l
Copy link
Contributor Author

liron-l commented Sep 3, 2017

@diogomonica @thaJeztah PTAL, all other dependencies related to this feature are completed. Thanks.

This commit extends SwarmKit secret management with pluggable secret
backends support.
Following previous commits:
1. moby/swarmkit@eebac27
2. moby/moby@08f7cf0
Added driver parameter to `docker secret` command.

Specifically:

1. `docker secret create [secret_name] --driver [driver_name]`
2.  Displaying the driver in
```
    $ docker secret ls
    $ docker secret inspect [secret_name]
    $ docker secret inspect [secret_name] -pretty
```

Signed-off-by: Liron Levin <liron@twistlock.com>
@diogomonica
Copy link
Contributor

This LGTM, but I don't have merging rights.

@liron-l
Copy link
Contributor Author

liron-l commented Sep 15, 2017

@vdemeester @dnephin @thaJeztah can somebody please merge?

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

alright let's get this merged

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants