Skip to content

Add a server side exporter parameter and impl.#17483

Merged
k8s-github-robot merged 3 commits intokubernetes:masterfrom
brendandburns:kubectl5
Dec 17, 2015
Merged

Add a server side exporter parameter and impl.#17483
k8s-github-robot merged 3 commits intokubernetes:masterfrom
brendandburns:kubectl5

Conversation

@brendandburns
Copy link
Copy Markdown
Contributor

This is mostly an import of the existing openshift code

Ref: #13038

@smarterclayton @bgrant0607

@k8s-github-robot
Copy link
Copy Markdown

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 19, 2015
@bgrant0607
Copy link
Copy Markdown
Member

Thanks, we do need export, and I do think it should be in the server.

cc @liggitt @derekwaynecarr re. whether this can be extended to work for Openshift

cc @lavalamp to see whether he has suggestions

I would prefer to put the individual export methods into each resource's strategy implementation. As we've found with the namespace deleter, centralizing the code like this makes it likely that it will be overlooked when adding new resources.

I think a subresource isn't needed, so the query parameter is probably fine.

Will take a closer look tomorrow.

cc @janetkuo

@bgrant0607 bgrant0607 added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Nov 19, 2015
@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Nov 19, 2015

GCE e2e test build/test passed for commit 2014d975b3ad3c57fb58ccec7752812222faaeb1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we do this here clients can't tell what methods support exporting. Servers outside the Kube code base also can't provide an export behavior. the pattern we use for optional behavior like this is to support another interface on the storage object which calls to the strategy. I would prefer to test for the interface in apiinstaller and pass it down to the get handler, and also add the parameter to the go-restful description there.

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.

Swagger supports specifying query parameters, though we don't use it consistently.

One could view this as a specialized form of field selection.

Probably every resource that supports GET should support export, even if it's a no-op.

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.

If we did leave this as a query param, we'd want to handle it similarly to other query params. See DeleteOptions and ListOptions as examples.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we did leave this as a query param, we'd want to handle it similarly to other query params.
+1

@bgrant0607
Copy link
Copy Markdown
Member

Somewhat related: #17333

Eventually we may want to export just what the user configured, both in terms of fields and resources, and if a user did a bulk export, they won't want to export resources (e.g., pods) created by other resources (e.g., RCs).

OTOH, if they were using kubectl apply already, they probably don't need export.

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.

Why do we need exact? What does it mean?

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.

This is copied from openshift, exact means "preserve things that are cluster dependent, like namespace"

@bgrant0607
Copy link
Copy Markdown
Member

One thing I'd like to use this for is edit: export, edit, then patch. @janetkuo Do you think that would work?

The benefit is that it would remove cruft like the uid, creationTimestamp, status, etc.

@brendandburns
Copy link
Copy Markdown
Contributor Author

@smarterclayton what you suggest is tricky to do given the way the framework is put together. The best you could do is either pass an Exporter to GetResourceWithOptions/GetResource or augment the Getter and GetterWithOptions interfaces to include an Export method.

I think another way to achieve what you are asking for @smarterclayton is to allow upstream users to inject their own Exporter, that seems to accomplish what you need.

@bgrant0607 there is already a GetterWithOptions but those options are an opaque runtime.Object so we would have to add an ExportOptions object from the query, but we would have to plumb it in addition to the existing Getter/GetterWithOptions interfaces (see above).

So then my concrete proposal would be to make

type GetterWithOptions interface {
  Get(ctx api.Context, name string, opts runtime.Object, export ExportOptions)
}

type Getter interface {
  Get(ctx api.Context, name string, export ExportOptions)
}

and then drive that down to a concrete implementation in the Strategy.

Does that work for both people?

I would very much like to enable:

kubectl --context=cluster-a export all | kubectl --context=cluster-b create -f -

to clone one cluster into another

@smarterclayton
Copy link
Copy Markdown
Contributor

I think export is different from the intent of getterwithoptions. The
latter is intended to support non-uniform subresources. We could simply
dictate that the presence of export / exact triggers the Export interface,
which does get and then passes that through the strategy filter. I did not
originally intent for getter with options and normal get to be used on base
resources (only virtual ones). Getterwithoptions is an escape hatch rather
than something like watch (export to me is a lot like watch)

On Nov 19, 2015, at 7:15 PM, Brendan Burns notifications@github.com wrote:

@smarterclayton https://github.com/smarterclayton what you suggest is
tricky to do given the way the framework is put together. The best you
could do is either pass an Exporter to GetResourceWithOptions/GetResource
or augment the Getter and GetterWithOptions interfaces to include an Export
method.

I think another way to achieve what you are asking for @smarterclayton
https://github.com/smarterclayton is to allow upstream users to inject
their own Exporter, that seems to accomplish what you need.

