-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Pass runtime.Object to Helper.Create/Replace #16441
Conversation
Labelling this PR as size/L |
cc @deads2k @smarterclayton @kubernetes/kubectl |
Object: &api.Pod{ | ||
ObjectMeta: api.ObjectMeta{Name: "foo"}, | ||
Spec: apitesting.DeepEqualSafePodSpec(), | ||
}, | ||
ExpectObject: &api.Pod{ | ||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "10"}, | ||
Spec: apitesting.DeepEqualSafePodSpec(), |
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 illustrates the encode/decode/defaulting/encode that was happening client-side
lgtm |
LGTM |
GCE e2e test build/test passed for commit b58e62e. |
We are serializing the object client side using the mapping codec to create the annotation for kubectl apply. We are also deserializing it client side to retrieve the previous version for the three way diff. I'm wondering if this process could introduce api version artifacts into the patch that we generate, and/or if we should fail patch generation if the live version is different from the version in the annotation? However, I can't think of any specific examples of problems caused by this process.
I'm therefore inclined to suggest that we keep the annotation and patch generation version independent. Is there anything I'm overlooking here that might argue otherwise? cc @bgrant0607, @ghodss, @janetkuo, @kubernetes/kubectl |
cc @jackgr |
Please cherrypick this into 1.1. |
Not sure what you're proposing... generating the JSON for the annotation using the internal codec? Anything serialized has to use a versioned codec. |
@liggitt it serializes the user input to the command using json.Marshal to generate the annotation, when the user input is present, and the object retrieved from the server using Mapping.Codec.Encode, to generate the annotation when no user input is present. See this method. The object retrieved from the server is serialized for the patch computation using Mapping.Codec.Encode here. PTAL. |
We do not want defaults applied in the annotation, which means we can't apply conversion, either. |
The straight |
See this method for the difference between them. As I read it, |
@k8s-bot unit test this |
I don't have time to look at the code, but the whole point of the annotations is to capture user intent and to detect changes in that intent (removal of specified items, such as containers, in particular). Is the problem that we don't understand what the alternative implementations do, or that we don't agree on which is preferred? If the latter, could someone please clearly explain the difference in behavior between the two? |
can we move the discussion of the annotation encoding to a new issue? that is unrelated to the issue this PR is fixing |
Created #16543 to continue this discussion. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test failed for commit b58e62e. |
@k8s-bot test this please |
GCE e2e test build/test passed for commit b58e62e. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit b58e62e. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit b58e62e. |
Automatic merge from submit-queue |
Auto commit by PR queue bot
…1-upstream-release-1.1 Auto commit by PR queue bot
…k-of-#16441-upstream-release-1.1 Auto commit by PR queue bot
…k-of-#16441-upstream-release-1.1 Auto commit by PR queue bot
kubectl commands were serializing using the info.Mapping.Codec, rather than letting the RESTClient serialize the object using the Codec for the version it expected to speak to the server with.
This also meant that in
modify
cases, the object would get encoded, decoded, and re-encoded, which would apply defaulting client-side, which is not ideal.