@@ -90,6 +90,7 @@ type Controller struct {
9090 jobs batchcontroller.JobController
9191 jobCache batchcontroller.JobCache
9292 secretCache corecontroller.SecretCache
93+ namespaceCache corecontroller.NamespaceCache
9394 apply apply.Apply
9495 recorder record.EventRecorder
9596 apiServerPort string
@@ -114,7 +115,8 @@ func Register(
114115 sas corecontroller.ServiceAccountController ,
115116 cm corecontroller.ConfigMapController ,
116117 s corecontroller.SecretController ,
117- sCache corecontroller.SecretCache ) {
118+ sCache corecontroller.SecretCache ,
119+ nsCache corecontroller.NamespaceCache ) {
118120
119121 c := & Controller {
120122 systemNamespace : systemNamespace ,
@@ -127,6 +129,7 @@ func Register(
127129 jobs : jobs ,
128130 jobCache : jobCache ,
129131 secretCache : sCache ,
132+ namespaceCache : nsCache ,
130133 recorder : recorder ,
131134 apiServerPort : apiServerPort ,
132135 }
@@ -335,6 +338,14 @@ func (c *Controller) OnRemove(key string, chart *v1.HelmChart) (*v1.HelmChart, e
335338 return nil , nil
336339 }
337340
341+ // if the target namespace is terminating, we are not allowed to spawn jobs
342+ // skip to not block indefinitely. namespace deletion will remove the chart
343+ if ns , err := c .namespaceCache .Get (chart .Namespace ); err != nil {
344+ return nil , fmt .Errorf ("could not perform uninstall: namespace %s not found" , chart .Namespace )
345+ } else if ns .Status .Phase == corev1 .NamespaceTerminating {
346+ return nil , nil
347+ }
348+
338349 expectedJob , objs , err := c .getJobAndRelatedResources (chart )
339350 if err != nil {
340351 return nil , err
0 commit comments