Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 @@ -184,6 +184,13 @@ var _ = Describe("ObjectRef ClusterVirtualImage", func() {

It("waits for the first consumer", func() {
dv.Status.Phase = cdiv1.PendingPopulation
dv.Status.Conditions = []cdiv1.DataVolumeCondition{
{
Type: cdiv1.DataVolumeRunning,
Status: corev1.ConditionFalse,
Reason: "",
},
}
sc.VolumeBindingMode = ptr.To(storagev1.VolumeBindingWaitForFirstConsumer)
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(pvc, dv, sc).Build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ var _ = Describe("ObjectRef VirtualImage", func() {

It("waits for the first consumer", func() {
dv.Status.Phase = cdiv1.PendingPopulation
dv.Status.Conditions = []cdiv1.DataVolumeCondition{
{
Type: cdiv1.DataVolumeRunning,
Status: corev1.ConditionFalse,
Reason: "",
},
}
sc.VolumeBindingMode = ptr.To(storagev1.VolumeBindingWaitForFirstConsumer)
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(pvc, dv, sc).Build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ func setPhaseConditionForPVCProvisioningDisk(
Message("Waiting for the pvc importer to be created")
return nil
}
if isStorageClassWFFC(sc) && (dv.Status.Phase == cdiv1.PendingPopulation || dv.Status.Phase == cdiv1.WaitForFirstConsumer) {

dvRunningCond, _ := conditions.GetDataVolumeCondition(conditions.DVRunningConditionType, dv.Status.Conditions)
if isStorageClassWFFC(sc) && (dv.Status.Phase == cdiv1.PendingPopulation || dv.Status.Phase == cdiv1.WaitForFirstConsumer) && dvRunningCond.Reason == "" {
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
cb.
Status(metav1.ConditionFalse).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/deckhouse/virtualization-controller/pkg/controller/conditions"
"github.com/deckhouse/virtualization-controller/pkg/controller/service"
vdsupplements "github.com/deckhouse/virtualization-controller/pkg/controller/vd/internal/supplements"
"github.com/deckhouse/virtualization-controller/pkg/logger"
"github.com/deckhouse/virtualization/api/core/v1alpha2"
"github.com/deckhouse/virtualization/api/core/v1alpha2/vdcondition"
)
Expand Down Expand Up @@ -126,13 +127,19 @@ func (s WaitForDVStep) setForProvisioning(vd *v1alpha2.VirtualDisk) (set bool) {
}

func (s WaitForDVStep) setForFirstConsumerIsAwaited(ctx context.Context, vd *v1alpha2.VirtualDisk) (set bool, err error) {
if vd.Status.StorageClassName == "" {
logger.FromContext(ctx).Info("StorageClassName is empty, skipping WFFC check")
return false, nil
}

sc, err := object.FetchObject(ctx, types.NamespacedName{Name: vd.Status.StorageClassName}, s.client, &storagev1.StorageClass{})
if err != nil {
return false, fmt.Errorf("get sc: %w", err)
}

dvRunningCond, _ := conditions.GetDataVolumeCondition(conditions.DVRunningConditionType, s.dv.Status.Conditions)
isWFFC := sc != nil && sc.VolumeBindingMode != nil && *sc.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer
if isWFFC && (s.dv.Status.Phase == cdiv1.PendingPopulation || s.dv.Status.Phase == cdiv1.WaitForFirstConsumer) {
if isWFFC && (s.dv.Status.Phase == cdiv1.PendingPopulation || s.dv.Status.Phase == cdiv1.WaitForFirstConsumer) && dvRunningCond.Reason == "" {
vd.Status.Phase = v1alpha2.DiskWaitForFirstConsumer
s.cb.
Status(metav1.ConditionFalse).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/deckhouse/virtualization-controller/pkg/controller/conditions"
"github.com/deckhouse/virtualization-controller/pkg/controller/service"
"github.com/deckhouse/virtualization/api/core/v1alpha2"
)

Expand Down Expand Up @@ -73,8 +72,14 @@ func (w *DataVolumeWatcher) Watch(mgr manager.Manager, ctr controller.Controller
return true
}

dvRunning := service.GetDataVolumeCondition(cdiv1.DataVolumeRunning, e.ObjectNew.Status.Conditions)
return dvRunning != nil && (dvRunning.Reason == "Error" || dvRunning.Reason == "ImagePullFailed")
oldDVRunning, _ := conditions.GetDataVolumeCondition(conditions.DVRunningConditionType, e.ObjectOld.Status.Conditions)
newDVRunning, _ := conditions.GetDataVolumeCondition(conditions.DVRunningConditionType, e.ObjectNew.Status.Conditions)

if oldDVRunning.Reason != newDVRunning.Reason {
return true
}

return newDVRunning.Reason == "Error" || newDVRunning.Reason == "ImagePullFailed"
},
},
),
Expand Down
Loading