Merge pull request #29724 from brendandburns/thirdparty3

Automatic merge from submit-queue

Fix third party APIResource reporting

@polvi @caesarxuchao @deads2k 

This "fixes" some additional bugs in third party `APIResourceList` reporting.

This code needs a bunch of cleanup, and more tests, but sending it out for a quick smell check review in case I'm doing something stupid.

Fixes the bug referenced here:  https://github.com/kubernetes/kubernetes/pull/28414#issuecomment-235346108 and in https://github.com/kubernetes/kubernetes/issues/23831

Fixes https://github.com/kubernetes/kubernetes/issues/25570
This commit is contained in:
Kubernetes Submit Queue
2016-08-13 17:10:20 -07:00
committed by GitHub
5 changed files with 212 additions and 56 deletions

View File

@@ -509,7 +509,7 @@ func TestDiscoveryAtAPIS(t *testing.T) {
}
thirdPartyGV := unversioned.GroupVersionForDiscovery{GroupVersion: "company.com/v1", Version: "v1"}
master.addThirdPartyResourceStorage("/apis/company.com/v1", nil,
master.addThirdPartyResourceStorage("/apis/company.com/v1", "foos", nil,
unversioned.APIGroup{
Name: "company.com",
Versions: []unversioned.GroupVersionForDiscovery{thirdPartyGV},
@@ -576,10 +576,18 @@ func initThirdPartyMultiple(t *testing.T, versions, names []string) (*Master, *e
},
},
}
err := master.InstallThirdPartyResource(api)
if !assert.NoError(err) {
t.Logf("Failed to install API: %v", err)
t.FailNow()
hasRsrc, err := master.HasThirdPartyResource(api)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if !hasRsrc {
err := master.InstallThirdPartyResource(api)
if !assert.NoError(err) {
t.Errorf("Failed to install API: %v", err)
t.FailNow()
}
} else {
t.Errorf("Expected %s: %v not to be present!", names[ix], api)
}
}
@@ -1081,7 +1089,7 @@ func testInstallThirdPartyResourceRemove(t *testing.T, version string) {
}
path := makeThirdPartyPath("company.com")
master.RemoveThirdPartyResource(path)
master.RemoveThirdPartyResource(path + "/foos")
resp, err = http.Get(server.URL + "/apis/company.com/" + version + "/namespaces/default/foos/test")
if !assert.NoError(err) {