-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Persist Bindings annotations alongside pod Host assignment #5005
Conversation
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. |
FWIW I've already signed the CLA |
I can do the review on this |
Found the problem: PEBKAC. It's actually working as expected. |
// can't really be helped, since there's not really a way to do atomic | ||
// multi-object changes in etcd. | ||
if _, err2 := r.setPodHostTo(ctx, podID, machine, ""); err2 != nil { | ||
glog.V(1).Infof("failing pod %v because constraint checks failed", podID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make this v1. It will happen too frequently. I suggest v4.
Gratefully punting review to @smarterclayton, who is also touching /bindings right now. This behavior needs to be documented, ideally somewhere that would appear in the swagger (e.g., in the description on the ObjectMeta field for Binding), as well as in a .md doc. Note that descriptions on fields for v1beta3 are in flight. |
related work in #5054 |
Sorry for the delay, will get to this very soon. |
err2 = r.store.Helper.AtomicUpdate(podKey, &api.Pod{}, false, func(obj runtime.Object) (runtime.Object, error) { | ||
if pod, ok := obj.(*api.Pod); !ok { | ||
return nil, fmt.Errorf("unexpected object: %#v", obj) | ||
} else if pod.Status.Host != machine { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the else's here? Since you're returning they're not necessary and it fits our style more (if the if block returns, never use else).
Just my comment and Brian's I think. Sorry again for the delay. |
Fails gofmt:
|
} | ||
pod.Status.Host = "" //TODO(jdef) get rid of this once BoundPods goes away | ||
pod.Status.Phase = api.PodFailed | ||
pod.Status.Message = fmt.Sprintf("Assignment to host %v failed", machine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was too terse last time. Please also populate Reason with something like HostAssignmentFailed
. The more detailed message is useful, but the concise form (in particular, without the hostname) is useful for stats collection.
@bgrant0607 It looks like reason codes are pretty specific and should closely track HTTP codes. So I changed the pod.status.message to what you suggested, and set the api.status.reason to Conflict. The api.status.message will include a more detailed description of what went wrong. Sound ok? |
err = etcderr.InterpretCreateError(err, "binding", "") | ||
out = &api.Status{Status: api.StatusSuccess} | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, this is somewhat wrong, because InterpretCreateError may already create an appropriate api.Status. If assignPod needs to return special errors, that should happen in that method (using errors.NewConflict)
@smarterclayton just re-read your comment after I pushed the "clean up error handling" change. PTAL and let me know if you still think I should create NewConflict errors in assignPod. |
err = etcderr.InterpretCreateError(err, "binding", "") | ||
err = r.assignPod(ctx, binding.PodID, binding.Host, binding.Annotations) | ||
if err = etcderr.InterpretCreateError(err, "binding", ""); err != nil { | ||
if _, ok := err.(*errors.StatusError); !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for now. Bindings internal storage will be cleanup up over successive iterations so we don't need the perfect solution now.
This looks good to me - can you go ahead and squash? |
squashed On Mon, Mar 9, 2015 at 11:30 AM, Clayton Coleman notifications@github.com
James DeFelice |
Will merge after tests pass again. |
Hrm, seeing a transient failure that looks related to this pull (not sure if it's coincidence or enemy action):
|
Funny, I think it's related to another PR of mine that was just merged. I'll take a look |
@smarterclayton I'm not sure what's holding up the coveralls test. From what I can see the tests pass. |
K, will look in a bit
|
} | ||
pod.Status.Host = "" //TODO(jdef) get rid of this once BoundPods goes away | ||
pod.Status.Phase = api.PodFailed | ||
pod.Status.Message = "HostAssignmentFailed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pod status message should be more informative, such as including the host. Search the code for examples.
Don't worry about coveralls. It appears to be wedged. |
Thanks for the feedback @bgrant0607. I've pushed some changes to address your concerns. |
@@ -1025,6 +1025,13 @@ const ( | |||
// Status code 409 | |||
StatusReasonConflict StatusReason = "Conflict" | |||
|
|||
// StatusReasonResourceConflict means the requested update operation cannot be completed | |||
// due to a resource conflict in the operation. The client may need to alter the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "due to conflicting usage of underlying system/infrastructure resources".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
On Wed, Mar 11, 2015 at 6:29 PM, Brian Grant notifications@github.com
wrote:
In pkg/api/types.go
#5005 (comment)
:@@ -1025,6 +1025,13 @@ const (
// Status code 409
StatusReasonConflict StatusReason = "Conflict"
- // StatusReasonResourceConflict means the requested update operation cannot be completed
- // due to a resource conflict in the operation. The client may need to alter the request.
How about "due to conflicting usage of underlying system/infrastructure
resources".—
Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/pull/5005/files#r26262653
.
James DeFelice
585.241.9488 (voice)
650.649.6071 (fax)
addressed your concerns @bgrant0607 PTAL |
Code LGTM. Are you able to run the e2e test? The change to write Spec.Host in setPodHostTo broke it, due to somewhat fragile assumptions. We just added documentation of status codes to docs/api-conventions.md. Could you please add documentation on ResourceConflict there? |
Alternatively, we could remove ResourceConflict and change back to Conflict. Host mismatch or etcd collision are the only reasons for failure now, since we removed hostport conflict detection. We'll likely want to add back some best-effort constraint checking at some point. See: But we don't have it now. I'll leave it up to you. |
Removed ResourceConflict. I don't want to muddy the water with additional On Thu, Mar 12, 2015 at 9:43 PM, Brian Grant notifications@github.com
James DeFelice |
@bgrant0607 any final thoughts? |
LGTM |
Persist Bindings annotations alongside pod Host assignment
as per @bgrant0607:
In this PR, Bindings.Annotations are merged with those of the Pod, overwriting the values of any pre-existing keys. If the binding fails, the pod is flagged as failed.
Also added error checking in Binding creation, returning a more appropriate Status object on errors.
cc @smarterclayton @erictune