File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -579,6 +579,28 @@ def preparePipelinesNamespace(
579579
580580 # Create config PVC if requested
581581 if createConfigPVC :
582+ # If config-pvc already exists with a different storageClass, delete it first.
583+ # Kubernetes does not allow changing storageClassName on an existing PVC (immutable
584+ # field), so patching would fail with a conflict error. Deleting and recreating
585+ # is safe here because config-pvc only holds transient pipeline workspace data —
586+ # it is not a source of truth for any persistent application state.
587+ try :
588+ existingConfigPVC = pvcAPI .get (name = "config-pvc" , namespace = namespace )
589+ existingStorageClass = existingConfigPVC .spec .storageClassName
590+ if existingStorageClass != storageClass :
591+ logger .info (
592+ f"config-pvc already exists with storageClassName='{ existingStorageClass } ' "
593+ f"which differs from requested storageClassName='{ storageClass } '. "
594+ f"Deleting existing config-pvc so it can be recreated with the correct storageClass."
595+ )
596+ pvcAPI .delete (name = "config-pvc" , namespace = namespace )
597+ else :
598+ logger .info (
599+ f"config-pvc already exists with matching storageClassName='{ existingStorageClass } ', skipping delete."
600+ )
601+ except NotFoundError :
602+ pass # PVC does not exist yet — will be created below
603+
582604 logger .info ("Creating config PVC" )
583605 template = env .get_template ("pipelines-pvc.yml.j2" )
584606 renderedTemplate = template .render (
You can’t perform that action at this time.
0 commit comments