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

Allow for escaping docker:label #137

Open
Smithx10 opened this issue Jan 20, 2019 · 1 comment
Open

Allow for escaping docker:label #137

Smithx10 opened this issue Jan 20, 2019 · 1 comment

Comments

@Smithx10
Copy link

While working on https://github.com/Smithx10/virtual-kubelet, I came across a situation where I would like for all instances provisioned to have a certain set of shared tags whether they are provisioned via sdc-docker or sdc-cloudapi.

The Docker API is only aware of labels, which are stored in Triton as tags prefixed with docker:label:

I was hoping that we could add to docker a way to escape docker:label: and set tags directly, this will save me from having to make 2 api calls, a Create, and then an Apply tag.

Implementation Idea:
I noticed that the label "triton.cns.services" was applied without the docker:label prefix. I imagine we could do something like the following to escape it...

--label no.prefix.mytag=mytagvalue 

Which would result in the following tag:

mytag=mytagvalue 

Instead of

docker:label:mytag
@Smithx10
Copy link
Author

I hacked together something simple. I believe this sums up in essence what is desired, but probably needs a safer implementation.

I added the following to https://github.com/joyent/sdc-docker/blob/master/lib/backends/sdc/containers.js#L2033

2023                     } else if (triton_tags.isTritonTag(key)) {
2024                         triton_tags.parseTritonTagStr(key, val,
2025                                 function (err, parsed) {
2026                             if (err) {
2027                                 labelErrs.push(err);
2028                             } else {
2029                                 payload.tags[key] = parsed;
2030                             }
2031                             next();
2032                         });
2033                     } else if (key.lastIndexOf('escape.prefix.', 0) === 0) {
2034                          key = key.split(/\.(?=[^\.]+$)/)[1];
2035                          payload.tags[key] = val;
2036                          next();
2037                     } else {
2038                         payload.tags[common.LABELTAG_PREFIX + key] = val;
2039                         next();
2040                     }
2041                 }

Smithx10 pushed a commit to Smithx10/virtual-kubelet that referenced this issue Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant