Skip to content

Commit

Permalink
improve TimeoutSeconds, ds nil check and use PullIfNotPresent
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan committed Nov 6, 2024
1 parent 4bc655c commit 6ce12b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/supportbundle/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ func runRemoteHostCollectors(ctx context.Context, hostCollectors []*troubleshoot

klog.V(2).Infof("Created Remote Host Collector Daemonset %s", ds.Name)
pods, err := clientset.CoreV1().Pods(ds.Namespace).List(ctx, metav1.ListOptions{
LabelSelector: selectorLabelKey + "=" + ds.Name,
TimeoutSeconds: new(int64),
LabelSelector: selectorLabelKey + "=" + ds.Name,
// use the default logs collector timeout for now
TimeoutSeconds: ptr.To(int64(constants.DEFAULT_LOGS_COLLECTOR_TIMEOUT.Seconds())),
Limit: 0,
})
if err != nil {
Expand Down Expand Up @@ -436,6 +437,10 @@ func runRemoteHostCollectors(ctx context.Context, hostCollectors []*troubleshoot
// delete the config map
// delete the remote pods
// check if the daemonset still exists
if ds == nil || ds.Name == "" {
return
}

if err := clientset.AppsV1().DaemonSets(ds.Namespace).Delete(ctx, ds.Name, metav1.DeleteOptions{}); err != nil {
if kuberneteserrors.IsNotFound(err) {
klog.Errorf("Remote host collector daemonset %s not found", ds.Name)
Expand Down Expand Up @@ -492,7 +497,7 @@ func createHostCollectorDS(ctx context.Context, clientset kubernetes.Interface,
dsName := names.SimpleNameGenerator.GenerateName("remote-host-collector" + "-")
ns := "default"
imageName := "replicated/troubleshoot:latest"
imagePullPolicy := corev1.PullAlways
imagePullPolicy := corev1.PullIfNotPresent

labels[selectorLabelKey] = dsName

Expand Down

0 comments on commit 6ce12b5

Please sign in to comment.