@@ -19,8 +19,10 @@ package step
1919import (
2020 "context"
2121 "fmt"
22+ "reflect"
2223 "strings"
2324
25+ "github.com/deckhouse/virtualization-controller/pkg/logger"
2426 corev1 "k8s.io/api/core/v1"
2527 storagev1 "k8s.io/api/storage/v1"
2628 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -66,13 +68,25 @@ func NewWaitForDVStep(
6668 }
6769}
6870
71+ func safenil (o client.Object ) string {
72+ if o == nil || reflect .ValueOf (o ).IsNil () {
73+ return "nil"
74+ }
75+
76+ return o .GetName ()
77+ }
78+
6979func (s WaitForDVStep ) Take (ctx context.Context , vd * v1alpha2.VirtualDisk ) (* reconcile.Result , error ) {
80+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep" , "datavolume" , safenil (s .dv ), "sc" , vd .Status .StorageClassName )
81+
7082 if s .dv == nil {
7183 vd .Status .Phase = v1alpha2 .DiskProvisioning
7284 s .cb .
7385 Status (metav1 .ConditionFalse ).
7486 Reason (vdcondition .Provisioning ).
7587 Message ("Waiting for the VirtualDisk importer to be created." )
88+
89+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep [importer to be created]" )
7690 return & reconcile.Result {}, nil
7791 }
7892
@@ -88,11 +102,13 @@ func (s WaitForDVStep) Take(ctx context.Context, vd *v1alpha2.VirtualDisk) (*rec
88102 return & reconcile.Result {}, nil
89103 }
90104 if set {
105+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep [consumer awaited]" )
91106 return & reconcile.Result {}, nil
92107 }
93108
94109 ok = s .checkRunningCondition (vd )
95110 if ! ok {
111+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep [checkRunningCondition]" )
96112 return & reconcile.Result {}, nil
97113 }
98114
@@ -106,9 +122,12 @@ func (s WaitForDVStep) Take(ctx context.Context, vd *v1alpha2.VirtualDisk) (*rec
106122
107123 set = s .setForProvisioning (vd )
108124 if set {
125+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep [provisioning to the pvc]" )
109126 return & reconcile.Result {}, nil
110127 }
111128
129+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep [ok]" )
130+
112131 return nil , nil
113132}
114133
@@ -126,6 +145,8 @@ func (s WaitForDVStep) setForProvisioning(vd *v1alpha2.VirtualDisk) (set bool) {
126145}
127146
128147func (s WaitForDVStep ) setForFirstConsumerIsAwaited (ctx context.Context , vd * v1alpha2.VirtualDisk ) (set bool , err error ) {
148+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep setForFirstConsumerIsAwaited 111" )
149+
129150 if vd .Status .StorageClassName == "" {
130151 return false , fmt .Errorf ("StorageClassName is empty, please report a bug" )
131152 }
@@ -138,6 +159,9 @@ func (s WaitForDVStep) setForFirstConsumerIsAwaited(ctx context.Context, vd *v1a
138159 isWFFC := sc != nil && sc .VolumeBindingMode != nil && * sc .VolumeBindingMode == storagev1 .VolumeBindingWaitForFirstConsumer
139160 dvRunningCond , _ := conditions .GetDataVolumeCondition (conditions .DVRunningConditionType , s .dv .Status .Conditions )
140161 dvRunningReasonEmptyOrPending := dvRunningCond .Reason == "" || dvRunningCond .Reason == conditions .DVRunningConditionPendingReason
162+
163+ logger .FromContext (ctx ).Info ("[GOGOGO] STEP WaitForDVStep setForFirstConsumerIsAwaited 222" , "isWFFC" , isWFFC , "dvPhase" , s .dv .Status .Phase , "dvRunningReasonEmptyOrPending" , dvRunningReasonEmptyOrPending )
164+
141165 if isWFFC && (s .dv .Status .Phase == cdiv1 .PendingPopulation || s .dv .Status .Phase == cdiv1 .WaitForFirstConsumer ) && dvRunningReasonEmptyOrPending {
142166 vd .Status .Phase = v1alpha2 .DiskWaitForFirstConsumer
143167 s .cb .
0 commit comments