mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Tolerate group discovery errors in e2e ns cleanup
This commit is contained in:
parent
0a88323013
commit
5acd5b52f4
@ -70,6 +70,10 @@ var _ = SIGDescribe("Aggregator", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
func cleanTest(f *framework.Framework, block bool) {
|
func cleanTest(f *framework.Framework, block bool) {
|
||||||
|
// delete the APIService first to avoid causing discovery errors
|
||||||
|
aggrclient := f.AggregatorClient
|
||||||
|
_ = aggrclient.ApiregistrationV1beta1().APIServices().Delete("v1alpha1.wardle.k8s.io", nil)
|
||||||
|
|
||||||
namespace := "sample-system"
|
namespace := "sample-system"
|
||||||
client := f.ClientSet
|
client := f.ClientSet
|
||||||
_ = client.ExtensionsV1beta1().Deployments(namespace).Delete("sample-apiserver", nil)
|
_ = client.ExtensionsV1beta1().Deployments(namespace).Delete("sample-apiserver", nil)
|
||||||
@ -80,8 +84,6 @@ func cleanTest(f *framework.Framework, block bool) {
|
|||||||
_ = client.CoreV1().Namespaces().Delete(namespace, nil)
|
_ = client.CoreV1().Namespaces().Delete(namespace, nil)
|
||||||
_ = client.RbacV1beta1().ClusterRoles().Delete("wardler", nil)
|
_ = client.RbacV1beta1().ClusterRoles().Delete("wardler", nil)
|
||||||
_ = client.RbacV1beta1().ClusterRoleBindings().Delete("wardler:sample-system:anonymous", nil)
|
_ = client.RbacV1beta1().ClusterRoleBindings().Delete("wardler:sample-system:anonymous", nil)
|
||||||
aggrclient := f.AggregatorClient
|
|
||||||
_ = aggrclient.ApiregistrationV1beta1().APIServices().Delete("v1alpha1.wardle.k8s.io", nil)
|
|
||||||
if block {
|
if block {
|
||||||
_ = wait.Poll(100*time.Millisecond, 5*time.Second, func() (bool, error) {
|
_ = wait.Poll(100*time.Millisecond, 5*time.Second, func() (bool, error) {
|
||||||
_, err := client.CoreV1().Namespaces().Get("sample-system", metav1.GetOptions{})
|
_, err := client.CoreV1().Namespaces().Get("sample-system", metav1.GetOptions{})
|
||||||
|
@ -1132,6 +1132,28 @@ func countRemainingPods(c clientset.Interface, namespace string) (int, int, erro
|
|||||||
return numPods, missingTimestamp, nil
|
return numPods, missingTimestamp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isDynamicDiscoveryError returns true if the error is a group discovery error
|
||||||
|
// only for groups expected to be created/deleted dynamically during e2e tests
|
||||||
|
func isDynamicDiscoveryError(err error) bool {
|
||||||
|
if !discovery.IsGroupDiscoveryFailedError(err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
discoveryErr := err.(*discovery.ErrGroupDiscoveryFailed)
|
||||||
|
for gv := range discoveryErr.Groups {
|
||||||
|
switch gv.Group {
|
||||||
|
case "mygroup.example.com":
|
||||||
|
// custom_resource_definition
|
||||||
|
// garbage_collector
|
||||||
|
case "wardle.k8s.io":
|
||||||
|
// aggregator
|
||||||
|
default:
|
||||||
|
Logf("discovery error for unexpected group: %#v", gv)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// hasRemainingContent checks if there is remaining content in the namespace via API discovery
|
// hasRemainingContent checks if there is remaining content in the namespace via API discovery
|
||||||
func hasRemainingContent(c clientset.Interface, clientPool dynamic.ClientPool, namespace string) (bool, error) {
|
func hasRemainingContent(c clientset.Interface, clientPool dynamic.ClientPool, namespace string) (bool, error) {
|
||||||
// some tests generate their own framework.Client rather than the default
|
// some tests generate their own framework.Client rather than the default
|
||||||
@ -1142,11 +1164,11 @@ func hasRemainingContent(c clientset.Interface, clientPool dynamic.ClientPool, n
|
|||||||
|
|
||||||
// find out what content is supported on the server
|
// find out what content is supported on the server
|
||||||
resources, err := c.Discovery().ServerPreferredNamespacedResources()
|
resources, err := c.Discovery().ServerPreferredNamespacedResources()
|
||||||
if err != nil {
|
if err != nil && !isDynamicDiscoveryError(err) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
groupVersionResources, err := discovery.GroupVersionResources(resources)
|
groupVersionResources, err := discovery.GroupVersionResources(resources)
|
||||||
if err != nil {
|
if err != nil && !isDynamicDiscoveryError(err) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user