@@ -190,25 +190,6 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
190
190
return reconcile.Result {}, err
191
191
}
192
192
193
- // 2. Ensure there are no RestartAwaitingChanges.
194
- if len (vm .Status .RestartAwaitingChanges ) > 0 {
195
- vmSnapshot .Status .Phase = virtv2 .VirtualMachineSnapshotPhasePending
196
- msg := fmt .Sprintf (
197
- "Waiting for the restart and approval of changes to virtual machine %q before taking the snapshot." ,
198
- vm .Name ,
199
- )
200
- h .recorder .Event (
201
- vmSnapshot ,
202
- corev1 .EventTypeNormal ,
203
- virtv2 .ReasonVMSnapshottingPending ,
204
- msg ,
205
- )
206
- cb .
207
- Status (metav1 .ConditionFalse ).
208
- Reason (vmscondition .RestartAwaitingChanges ).Message (msg )
209
- return reconcile.Result {}, nil
210
- }
211
-
212
193
needToFreeze := h .needToFreeze (vm , vmSnapshot .Spec .RequiredConsistency )
213
194
214
195
isAwaitingConsistency := needToFreeze && ! h .snapshotter .CanFreeze (vm ) && vmSnapshot .Spec .RequiredConsistency
@@ -260,7 +241,7 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
260
241
261
242
var hasFrozen bool
262
243
263
- // 3 . Ensure the virtual machine is consistent for snapshotting.
244
+ // 2 . Ensure the virtual machine is consistent for snapshotting.
264
245
if needToFreeze {
265
246
hasFrozen , err = h .freezeVirtualMachine (ctx , vm , vmSnapshot )
266
247
if err != nil {
@@ -278,17 +259,17 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
278
259
return reconcile.Result {}, nil
279
260
}
280
261
281
- // 4 . Create secret.
262
+ // 3 . Create secret.
282
263
err = h .ensureSecret (ctx , vm , vmSnapshot )
283
264
if err != nil {
284
265
h .setPhaseConditionToFailed (cb , vmSnapshot , err )
285
266
return reconcile.Result {}, err
286
267
}
287
268
288
- // 5 . Fill status.VirtualDiskSnapshotNames.
269
+ // 4 . Fill status.VirtualDiskSnapshotNames.
289
270
h .fillStatusVirtualDiskSnapshotNames (vmSnapshot , vm )
290
271
291
- // 6 . Get or Create VirtualDiskSnapshots.
272
+ // 5 . Get or Create VirtualDiskSnapshots.
292
273
vdSnapshots , err := h .ensureVirtualDiskSnapshots (ctx , vmSnapshot )
293
274
switch {
294
275
case err == nil :
@@ -314,7 +295,7 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
314
295
return reconcile.Result {}, err
315
296
}
316
297
317
- // 7 . Wait for VirtualDiskSnapshots to be Ready.
298
+ // 6 . Wait for VirtualDiskSnapshots to be Ready.
318
299
readyCount := h .countReadyVirtualDiskSnapshots (vdSnapshots )
319
300
msg := fmt .Sprintf (
320
301
"Waiting for the virtual disk snapshots to be taken for " +
@@ -351,21 +332,21 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
351
332
vmSnapshot .Status .Consistent = nil
352
333
}
353
334
354
- // 8 . Unfreeze VirtualMachine if can.
335
+ // 7 . Unfreeze VirtualMachine if can.
355
336
unfrozen , err := h .unfreezeVirtualMachineIfCan (ctx , vmSnapshot , vm )
356
337
if err != nil {
357
338
h .setPhaseConditionToFailed (cb , vmSnapshot , err )
358
339
return reconcile.Result {}, err
359
340
}
360
341
361
- // 9 . Fill status resources.
342
+ // 8 . Fill status resources.
362
343
err = h .fillStatusResources (ctx , vmSnapshot , vm )
363
344
if err != nil {
364
345
h .setPhaseConditionToFailed (cb , vmSnapshot , err )
365
346
return reconcile.Result {}, err
366
347
}
367
348
368
- // 10 . Move to Ready phase.
349
+ // 9 . Move to Ready phase.
369
350
log .Debug ("The virtual disk snapshots are taken: the virtual machine snapshot is Ready now" , "unfrozen" , unfrozen )
370
351
371
352
vmSnapshot .Status .Phase = virtv2 .VirtualMachineSnapshotPhaseReady
0 commit comments