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

Minimal status mutation change #4779

Merged
merged 1 commit into from
Mar 3, 2015

Conversation

smarterclayton
Copy link
Contributor

PUT /api/v1beta3/namespaces/default/pods/foo/status
{
  "metadata": {...}, // allowed for valid values
  "spec": {}, // ignored
  "status": {...}, // allowed, except for Host
}

Exposes the simplest possibly change. Needs a slight refactoring
to RESTUpdateStrategy to split merging.

Sets the stage for #2726

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.


ReturnDeletedObject: true,
AfterDelete: bindings.AfterDelete,
statusStore.UpdateStrategy = pod.StatusStrategy
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work? StatusStrategy does not implement some methods from RESTUpdateStrategy:

  1. NamespaceScoped() bool
  2. AllowCreateOnUpdate() bool

Copy link
Contributor

Choose a reason for hiding this comment

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

Forget that! I've missed that you have anonymous field Strategy.

@fgrzadkowski
Copy link
Contributor

I have a general question. Before this PR pod status was periodically fetched by pod_cache and stored in memory. It was written to etcd only when someone updated pod via REST API. This PR combined with #4561 (thanks for doing part of the work! :) ) will result in writing status for every update. Is this expected? I imagine this can have a significant effect on performance.

@smarterclayton
Copy link
Contributor Author

This doesn't necessarily make that change, but status updates can definitely ramp up the write load. We need to test the change for sure and get a feel for the cost.

On Feb 25, 2015, at 5:00 AM, Filip Grzadkowski notifications@github.com wrote:

I have a general question. Before this PR pod status was periodically fetched by pod_cache and stored in memory. It was written to etcd only when someone updated pod via REST API. This PR combined with #4561 (thanks for doing part of the work! :) ) will result in writing status for every update. Is this expected? I imagine this can have a significant effect on performance.


Reply to this email directly or view it on GitHub.

@jdef
Copy link
Contributor

jdef commented Feb 26, 2015

xref #4103

@bgrant0607
Copy link
Member

LGTM

@bgrant0607
Copy link
Member

@bprashanth: You'll want to use this pattern for replicationcontroller status.

@smarterclayton
Copy link
Contributor Author

I'll be cleaning this up soon, then we'll do the pod-status writer in a second pull.

On Feb 26, 2015, at 7:43 PM, Brian Grant notifications@github.com wrote:

@bprashanth: You'll want to use this pattern for replicationcontroller status.


Reply to this email directly or view it on GitHub.

@smarterclayton smarterclayton changed the title WIP - Minimal status mutation change Minimal status mutation change Feb 27, 2015
@smarterclayton
Copy link
Contributor Author

I'll do the cleanup and other work in a follow up (since this can standalone)

@smarterclayton
Copy link
Contributor Author

Ready for final review

@bgrant0607
Copy link
Member

_output/local/go/src/github.com/GoogleCloudPlatform/kubernetes/pkg/registry/etcd/etcd_test.go:44: assignment count mismatch: 2 = 3


allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)

// TODO: allow change when bindings are properly decoupled from pods
Copy link
Member

Choose a reason for hiding this comment

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

In what situation would we allow changes? Pods don't get rescheduled, and I'm thinking that the cleanest way to deal with rejection from Kubelet is to consider the pod dead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we ever wanted to allow scheduler to mutate status instead of binding, but no other reason. I'll remove the todo

On Feb 26, 2015, at 11:09 PM, Brian Grant notifications@github.com wrote:

In pkg/api/validation/validation.go:

@@ -647,6 +647,23 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
return allErrs
}

+// ValidatePodStatusUpdate tests to see if the update is legal for an end user to make. newPod is updated with fields
+// that cannot be changed.
+func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {

  • allErrs := errs.ValidationErrorList{}
  • allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
  • // TODO: allow change when bindings are properly decoupled from pods
    In what situation would we allow changes? Pods don't get rescheduled, and I'm thinking that the cleanest way to deal with rejection from Kubelet is to consider the pod dead.


Reply to this email directly or view it on GitHub.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also thinking we should get rid of host in Status, and just set the one in Spec -- the scheduler is a finalizer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So would end users be able to set it?

On Feb 26, 2015, at 11:12 PM, Brian Grant notifications@github.com wrote:

In pkg/api/validation/validation.go:

@@ -647,6 +647,23 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
return allErrs
}

+// ValidatePodStatusUpdate tests to see if the update is legal for an end user to make. newPod is updated with fields
+// that cannot be changed.
+func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {

  • allErrs := errs.ValidationErrorList{}
  • allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
  • // TODO: allow change when bindings are properly decoupled from pods
    I'm also thinking we should get rid of host in Status, and just set the one in Spec -- the scheduler is a finalizer.


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Never mind, binding sets it. I keep forgetting....

On Feb 26, 2015, at 11:12 PM, Brian Grant notifications@github.com wrote:

In pkg/api/validation/validation.go:

@@ -647,6 +647,23 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
return allErrs
}

+// ValidatePodStatusUpdate tests to see if the update is legal for an end user to make. newPod is updated with fields
+// that cannot be changed.
+func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {

  • allErrs := errs.ValidationErrorList{}
  • allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
  • // TODO: allow change when bindings are properly decoupled from pods
    I'm also thinking we should get rid of host in Status, and just set the one in Spec -- the scheduler is a finalizer.


Reply to this email directly or view it on GitHub.

@bgrant0607
Copy link
Member

LGTM, other than the test failure and TODO.

    PUT /api/v1beta3/namespaces/default/pods/foo/status
    {
      "metadata": {...}, // allowed for valid values
      "spec": {}, // ignored
      "status": {...}, // allowed, except for Host
    }

Exposes the simplest possibly change. Needs a slight refactoring
to RESTUpdateStrategy to split merging which can be done in a
follow up.
@smarterclayton
Copy link
Contributor Author

Fixed comments and failing test.

@jdef
Copy link
Contributor

jdef commented Mar 2, 2015

bgrant0607 added a commit that referenced this pull request Mar 3, 2015
@bgrant0607 bgrant0607 merged commit fca9fd6 into kubernetes:master Mar 3, 2015
@fgrzadkowski
Copy link
Contributor

I synced to HEAD, but my cluster does not recognize this new handler. Is this only available in v1beta3?

@fgrzadkowski
Copy link
Contributor

It works after kube-down/kube-up. I thought that dev-build-and-push should be enough, but apparently not.

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.

6 participants