Skip to content

Commit

Permalink
Fiixed: persistentvolumeclaims already exists #1130 (#1363)
Browse files Browse the repository at this point in the history
* Fixed: persistentvolumeclaims already exists  #1130
  • Loading branch information
sarabala1979 authored Jun 7, 2019
1 parent 6a042d1 commit bc81fe2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit bc81fe2

Please sign in to comment.