Commit b1dba6cd authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #37328 from caesarxuchao/fix-tpr-deleteoptions

Automatic merge from submit-queue (batch tested with PRs 37328, 38102, 37261, 31321, 38146) Make thirdparty codec able to decode DeleteOptions Fix #37278. Without this PR, the gvk sent to the delegated codec will be the thirdparty one, which is not recognized by the delegated codec (usually api.Codecs).
parents f299a001 6534661a
...@@ -370,6 +370,10 @@ func (t *thirdPartyResourceDataDecoder) Decode(data []byte, gvk *schema.GroupVer ...@@ -370,6 +370,10 @@ func (t *thirdPartyResourceDataDecoder) Decode(data []byte, gvk *schema.GroupVer
} }
return o, outGVK, nil return o, outGVK, nil
default: default:
if gvk != nil && registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
// delegate won't recognize a thirdparty group version
gvk = nil
}
return t.delegate.Decode(data, gvk, into) return t.delegate.Decode(data, gvk, into)
} }
......
...@@ -161,7 +161,15 @@ var _ = Describe("ThirdParty resources [Flaky] [Disruptive]", func() { ...@@ -161,7 +161,15 @@ var _ = Describe("ThirdParty resources [Flaky] [Disruptive]", func() {
framework.Failf("expected: %#v, saw in list: %#v", foo, list.Items[0]) framework.Failf("expected: %#v, saw in list: %#v", foo, list.Items[0])
} }
if _, err := f.ClientSet.Extensions().RESTClient().Delete().AbsPath("/apis/company.com/v1/namespaces/default/foos/foo").DoRaw(); err != nil { // Need to manually do the serialization because otherwise the
// Content-Type header is set to protobuf, the thirdparty codec in
// the API server side only accepts JSON.
deleteOptionsData, err := json.Marshal(v1.NewDeleteOptions(10))
framework.ExpectNoError(err)
if _, err := f.ClientSet.Core().RESTClient().Delete().
AbsPath("/apis/company.com/v1/namespaces/default/foos/foo").
Body(deleteOptionsData).
DoRaw(); err != nil {
framework.Failf("failed to delete: %v", err) framework.Failf("failed to delete: %v", err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment