diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 010feb6d19f0..3617d5d51edb 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -2,7 +2,7 @@ "swagger": "2.0", "info": { "title": "Argo", - "version": "v2.3.0-rc3" + "version": "v2.4.0" }, "paths": {}, "definitions": { diff --git a/workflow/controller/operator.go b/workflow/controller/operator.go index 9a2cd8ab1fc1..9fff7b59ee55 100644 --- a/workflow/controller/operator.go +++ b/workflow/controller/operator.go @@ -897,9 +897,30 @@ func (woc *wfOperationCtx) createPVCs() error { *metav1.NewControllerRef(woc.wf, wfv1.SchemaGroupVersionKind), } pvc, err := pvcClient.Create(&pvcTmpl) + if err != nil && apierr.IsAlreadyExists(err) { + woc.log.Infof("%s pvc has already exists. Workflow is re-using it", pvcTmpl.Name) + pvc, err = pvcClient.Get(pvcTmpl.Name, metav1.GetOptions{}) + if err != nil { + return err + } + hasOwnerReference := false + for i := range pvc.OwnerReferences { + ownerRef := pvc.OwnerReferences[i] + if ownerRef.UID == woc.wf.UID { + hasOwnerReference = true + break + } + } + if !hasOwnerReference { + return errors.New(errors.CodeForbidden, "%s pvc has already exists with different ownerreference") + } + } + + //continue if err != nil { return err } + vol := apiv1.Volume{ Name: refName, VolumeSource: apiv1.VolumeSource{