mirror of https://github.com/k3s-io/k3s
Merge pull request #51915 from liggitt/e2e-ns-cleanup
Automatic merge from submit-queue Tolerate group discovery errors in e2e ns cleanup Fixes #51910 Fixes #51424pull/6/head
commit
74608e7899
|
@ -70,6 +70,10 @@ var _ = SIGDescribe("Aggregator", func() {
|
|||
})
|
||||
|
||||
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"
|
||||
client := f.ClientSet
|
||||
_ = 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.RbacV1beta1().ClusterRoles().Delete("wardler", nil)
|
||||
_ = client.RbacV1beta1().ClusterRoleBindings().Delete("wardler:sample-system:anonymous", nil)
|
||||
aggrclient := f.AggregatorClient
|
||||
_ = aggrclient.ApiregistrationV1beta1().APIServices().Delete("v1alpha1.wardle.k8s.io", nil)
|
||||
if block {
|
||||
_ = wait.Poll(100*time.Millisecond, 5*time.Second, func() (bool, error) {
|
||||
_, 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
|
||||
}
|
||||
|
||||
// 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
|
||||
func hasRemainingContent(c clientset.Interface, clientPool dynamic.ClientPool, namespace string) (bool, error) {
|
||||
// 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
|
||||
resources, err := c.Discovery().ServerPreferredNamespacedResources()
|
||||
if err != nil {
|
||||
if err != nil && !isDynamicDiscoveryError(err) {
|
||||
return false, err
|
||||
}
|
||||
groupVersionResources, err := discovery.GroupVersionResources(resources)
|
||||
if err != nil {
|
||||
if err != nil && !isDynamicDiscoveryError(err) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue