File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,19 @@ func (o *MustGatherOptions) Run() error {
379379 go func (pod * corev1.Pod ) {
380380 defer wg .Done ()
381381
382+ if len (o .RunNamespace ) > 0 && ! o .Keep {
383+ defer func () {
384+ // must-gather runs in its own separate namespace as default , so after it is completed
385+ // it deletes this namespace and all the pods are removed by garbage collector.
386+ // However, if user specifies namespace via `run-namespace`, these pods need to
387+ // be deleted manually.
388+ err = o .Client .CoreV1 ().Pods (o .RunNamespace ).Delete (context .TODO (), pod .Name , metav1.DeleteOptions {})
389+ if err != nil {
390+ klog .V (4 ).Infof ("pod deletion error %v" , err )
391+ }
392+ }()
393+ }
394+
382395 log := newPodOutLogger (o .Out , pod .Name )
383396
384397 // wait for gather container to be running (gather is running)
You can’t perform that action at this time.
0 commit comments