@@ -458,7 +458,7 @@ func replace(ctx context.Context, client kubectl.Client, pod *selector.SelectedP
458458
459459 // create a pvc if needed
460460 if len (replacePod .PersistPaths ) > 0 {
461- err = createPVC (ctx , client , copiedPod , replicaSet , replacePod )
461+ err = createPVC (ctx , client , copiedPod , replicaSet , replacePod , log )
462462 if err != nil {
463463 if kerrors .IsAlreadyExists (err ) {
464464 // delete the old one and wait
@@ -473,7 +473,7 @@ func replace(ctx context.Context, client kubectl.Client, pod *selector.SelectedP
473473 }
474474
475475 // create the new one
476- err = createPVC (ctx , client , copiedPod , replicaSet , replacePod )
476+ err = createPVC (ctx , client , copiedPod , replicaSet , replacePod , log )
477477 if err != nil {
478478 return errors .Wrap (err , "create persistent volume claim" )
479479 }
@@ -486,7 +486,7 @@ func replace(ctx context.Context, client kubectl.Client, pod *selector.SelectedP
486486 return nil
487487}
488488
489- func createPVC (ctx context.Context , client kubectl.Client , copiedPod * corev1.Pod , replicaSet * appsv1.ReplicaSet , replacePod * latest.ReplacePod ) error {
489+ func createPVC (ctx context.Context , client kubectl.Client , copiedPod * corev1.Pod , replicaSet * appsv1.ReplicaSet , replacePod * latest.ReplacePod , log log. Logger ) error {
490490 var err error
491491 size := resource .MustParse ("10Gi" )
492492 if replacePod .PersistenceOptions != nil && replacePod .PersistenceOptions .Size != "" {
@@ -540,12 +540,14 @@ func createPVC(ctx context.Context, client kubectl.Client, copiedPod *corev1.Pod
540540 }, metav1.CreateOptions {})
541541 if err != nil {
542542 if kerrors .IsAlreadyExists (err ) && replacePod .PersistenceOptions != nil && replacePod .PersistenceOptions .Name != "" {
543+ log .Infof ("PVC %s already exists for replaced pod %s" , name , copiedPod .Name )
543544 return nil
544545 }
545546
546547 return err
547548 }
548549
550+ log .Donef ("Created PVC %s for replaced pod %s" , name , copiedPod .Name )
549551 return nil
550552}
551553
0 commit comments