-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Replica Controller Name Annotation in Pods #5842
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. |
@bgrant0607 before I address @ravigadde's comments do you want to consider regular attributes (instead of annotations)? I mentioned in the pull request why I think it could be preferable. Should we queue this behind the pod templates? (The reference will be to the template instead of the RC) |
It is a feature that replication controllers do not own the pods they create and also can manage pods they do not create. I am strongly opposed to changing those properties. Also, annotations are not used for filtering -- that would be labels. I'll look at the rest. |
@@ -60,6 +60,8 @@ type RealPodControl struct { | |||
// Time period of main replication controller sync loop | |||
const DefaultSyncPeriod = 10 * time.Second | |||
|
|||
const RCNAME_ANNOTATION = "replicationControllerName" |
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.
Do you care more about the replication controller, or the pod template used to create the pod?
Any annotation created by the system should be namespaced. I believe we've used kubernetes.io/
elsewhere.
More explanation about the replication controller design can be found here: |
@bgrant0607 do you think it would be acceptable if the replication controller would keep the annotation updated? I think your problem with it is that at every Anyway it seems that the real name of the annotation should be I experimented with some json in the annotation, e.g.
Now that we realized that it's actually a |
The annotation is similar to, but not exactly the same as, the existence dependence discussed here: #1535 (comment) Assuming we want the relationship to be represented regardless of deletion behavior, then I suggest we keep the annotation. Like "description" annotations, it shouldn't be a direct metadata field if it has no semantic purpose. Besides, not all pods will be created by other API objects. The only case in which either the annotation or dependence would need to be updated would be the case where the pods were to be orphaned and then put under control of a new replication controller. Assuming that we want to support re-parenting in this scenario, we'll need a new subresource, similar to /binding, in which case the annotation could be updated as well. Given that the current default behavior of ReplicationController is to orphan pods on delete and that we don't have existence dependencies or the subresource, I recommend going with the It's also worth thinking about what will happen when we split pod templates out as separate resources #5012. |
@bgrant0607 I thought that given comment #5842 (comment) it was certain that we wanted to support it. Or are the two cases slightly different (user-created and previous-controller-created)? Is there any case where two controllers may overlap? E.g. an rc with selector
@bgrant0607 is the existence dependencies / subresource something that is actively worked on? It seems that in the long term those are your preferred solutions. How much work would it be? If it's doable I could work on one of them. Also, for |
Yes, I do want to support reparenting, in general. No, it is not legal for 2 controllers to overlap. We've tried a couple times to validate that, but there are some complications. No, existence dependencies and the subresource are not actively being worked on yet. I'm not sure how much work they'd be. The subresource should be straightforward. Either a garbage-collection agent needs to be created in order to implement existence dependencies, or that functionality needs to be added to all existing object managers, so that's harder. Yes, for created-by, a JSON-ized ObjectReference is fine. |
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
@bgrant0607 I think the patch should be fine now (no idea why shippable breaks) |
Thanks. LGTM. |
Replica Controller Name Annotation in Pods
return | ||
} | ||
|
||
createdByRefJson, err := json.Marshal(createdByRef) |
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.
@simon3z @bgrant0607 This serializes our internal, unversioned object. These annotations will not be readable as soon as that changes!
This should use some codec's Encode function.
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.
It's a bit awkward, because the field doesn't go through conversion, so the versioned rep isn't really appropriate, either. I do want to get rid of the json tags on the internal rep., however, which would also break this.
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.
I suppose using the latest stable API version would be better. Really, the RC controller shouldn't be using the internal rep. at all.
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.
@lavalamp Did you file an issue to fix this? How did you discover it?
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.
Noticed while reviewing #6866. I asked for a TODO there, but I'll file an issue, too.
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.
Also, now that you got me actually thinking about it, this is gonna be a nightmare for any sort of schema updating script-- it's going to have to understand the annotations to be correct.
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.
Filed #7322.
As discussed with @bgrant0607 in #3676 these patches are adding a pod annotation ("replicationControllerName") to reference the replica controller that generated a pod.
The PR consists of two patches:
2 probably needs some discussion.
In fact today it is possible that a user-created pod (if matching the selector) could be counted as part of a replica controller (with the side effect of e.g. another pod being killed).
We could discuss if that's a bug or a feature. In my opinion it is a bug (a user-initiated pod should successfully start and not affect a replication controller pod).
Considering the replication controller annotation when counting the pods (patch 2) makes sure that a replication controller only looks after pods that it generated and it is managing.
If we go down this road we may consider some attribute more "official" than an annotation.
Update: I forgot to mention that patch 2 on a running cluster is dangerous (not even backward compatible), probably all the replication controller will spawn new containers (effectively doubling the replicas).
For this reason I think that this annotation/attribute is vital to be introduced ASAP, because if we don't tag the pods spawned by a replication controller now, we'll never be able to introduce it later.