Skip to content

Uses namespace labels for default options#2626

Merged
dmcgowan merged 4 commits intocontainerd:masterfrom
krsoninikhil:defaults3
Apr 2, 2019
Merged

Uses namespace labels for default options#2626
dmcgowan merged 4 commits intocontainerd:masterfrom
krsoninikhil:defaults3

Conversation

@krsoninikhil
Copy link
Copy Markdown
Contributor

This is in reference to #2285. I tried to configure default runtime and snapshotter using namespace labels. Please suggest me the right approach if this is not the best way to do it.

Signed-off-by: Nikhil Soni [email protected]

@krsoninikhil krsoninikhil force-pushed the defaults3 branch 2 times, most recently from bbf8134 to a6c0be1 Compare September 10, 2018 19:03
@kadisi
Copy link
Copy Markdown
Contributor

kadisi commented Sep 11, 2018

i think , the meaning of issue #2285 maybe not only get specific label from default namespace . we should get the specific label from every namespaces to set defaults for certain items which created in it`s namespace.

cc @stevvooe @crosbymichael PTAL

@krsoninikhil
Copy link
Copy Markdown
Contributor Author

krsoninikhil commented Sep 11, 2018

Thanks @kadisi for taking a look. During client instantiation, we don't have a context and only namespace we can consider, is the one which is passed with ClientOpt, which should be default if nothing is passed. Are there any other possible namespaces during client instantiation?

@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 12, 2018

Codecov Report

Merging #2626 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2626   +/-   ##
=======================================
  Coverage   43.98%   43.98%           
=======================================
  Files         102      102           
  Lines       10873    10873           
=======================================
  Hits         4782     4782           
  Misses       5358     5358           
  Partials      733      733
Flag Coverage Δ
#linux 47.63% <ø> (ø) ⬆️
#windows 41.19% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7f24e2...da2ab86. Read the comment docs.

Comment thread client.go Outdated
}
namespaces := c.NamespaceService()
ctx := context.Background()
if labels, err := namespaces.Labels(ctx, defaultns); err == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably only be looked up when a defaultns is provided and no defaultruntime is. The given option should always be preferred and I don't think we should default the ns here.

Also I think NewWithConn should probably have matching logic

@krsoninikhil krsoninikhil force-pushed the defaults3 branch 2 times, most recently from 377595b to 3ac507a Compare September 18, 2018 10:33
@krsoninikhil
Copy link
Copy Markdown
Contributor Author

Hi @dmcgowan, thanks for reviewing. I've made these changes, can you please again have a look?

@krsoninikhil
Copy link
Copy Markdown
Contributor Author

Hi @dmcgowan, just wanted to ping you again. Can you please have another look on this?

/cc @crosbymichael

@crosbymichael
Copy link
Copy Markdown
Member

Ya, sorry about the delay. We are in the middle of two releases right now that we are trying to get out the door so review times are a little long right now.

@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Oct 2, 2018

One problem here is that the labels need to be namespaced. This has runtime, but it should be something like containerd.io/defaults/runtime. This will allow different clients to not step on each others feet.

@krsoninikhil
Copy link
Copy Markdown
Contributor Author

krsoninikhil commented Oct 2, 2018

Hey @stevvooe, I have changed the labels to namespaced version. Didn't realize that's why your example labels in issue are namespaced. Can you please take another look?

@krsoninikhil krsoninikhil force-pushed the defaults3 branch 2 times, most recently from b6faa62 to 2e858a9 Compare October 3, 2018 07:41
@krsoninikhil
Copy link
Copy Markdown
Contributor Author

Hi @stevvooe @crosbymichael, just a ping. Please let me know if this requires any more changes.

@ehazlett
Copy link
Copy Markdown
Member

@krsoninikhil sorry for the delay! can you rebase this please? thanks!

@krsoninikhil krsoninikhil force-pushed the defaults3 branch 2 times, most recently from ffecdab to d9f9d68 Compare January 29, 2019 21:24
options.

Implements same approach of setting defaults for `NewWithConn`.

Signed-off-by: Nikhil Soni <[email protected]>
@krsoninikhil
Copy link
Copy Markdown
Contributor Author

Hi @ehazlett, I've rebased it with master, please let me know if any other changes are required.

Comment thread client.go
@krsoninikhil
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @ehazlett I've added the documentation also, please have a look if it can be improved.

@krsoninikhil
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @ehazlett, just wanted to follow up on this, if any changes are required.

Comment thread container_opts.go Outdated
namespaceService := client.NamespaceService()
if ns, err := namespaces.NamespaceRequired(ctx); err == nil {
if labels, err := namespaceService.Labels(ctx, ns); err == nil {
if snapshotLabel, ok := labels["containerd.io/defaults/snapshotter"]; ok {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how about the const for the label here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean to use defaults package for the label names? That sounds better, should I move both label names to https://github.com/containerd/containerd/blob/master/defaults/defaults.go?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is ok to move it to defaults

Labels that are used for configuring defaults are moved to defaults package

Signed-off-by: Nikhil Soni <[email protected]>
Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@krsoninikhil
Copy link
Copy Markdown
Contributor Author

Hi @ehazlett, not sure why is this not getting merged. Are there any more changes required?

@ehazlett
Copy link
Copy Markdown
Member

ehazlett commented Apr 2, 2019

LGTM

1 similar comment
@dmcgowan
Copy link
Copy Markdown
Member

dmcgowan commented Apr 2, 2019

LGTM

@dmcgowan dmcgowan merged commit 2f60e38 into containerd:master Apr 2, 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

Successfully merging this pull request may close these issues.

9 participants