Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,11 @@ func (ds HTTPDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk) (re

envSettings := ds.getEnvSettings(vd, supgen)

var nodePlacement *provisioner.NodePlacement
nodePlacement, err = getNodePlacement(ctx, ds.client, vd)
if err != nil {
setPhaseConditionToFailed(cb, &vd.Status.Phase, fmt.Errorf("unexpected error: %w", err))
return reconcile.Result{}, fmt.Errorf("failed to get importer tolerations: %w", err)
}

err = ds.importerService.Start(ctx, envSettings, vd, supgen, datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource), service.WithNodePlacement(nodePlacement))
err = ds.importerService.Start(
ctx, envSettings, vd, supgen,
datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource),
service.WithSystemNodeToleration(),
)
switch {
case err == nil:
// OK.
Expand Down Expand Up @@ -199,6 +196,12 @@ func (ds HTTPDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk) (re
vd.Status.Progress = ds.statService.GetProgress(vd.GetUID(), pod, vd.Status.Progress, service.NewScaleOption(0, 50))
vd.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(vd.GetUID(), pod)
case dv == nil:
if isStorageClassWFFC(sc) && len(vd.Status.AttachedToVirtualMachines) != 1 {
vd.Status.Progress = "50%"
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
return reconcile.Result{}, nil
}

ds.recorder.Event(
vd,
corev1.EventTypeNormal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,11 @@ func (ds RegistryDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk)

envSettings := ds.getEnvSettings(vd, supgen)

var nodePlacement *provisioner.NodePlacement
nodePlacement, err = getNodePlacement(ctx, ds.client, vd)
if err != nil {
setPhaseConditionToFailed(cb, &vd.Status.Phase, fmt.Errorf("unexpected error: %w", err))
return reconcile.Result{}, fmt.Errorf("failed to get importer tolerations: %w", err)
}

err = ds.importerService.Start(ctx, envSettings, vd, supgen, datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource), service.WithNodePlacement(nodePlacement))
err = ds.importerService.Start(
ctx, envSettings, vd, supgen,
datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource),
service.WithSystemNodeToleration(),
)
switch {
case err == nil:
// OK.
Expand Down Expand Up @@ -200,6 +197,12 @@ func (ds RegistryDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk)
return reconcile.Result{}, err
}
case dv == nil:
if isStorageClassWFFC(sc) && len(vd.Status.AttachedToVirtualMachines) != 1 {
vd.Status.Progress = "50%"
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
return reconcile.Result{}, nil
}

ds.recorder.Event(
vd,
corev1.EventTypeNormal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func (s CreateDataVolumeStep) Take(ctx context.Context, vd *v1alpha2.VirtualDisk
return nil, fmt.Errorf("get sc: %w", err)
}

isWFFC := sc != nil && sc.VolumeBindingMode != nil && *sc.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer
if isWFFC && len(vd.Status.AttachedToVirtualMachines) != 1 {
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
return &reconcile.Result{}, nil
}

var nodePlacement *provisioner.NodePlacement
nodePlacement, err = GetNodePlacement(ctx, s.client, vd)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,11 @@ func (ds UploadDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk) (

envSettings := ds.getEnvSettings(vd, supgen.Generator)

var nodePlacement *provisioner.NodePlacement
nodePlacement, err = getNodePlacement(ctx, ds.client, vd)
if err != nil {
setPhaseConditionToFailed(cb, &vd.Status.Phase, fmt.Errorf("unexpected error: %w", err))
return reconcile.Result{}, fmt.Errorf("failed to get importer tolerations: %w", err)
}

err = ds.uploaderService.Start(ctx, envSettings, vd, supgen, datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource), service.WithNodePlacement(nodePlacement))
err = ds.uploaderService.Start(
ctx, envSettings, vd, supgen,
datasource.NewCABundleForVMD(vd.GetNamespace(), vd.Spec.DataSource),
service.WithSystemNodeToleration(),
)
switch {
case err == nil:
// OK.
Expand Down Expand Up @@ -234,6 +231,12 @@ func (ds UploadDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk) (
return reconcile.Result{}, err
}
case dv == nil:
if isStorageClassWFFC(sc) && len(vd.Status.AttachedToVirtualMachines) != 1 {
vd.Status.Progress = "50%"
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
return reconcile.Result{}, nil
}

ds.recorder.Event(
vd,
corev1.EventTypeNormal,
Expand Down Expand Up @@ -285,7 +288,15 @@ func (ds UploadDataSource) Sync(ctx context.Context, vd *v1alpha2.VirtualDisk) (
if err != nil {
return reconcile.Result{}, err
}
err = ds.diskService.Start(ctx, diskSize, sc, source, vd, supgen)

var nodePlacement *provisioner.NodePlacement
nodePlacement, err = getNodePlacement(ctx, ds.client, vd)
if err != nil {
setPhaseConditionToFailed(cb, &vd.Status.Phase, fmt.Errorf("unexpected error: %w", err))
return reconcile.Result{}, fmt.Errorf("failed to get importer tolerations: %w", err)
}

err = ds.diskService.Start(ctx, diskSize, sc, source, vd, supgen, service.WithNodePlacement(nodePlacement))
if updated, err := setPhaseConditionFromStorageError(err, vd, cb); err != nil || updated {
return reconcile.Result{}, err
}
Expand Down
Loading