-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
Fix backward compatibility issue caused by promoting initcontainers f… #33055
Conversation
…rom alpha to beta.
Without this patch, if the user runs the init containers tests in 1.3 branch (including kubectl 1.3...): The dumped pod object in .json looks like
Running the same tests with this patch, the dumped pod object in .json looks like
|
LGTM-- unit test would be good so we don't break it in the future but that can be a followup. |
cc/ @pwittrock |
@eparis I am cherry picking this because it is causing an upgrade failure. Both the problem and solution are well understood. |
GCE e2e build/test passed for commit 4c4623e. |
@k8s-bot unit test this issue: #IGNORE |
@k8s-bot unit test this issue: #IGNORE omg this is annoying |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
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. |
I'll put this in the evidence queue for the amount of work annotations cause not actually being worth the work. Also, the whole point of alpha -> beta is to drop old fields, doing this takes us in the wrong direction (supporting twice as many fields). It would have been better to do nothing than have to jump through these hoops. |
@smarterclayton I agreed with you absolutely on this case. We need to redefine / redesign how to support alpha / beta feature and related promotion workflow. |
I have a todo to write up a simple proposal on the issue open for this so we can try this for 1.5 on a few fields. |
@dchen1107 thanks for fixing this. @smarterclayton I was having similar thoughts as I was writing the PR that this is fixing-up. |
@@ -627,6 +638,11 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error | |||
// back to the caller. | |||
in.Spec.InitContainers = values | |||
} | |||
// If there is a beta annotation, copy to alpha key. | |||
// See commit log for PR #31026 for why we do this. | |||
if valueBeta, okBeta := in.Annotations[PodInitContainerStatusesBetaAnnotationKey]; okBeta { |
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.
We do this a couple lins above (line 623) are we doing this twice intentionally?
If alpha annotation is synced to beta and beta annotations always trumps alpha annotation, then a v1.3 kubelet who only ever uses the alpha annotation will only be able to update the container-statuses once and never again. The apiserver will sync alpha to beta on the initial write then kubelet's subsequent writes of the alpha annotation will be overrwirtten by the beta annotations which contains the kubelet's initial write. |
And if we did this the other way around (alpha trumping beta), v1.4 kubelets couldn't update init container status for pods that had been updated by v1.3 kubelets. The correct way to fix this is to decide the priority of the annotations by looking at the version of the kubelet which I don't think is possible inside conversions. |
@maisem figured this out. |
Thanks Mike. Does that explain why this only impacts GKE and not GCE upgrade tests? |
@pwittrock this also effects GCE. |
That is probably why I didn't do this the first time. Can we just change the test to not expect a particular status, please. On Thu, Sep 22, 2016 at 4:17 PM, Mike Danese notifications@github.com
|
Wait a minute... before we jumped a conclusion:
Is this right? |
I don't understand the comment. v1.3 kubelet only knows about the alpha annotations thus only the first write is commited because there is not beta annotations. All subsequent writes do not commit because the beta annotation (contaning the initial data) always overwrites the alpha annotation according to this conversion logic. Does my explanation make sense? |
Yes that makes sense. |
Status has times in it. What if we let the one with the newest time win? If the annotation with the newest timestamp is synced to the older one, then a v1.3 kubelet who only ever uses the alpha annotation but has the newest timestamp, it will be able to update the container-statuses every time a timestamp advances. The apiserver will sync newest to oldest on the initial write then kubelet's subsequent writes of the alpha annotation will overrwrite by the beta annotations which contains the kubelet's initial write with older time. |
I don't think this is true. The Kubelet puts the status into the internal struct. Then, the internal representation gets converted to the v1 struct with 1.3 conversion code in kubelet. That code copies the internal status into just the alpha field. So, when it goes over the wire, it may have conflicting alpha and beta annotations. But, when it reaches the 1.4 apiserver, the json gets round-tripped before going to storage. So, the alpha key trumps the beta key, and the right status is stored. I am going to test this. |
This sounds like it would fix the issue. It's annoying to put this type of logic in conversions though. |
Also seems fragile. We're seeing this because we're trying to be backwards compatible on a Note that we'll have this same problem going from beta to final, which On Sep 23, 2016, at 5:05 PM, Mike Danese notifications@github.com wrote: If the annotation with the newest timestamp is synced to the older one, This sounds like it would fix the issue. It's annoying to put this type of — |
We decided we are not going to fix for 1.4.0. I will update the relnotes to day that you can't have init container status when your kubelets are 1.3.x and your apiservers are 1.4.0. Alpha features may break. If there is moaning, I will try one of the two fixes I mentioned above for a patch release. |
…ick-of-#33055-upstream-release-1.4 Automatic merge from submit-queue Automated cherry pick of kubernetes#33055 Cherry pick of kubernetes#33055 on release-1.4.
#31026 moves init-container feature from alpha to beta, but only took care the backward compatibility for pod specification, not deal with status. For status, it simply moved from
pods.beta.kubernetes.io/init-container-statuses
topods.beta.kubernetes.io/init-container-statuses
instead of introducing one more pods.beta.kubernetes.io/init-container-statuses. This breaks when the cluster is running with 1.4, but the user is still running with kubectl 1.3.x.Fixed #32711
This change is