@@ -60,13 +60,13 @@ func NewAddOriginalMetadataStep(
6060func (s AddOriginalMetadataStep ) Take (ctx context.Context , vd * v1alpha2.VirtualDisk ) (* reconcile.Result , error ) {
6161 vdSnapshot , err := object .FetchObject (ctx , types.NamespacedName {Name : vd .Spec .DataSource .ObjectRef .Name , Namespace : vd .Namespace }, s .client , & v1alpha2.VirtualDiskSnapshot {})
6262 if err != nil {
63- wrappedErr : = fmt .Errorf ("failed to fetch the virtual disk snapshot: %w" , err )
63+ err = fmt .Errorf ("failed to fetch the virtual disk snapshot: %w" , err )
6464 vd .Status .Phase = v1alpha2 .DiskFailed
6565 s .cb .
6666 Status (metav1 .ConditionFalse ).
6767 Reason (vdcondition .ProvisioningFailed ).
68- Message (service .CapitalizeFirstLetter (wrappedErr .Error () + "." ))
69- return nil , wrappedErr
68+ Message (service .CapitalizeFirstLetter (err .Error () + "." ))
69+ return nil , err
7070 }
7171
7272 if vdSnapshot == nil {
@@ -80,13 +80,13 @@ func (s AddOriginalMetadataStep) Take(ctx context.Context, vd *v1alpha2.VirtualD
8080
8181 vs , err := object .FetchObject (ctx , types.NamespacedName {Name : vdSnapshot .Status .VolumeSnapshotName , Namespace : vdSnapshot .Namespace }, s .client , & vsv1.VolumeSnapshot {})
8282 if err != nil {
83- wrappedErr : = fmt .Errorf ("failed to fetch the volume snapshot: %w" , err )
83+ err = fmt .Errorf ("failed to fetch the volume snapshot: %w" , err )
8484 vd .Status .Phase = v1alpha2 .DiskFailed
8585 s .cb .
8686 Status (metav1 .ConditionFalse ).
8787 Reason (vdcondition .ProvisioningFailed ).
88- Message (service .CapitalizeFirstLetter (wrappedErr .Error () + "." ))
89- return nil , wrappedErr
88+ Message (service .CapitalizeFirstLetter (err .Error () + "." ))
89+ return nil , err
9090 }
9191
9292 if vdSnapshot .Status .Phase != v1alpha2 .VirtualDiskSnapshotPhaseReady || vs == nil || vs .Status == nil || vs .Status .ReadyToUse == nil || ! * vs .Status .ReadyToUse {
@@ -124,12 +124,17 @@ func (s AddOriginalMetadataStep) Take(ctx context.Context, vd *v1alpha2.VirtualD
124124 // when updating the virtual disk resource. Therefore, this step should finish
125125 // with reconciliation if the metadata has changed.
126126 if areAnnotationsAdded || areLabelsAdded {
127+ msg := "The original metadata sync has started"
127128 s .recorder .Event (
128129 vd ,
129130 corev1 .EventTypeNormal ,
130131 v1alpha2 .ReasonMetadataSyncStarted ,
131- "The original metadata sync has started" ,
132+ msg ,
132133 )
134+ s .cb .
135+ Status (metav1 .ConditionFalse ).
136+ Reason (vdcondition .Provisioning ).
137+ Message (msg )
133138 return & reconcile.Result {}, nil
134139 }
135140
@@ -151,7 +156,10 @@ func setOriginalAnnotations(vd *v1alpha2.VirtualDisk, vs *vsv1.VolumeSnapshot) (
151156
152157 var areAnnotationsAdded bool
153158 for key , originalvalue := range originalAnnotationsMap {
154- if currentValue , exists := vd .Annotations [key ]; ! exists || (key != lastAppliedConfigAnnotation && currentValue != originalvalue ) {
159+ if key == lastAppliedConfigAnnotation {
160+ continue
161+ }
162+ if currentValue , exists := vd .Annotations [key ]; ! exists || currentValue != originalvalue {
155163 vd .Annotations [key ] = originalvalue
156164 areAnnotationsAdded = true
157165 }
0 commit comments