@bgrant0607 https://github.com/bgrant0607 there is already a
GetterWithOptions but those options are an opaque runtime.Object so we
would have to add an ExportOptions object from the query, but we would have
to plumb it in addition to the existing Getter/GetterWithOptions interfaces
(see above).

So then my concrete proposal would be to make

type GetterWithOptions interface {
Get(ctx api.Context, name string, opts runtime.Object, export ExportOptions)
}
type Getter interface {
Get(ctx api.Context, name string, export ExportOptions)
}

and then drive that down to a concrete implementation in the Strategy.

Does that work for both people?

I would very much like to enable:

kubectl --context=cluster-a export all | kubctl --context=cluster-b create -f -

to clone one cluster into another


Reply to this email directly or view it on GitHub
#17483 (comment)
.

@brendandburns
Copy link
Copy Markdown
Contributor Author

So to be concrete, what you are suggesting is that in GetResource we cast the Getter to an Exporter if the export options are present on the request? That is do-able. Alternately, we could force the GetResource handler to take an Exporter as a parameter and have it be nil if export isn't supported.

Let me know which one you prefer.

@smarterclayton
Copy link
Copy Markdown
Contributor

The latter - sorry for the delay, in meetings.

On Fri, Nov 20, 2015 at 12:29 PM, Brendan Burns notifications@github.com
wrote:

So to be concrete, what you are suggesting is that in GetResource we cast
the Getter to an Exporter if the export options are present on the
request? That is do-able. Alternately, we could force the GetResource
handler to take an Exporter as a parameter and have it be nil if export
isn't supported.

Let me know which one you prefer.


Reply to this email directly or view it on GitHub
#17483 (comment)
.

@bgrant0607
Copy link
Copy Markdown
Member

cc @lavalamp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would strongly prefer to see something added to the strategy (like the list, get, create, etc behaviors). You can even add a default to the generic one and get most of this for free, it looks like.

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Nov 21, 2015

GCE e2e build/test failed for commit 4bf228835229f65458b8d0872f8a9101e66e72dd.

@brendandburns
Copy link
Copy Markdown
Contributor Author

Moved over to the strategy based approach suggested by @smarterclayton, @lavalamp and others. please take another look.

--brendan

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Nov 21, 2015

GCE e2e build/test failed for commit 09681562d70b0165279e335c9c3171f48e851d9b.

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Nov 21, 2015

GCE e2e build/test failed for commit 44d948dcf15e642a40e9285849b41e7142a9bbae.

@brendandburns
Copy link
Copy Markdown
Contributor Author

ping @smarterclayton

@k8s-bot please test this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this check? Would delegate it to the strategy implementor.

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.

Why force every strategy to put the same boilerplate at the top of each export method?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't need to do it in the strategy. The etcd generic store can do it and call the strategy to do the rest. I think it'd make more sense there.

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.

done.

@smarterclayton
Copy link
Copy Markdown
Contributor

A few comments, also needs a test in apiserver_test, and a strategy test for each type.

@brendandburns brendandburns force-pushed the kubectl5 branch 2 times, most recently from dc8f168 to 8cfe4a7 Compare December 16, 2015 22:31
@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 16, 2015

GCE e2e test build/test passed for commit 060836c4570deacaf98322a0095a6134375fb9de.

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 16, 2015

GCE e2e test build/test passed for commit fb55ab4c8280b8d2f6d79f79db20e9361aff696e.

@k8s-github-robot
Copy link
Copy Markdown

Labelling this PR as size/XL

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 16, 2015
@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 16, 2015

GCE e2e test build/test passed for commit 8cfe4a72a202e16cb125c3ab5ec9f8aea0d42e6f.

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 16, 2015

GCE e2e test build/test passed for commit dc8f1683ae4081f0a3c0594f84d499ebc99beba7.

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 16, 2015

GCE e2e test build/test passed for commit 2efcccf.

@brendandburns
Copy link
Copy Markdown
Contributor Author

@k8s-bot unit test this please

@k8s-github-robot
Copy link
Copy Markdown

Labelling this PR as size/XXL

@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 17, 2015
@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 17, 2015

GCE e2e test build/test passed for commit a60069b.

@k8s-github-robot
Copy link
Copy Markdown

Labelling this PR as size/XS

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 17, 2015
@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 17, 2015

GCE e2e test build/test passed for commit 884c163.

@k8s-github-robot
Copy link
Copy Markdown

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented Dec 17, 2015

GCE e2e test build/test passed for commit 884c163.

@k8s-github-robot
Copy link
Copy Markdown

Automatic merge from submit-queue

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

Labels

kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants