diff --git a/cmd/troubleshoot/cli/run_nocrd.go b/cmd/troubleshoot/cli/run_nocrd.go index f1980de07..c55f48fb5 100644 --- a/cmd/troubleshoot/cli/run_nocrd.go +++ b/cmd/troubleshoot/cli/run_nocrd.go @@ -210,7 +210,7 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector) (str collectorDirs = append(collectorDirs, collectorDir) if err := client.Delete(context.Background(), newPod); err != nil { - fmt.Println("delete pod") + fmt.Println("delete pod error", err) } podsDeleted = append(podsDeleted, newPod) }, @@ -225,7 +225,8 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector) (str fmt.Printf("creating collector\n") _, pod, err := collectrunner.CreateCollector(client, s, &owner, collector.Name, v.GetString("namespace"), serviceAccountName, "troubleshoot", collect, v.GetString("image"), v.GetString("pullpolicy")) if err != nil { - return "", err + fmt.Printf("A collector pod cannot be created: %v\n", err) + continue } podsCreated = append(podsCreated, pod) } diff --git a/pkg/collect/runner.go b/pkg/collect/runner.go index 04156e0d2..6c162ed00 100644 --- a/pkg/collect/runner.go +++ b/pkg/collect/runner.go @@ -89,7 +89,9 @@ func createCollectorPod(client client.Client, scheme *runtime.Scheme, ownerRef m found := &corev1.Pod{} err := client.Get(context.Background(), namespacedName, found) - if err == nil || !kuberneteserrors.IsNotFound(err) { + if err == nil { + return nil, fmt.Errorf("pod %q already exists", name) + } else if !kuberneteserrors.IsNotFound(err) { return nil, err }