Merge pull request #104799 from RyanAoh/cronjob_dev

fix the error when cleaning up finished jobs for cronjob
This commit is contained in:
Kubernetes Prow Robot
2021-12-17 13:23:53 -08:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import (
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
@@ -153,6 +154,14 @@ func TestCronJobLaunchesPodAndCleansUp(t *testing.T) {
ns := framework.CreateTestingNamespace(namespaceName, server, t)
defer framework.DeleteTestingNamespace(ns, server, t)
backupHandlers := runtime.ErrorHandlers
runtime.ErrorHandlers = append(runtime.ErrorHandlers, func(e error) {
t.Fatalf("Failed with error: %v", e)
})
defer func() {
runtime.ErrorHandlers = backupHandlers
}()
cjClient := clientSet.BatchV1().CronJobs(ns.Name)
stopCh := make(chan struct{})