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

dry-run: Create Options with dryRun for POST/PUT/PATCH #65105

Merged
merged 2 commits into from Jul 12, 2018

Conversation

apelisse
Copy link
Member

@apelisse apelisse commented Jun 14, 2018

What this PR does / why we need it:
Create new options for Create and Update (through POST/PUT/PATCH).

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

Special notes for your reviewer:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 14, 2018
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 14, 2018
@apelisse apelisse force-pushed the dry-run branch 4 times, most recently from 133048b to 45640e8 Compare June 18, 2018 16:10
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 18, 2018
@@ -65,7 +65,7 @@ func (s *storage) GetDeployment(ctx context.Context, deploymentID string, option
}

func (s *storage) CreateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) {
obj, err := s.Create(ctx, deployment, createValidation, false)
obj, err := s.Create(ctx, deployment, createValidation, &metav1.CreateOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make a metav1.CreateOptionsTODO() function so you can be sure to find and fix all of these after the fact? If you go this route, anyway.

@apelisse apelisse force-pushed the dry-run branch 2 times, most recently from 9a4dd58 to cacf1ac Compare June 19, 2018 22:59
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Jun 20, 2018

// DryRun decides if the request should be completed or not.
// +optional
DryRun bool `json:"dryRun,omitempty" protobuf:"varint,1,opt,name=dryRun"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the decision from the call yesterday was to make this an enumerated string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely, I haven't taken the time to update yet.

@deads2k
Copy link
Contributor

deads2k commented Jun 21, 2018

@sttts I'm behind at the moment. I've got a comment on the prereq pull and the API here needs an update. Got time while I deal with the downstream?


// If IncludeUninitialized is specified, the object may be
// returned without completing initialization.
IncludeUninitialized bool `json:"includeUninitialized,omitempty" protobuf:"varint,2,opt,name=includeUninitialized"`
Copy link
Contributor

Choose a reason for hiding this comment

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

this surprises me. How is this related to dry-run? Why do we expose that via an API "suddenly"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also note that initializers go away (if I have understood @smarterclayton correctly). We should not expose a parameter for something that is planned to be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, found it: 69e757a#diff-7861f33474e4eb8d21cf1d33de5e4d4eL114 had the logic before, with a manually parsed get var. So nvm my comment above.

@@ -260,6 +260,14 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco

ae := request.AuditEventFrom(ctx)
audit.LogRequestObject(ae, obj, scope.Resource, scope.Subresource, scope.Serializer)
} else {
if values := req.URL.Query(); len(values) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is guarded by if checkBody. Looks odd.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the delete handler we call the guarding var allowsOptions.

Copy link
Member Author

@apelisse apelisse Jun 25, 2018

Choose a reason for hiding this comment

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

Yeah, I'm not sure what the point of these variable is, but it looks like "checkBody" and "allowOptions" have the same goal, so this is "correct".

@@ -111,7 +111,9 @@ func createHandler(r rest.NamedCreater, scope RequestScope, admit admission.Inte
}

// TODO: replace with content type negotiation?
includeUninitialized := req.URL.Query().Get("includeUninitialized") == "1"
options := &metav1.CreateOptions{
Copy link
Contributor

@sttts sttts Jun 22, 2018

Choose a reason for hiding this comment

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

Shouldn't this be using the parameter decoder? This looks hacky. Next commit.

}
}
// Timeout is not part of the options, drop it.
delete(values, "timeout")
Copy link
Contributor

Choose a reason for hiding this comment

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

DecodeParameters ignores params that are not in the struct (necessary for new clients speaking to old servers). So, no need for the delete.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -221,7 +221,8 @@ func (r *leaseEndpointReconciler) doReconcile(serviceName string, endpointPorts
}

glog.Warningf("Resetting endpoints for master service %q to %v", serviceName, masterIPs)
return r.endpointRegistry.UpdateEndpoints(ctx, e, rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
// PLEASE_PAY_ATTENTION(apelisse): No idea if this is what we need to do here. Does it make sense to have DryRun here anyway?
Copy link
Contributor

@sttts sttts Jun 22, 2018

Choose a reason for hiding this comment

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

this is the leader election code which speaks directly to the registry to update the (kubernetes service) endpoints. So this certainly does not need do a dry-run here. It is very very special purpose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2018
@deads2k
Copy link
Contributor

deads2k commented Jul 10, 2018

forgot we didn't settle the param type... string vs []string

Heh, I just thought to ask about that too.

/approve cancel

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 11, 2018
@apelisse apelisse force-pushed the dry-run branch 2 times, most recently from 765dc08 to a4b8a7e Compare July 12, 2018 03:36
@@ -453,6 +453,42 @@ type DeleteOptions struct {
// foreground.
// +optional
PropagationPolicy *DeletionPropagation `json:"propagationPolicy,omitempty" protobuf:"varint,4,opt,name=propagationPolicy"`

// Whether the request should be completed and modifications will not be persisted.
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest something more like this:

When present, indicates that modifications should not be persisted.
An invalid or unrecognized dryRun directive will result in a BadRequest response and no further processing of the request.

and then we can add details about what directives are supported as we determine that

@apelisse
Copy link
Member Author

/retest

@deads2k
Copy link
Contributor

deads2k commented Jul 12, 2018

type looks correct now.

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 12, 2018
@liggitt
Copy link
Member

liggitt commented Jul 12, 2018

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jul 12, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, deads2k, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@apelisse
Copy link
Member Author

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 65105, 62948). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit fe88461 into kubernetes:master Jul 12, 2018
k8s-github-robot pushed a commit that referenced this pull request Jul 16, 2018
Automatic merge from submit-queue (batch tested with PRs 66158, 66041, 66210). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Remove manually written typed registries

These were only used in a handful of places, and were not consistently available for all types.

They add a lot of call sites for PRs like #65105 and are not generally useful (very few callers have the ability to construct the underlying store).

This PR switches the scale subresources to use the underlying store directly (like the status subresources already were), and removes the manually written Registry impls.

/sig api-machinery
/kind cleanup
/assign @deads2k

/hold
will hold for #65105 and rebase after that

```release-note
NONE
```
k8s-publishing-bot added a commit to kubernetes/apiextensions-apiserver that referenced this pull request Jul 16, 2018
Automatic merge from submit-queue (batch tested with PRs 66158, 66041, 66210). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Remove manually written typed registries

These were only used in a handful of places, and were not consistently available for all types.

They add a lot of call sites for PRs like kubernetes/kubernetes#65105 and are not generally useful (very few callers have the ability to construct the underlying store).

This PR switches the scale subresources to use the underlying store directly (like the status subresources already were), and removes the manually written Registry impls.

/sig api-machinery
/kind cleanup
/assign @deads2k

/hold
will hold for kubernetes/kubernetes#65105 and rebase after that

```release-note
NONE
```

Kubernetes-commit: 43b801d499f95a4a89fe3319347225e9ad643359
@roycaihw
Copy link
Member

roycaihw commented Oct 1, 2018

It looks like we added meta.v1.CreateOptions and meta.v1.UpdateOptions in this PR, but they weren't reflected in our openapi spec. The dryRun query parameter was only added to the delete operations in the spec. I'm wondering if this was intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

None yet

8 participants