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

Made changes to DELETE API to let v1.DeleteOptions be passed in as a queryParameter #35806

Merged
merged 2 commits into from
Nov 5, 2016

Conversation

bdbauer
Copy link
Contributor

@bdbauer bdbauer commented Oct 28, 2016

Which issue this PR fixes (optional, in fixes #<issue number>(, #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #34856

DELETE requests can now pass in their DeleteOptions as a query parameter or a body parameter, rather than just as a body parameter.

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Oct 28, 2016
@@ -759,7 +759,7 @@ func DeleteResource(r rest.GracefulDeleter, checkBody bool, scope RequestScope,
ctx = api.WithNamespace(ctx, namespace)

options := &api.DeleteOptions{}
if checkBody {
if isGracefulDeletion {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only place this function is called, the passed in value is "isGracefulDeleter". It just seemed like with the change, what we're checking is no longer whether or not to check the body, but whether or not to look for graceful deletion.

Totally fine with leaving it as checkBody.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better for it to be allowsOptions (now that you support query parameters). We may have sub resources that support delete that have different api objects instead of DeleteOptions in the future and this would be one step towards that.

@@ -781,6 +781,13 @@ func DeleteResource(r rest.GracefulDeleter, checkBody bool, scope RequestScope,
scope.err(fmt.Errorf("decoded object cannot be converted to DeleteOptions"), res.ResponseWriter, req.Request)
return
}
} else {
if values := req.Request.URL.Query(); len(values) > 0 {
Copy link
Contributor

@smarterclayton smarterclayton Oct 28, 2016

Choose a reason for hiding this comment

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

please add a test to apiserver_test.go that verifies the 3 permutations (body+query, body, query)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, please take a look

@bdbauer
Copy link
Contributor Author

bdbauer commented Oct 29, 2016

@k8s-bot verify test this

@smarterclayton
Copy link
Contributor

Changes look good, please squash once you get green and I'll label.

@smarterclayton smarterclayton added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Oct 31, 2016
@smarterclayton
Copy link
Contributor

Also please add a release note to the PR description.

@bdbauer
Copy link
Contributor Author

bdbauer commented Nov 1, 2016

@k8s-bot unit test this

@maisem
Copy link

maisem commented Nov 1, 2016

@k8s-bot cvm gce e2e test this

@smarterclayton
Copy link
Contributor

/lgtm

@smarterclayton smarterclayton changed the title WIP: Made changes to DELETE API to let v1.DeleteOptions be passed in as a queryParameter Made changes to DELETE API to let v1.DeleteOptions be passed in as a queryParameter Nov 1, 2016
@k8s-github-robot k8s-github-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 1, 2016
@nikhiljindal
Copy link
Contributor

I am surprised that there is no swagger spec change in this PR.
Dont we document the allowed query params in our swagger spec?

cc @mbohlool

@smarterclayton smarterclayton removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 1, 2016
@smarterclayton
Copy link
Contributor

We need to change the generation code in api_installer and potentially openapi.

@smarterclayton
Copy link
Contributor

Good catch @nikhiljindal

@mbohlool
Copy link
Contributor

mbohlool commented Nov 1, 2016

I've looked into this. Look like some (most?) operations accept SomeOption also as query parameters. Because query parameters cannot be a type (should be simple type like string), it reads the Option type members and decode/encode them as a single query param. I don't see we add those to the spec anywhere, so I suggest this change is not doing worse than what we have by not adding query parameters. We should fix that for all operations.

@smarterclayton
Copy link
Contributor

Don't we already do this in swagger for ListOptions? What's the difference?

On Nov 1, 2016, at 6:45 PM, mbohlool notifications@github.com wrote:

I've looked into this. Look like some (most?) operations accept SomeOption
also as query parameters. Because query parameters cannot be a type (should
be simple type like string), it reads the Option type members and
decode/encode them as a single query param. I don't see we add those to the
spec anywhere, so I suggest this change is not doing worse than what we
have by not adding query parameters. We should fix that for all operations.


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#35806 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p53XvOlXsy6xq_ACbKvrYyHdDDeHks5q58EMgaJpZM4KjtBN
.

@mbohlool
Copy link
Contributor

mbohlool commented Nov 2, 2016

You are right. First I didn't see any ListOptions in swagger, but that is the point. addObjectParams in api_installer will do the trick. I suggest we do the same for DeleteOption.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE Node e2e failed for commit 5e6c034633aa858b33fe9df9bfe2ae742bb1616c. Full PR test history.

The magic incantation to run this job again is @k8s-bot node e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit 5e6c034633aa858b33fe9df9bfe2ae742bb1616c. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins Kubemark GCE e2e failed for commit 5e6c034633aa858b33fe9df9bfe2ae742bb1616c. Full PR test history.

The magic incantation to run this job again is @k8s-bot kubemark e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit 5e6c034633aa858b33fe9df9bfe2ae742bb1616c. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE etcd3 e2e failed for commit 5e6c034633aa858b33fe9df9bfe2ae742bb1616c. Full PR test history.

The magic incantation to run this job again is @k8s-bot gce etcd3 e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 3, 2016
@smarterclayton
Copy link
Contributor

Code as is and we'll figure out how to fix struct types in 1.6

On Nov 3, 2016, at 5:12 PM, bdbauer notifications@github.com wrote:

@smarterclayton https://github.com/smarterclayton Do you mean leave the
code as is, and create an issue to fix the Time/serialized type problem in
the future? Or, get rid of my swagger spec changes, and make a bug to fix
them later?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#35806 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pzvpGJzV2z2ePKfpbokf6JQAnyCzks5q6k4pgaJpZM4KjtBN
.

@mbohlool
Copy link
Contributor

mbohlool commented Nov 3, 2016

We are removing a field from swagger 1.2, is it not a backward compatibility issue?

I can see from typeToJSON function that we should only allow unversioned.Time to pass through. We can fix this in a more abstract way later (file the bug please) but I think we should fix it for unversioned.Time to not have a backward compatibility issue with clients that already using swagger 1.2. It should be a simple fix.

@@ -944,6 +948,11 @@ func addObjectParams(ws *restful.WebService, route *restful.RouteBuilder, obj in
}
switch sf.Type.Kind() {
case reflect.Interface, reflect.Struct:
case reflect.Ptr:
if sf.Type.Elem().Kind() == reflect.Interface || sf.Type.Elem().Kind() == reflect.Struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add something like

// TODO... (add appropriate message here to say this is a hack and need to be fixed in a generic way later, hopefully with a bug number)
if (...) && strings.TrimPrefix(sf.Type.String(),"*") != "unversioned.Time"

to let unversioned.Time pass through and have the removed time field back to the spec.

@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 3, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCE e2e failed for commit cb188d9067addb1a88f9b04161c401a67c3ad98a. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins verification failed for commit 297c8dbfc30c31c66ec08f3602f8cfcb706ba404. Full PR test history.

The magic incantation to run this job again is @k8s-bot verify test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit 297c8dbfc30c31c66ec08f3602f8cfcb706ba404. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@bdbauer
Copy link
Contributor Author

bdbauer commented Nov 4, 2016

@smarterclayton look good?

@smarterclayton smarterclayton added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Nov 4, 2016
@smarterclayton smarterclayton added this to the v1.5 milestone Nov 4, 2016
@smarterclayton
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 4, 2016
@k8s-github-robot
Copy link

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

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 17fda0a into kubernetes:master Nov 5, 2016
@jessfraz jessfraz added cherrypick-candidate cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. labels Nov 8, 2016
@jessfraz jessfraz modified the milestones: v1.4, v1.5 Nov 8, 2016
jessfraz added a commit that referenced this pull request Nov 10, 2016
…6-upstream-release-1.4

Automated cherry pick of #35806
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.4" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API uses body in DELETE requests
10 participants