Skip to content

Commit 412e37a

Browse files
committed
feat(vd): resize-condition-to-resizing
Signed-off-by: Daniil Antoshin <[email protected]> fix: tests Signed-off-by: Daniil Antoshin <[email protected]> fix Signed-off-by: Daniil Antoshin <[email protected]>
1 parent afe682a commit 412e37a

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

api/core/v1alpha2/vdcondition/condition.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const (
2828
DatasourceReadyType Type = "DatasourceReady"
2929
// ReadyType indicates whether the import process succeeded and the `VirtualDisk` is ready for use.
3030
ReadyType Type = "Ready"
31-
// ResizedType indicates whether the disk resizing operation is completed.
32-
ResizedType Type = "Resized"
31+
// ResizingType indicates whether the disk resizing operation is completed.
32+
ResizingType Type = "Resizing"
3333
// SnapshottingType indicates whether the disk snapshotting operation is in progress.
3434
SnapshottingType Type = "Snapshotting"
3535
// StorageClassReadyType indicates whether the storage class is ready.

images/virtualization-artifact/pkg/controller/vd/internal/resizing.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func NewResizingHandler(diskService DiskService) *ResizingHandler {
4848
func (h ResizingHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (reconcile.Result, error) {
4949
log := logger.FromContext(ctx).With(logger.SlogHandler("resizing"))
5050

51-
condition, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
52-
cb := conditions.NewConditionBuilder(vdcondition.ResizedType).Generation(vd.Generation)
51+
condition, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
52+
cb := conditions.NewConditionBuilder(vdcondition.ResizingType).Generation(vd.Generation)
5353

5454
defer func() { conditions.SetCondition(cb, &vd.Status.Conditions) }()
5555

@@ -107,7 +107,7 @@ func (h ResizingHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (re
107107

108108
vd.Status.Phase = virtv2.DiskResizing
109109
cb.
110-
Status(metav1.ConditionFalse).
110+
Status(metav1.ConditionTrue).
111111
Reason(vdcondition.InProgress).
112112
Message(pvcResizing.Message)
113113
return reconcile.Result{}, nil
@@ -155,7 +155,7 @@ func (h ResizingHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (re
155155

156156
vd.Status.Phase = virtv2.DiskResizing
157157
cb.
158-
Status(metav1.ConditionFalse).
158+
Status(metav1.ConditionTrue).
159159
Reason(vdcondition.InProgress).
160160
Message("The virtual disk resizing has started.")
161161
return reconcile.Result{}, nil
@@ -165,7 +165,7 @@ func (h ResizingHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (re
165165
switch condition.Reason {
166166
case vdcondition.InProgress.String(), vdcondition.Resized.String():
167167
cb.
168-
Status(metav1.ConditionTrue).
168+
Status(metav1.ConditionFalse).
169169
Reason(vdcondition.Resized).
170170
Message("")
171171
default:

images/virtualization-artifact/pkg/controller/vd/internal/resizing_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ var _ = Describe("Resizing handler Run", func() {
104104

105105
_, err := h.Handle(testContext(), vd)
106106
Expect(err).To(BeNil())
107-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
108-
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
107+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
108+
Expect(resized.Status).To(Equal(metav1.ConditionTrue))
109109
Expect(resized.Reason).To(Equal(vdcondition.InProgress.String()))
110110
})
111111

@@ -116,7 +116,7 @@ var _ = Describe("Resizing handler Run", func() {
116116

117117
_, err := h.Handle(testContext(), vd)
118118
Expect(err).To(BeNil())
119-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
119+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
120120
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
121121
Expect(resized.Reason).To(Equal(vdcondition.ResizingNotRequested.String()))
122122
})
@@ -128,7 +128,7 @@ var _ = Describe("Resizing handler Run", func() {
128128

129129
_, err := h.Handle(testContext(), vd)
130130
Expect(err).To(BeNil())
131-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
131+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
132132
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
133133
Expect(resized.Reason).To(Equal(vdcondition.ResizingNotRequested.String()))
134134
})
@@ -138,7 +138,7 @@ var _ = Describe("Resizing handler Run", func() {
138138

139139
_, err := h.Handle(testContext(), vd)
140140
Expect(err).To(BeNil())
141-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
141+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
142142
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
143143
Expect(resized.Reason).To(Equal(vdcondition.ResizingNotRequested.String()))
144144
})
@@ -150,14 +150,14 @@ var _ = Describe("Resizing handler Run", func() {
150150

151151
_, err := h.Handle(testContext(), vd)
152152
Expect(err).To(BeNil())
153-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
154-
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
153+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
154+
Expect(resized.Status).To(Equal(metav1.ConditionTrue))
155155
Expect(resized.Reason).To(Equal(vdcondition.InProgress.String()))
156156
})
157157

158158
It("Resize has completed", func() {
159159
vd.Status.Conditions = append(vd.Status.Conditions, metav1.Condition{
160-
Type: vdcondition.ResizedType.String(),
160+
Type: vdcondition.ResizingType.String(),
161161
Status: metav1.ConditionFalse,
162162
Reason: vdcondition.InProgress.String(),
163163
})
@@ -166,8 +166,8 @@ var _ = Describe("Resizing handler Run", func() {
166166

167167
_, err := h.Handle(testContext(), vd)
168168
Expect(err).To(BeNil())
169-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
170-
Expect(resized.Status).To(Equal(metav1.ConditionTrue))
169+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
170+
Expect(resized.Status).To(Equal(metav1.ConditionFalse))
171171
Expect(resized.Reason).To(Equal(vdcondition.Resized.String()))
172172
})
173173
})

images/virtualization-artifact/pkg/controller/vd/internal/snapshotting.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (h SnapshottingHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk)
7474
continue
7575
}
7676

77-
resized, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
77+
resized, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
7878
if resized.Reason == vdcondition.InProgress.String() {
7979
cb.
8080
Status(metav1.ConditionFalse).

images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func (h LifeCycleHandler) ensureBlockDeviceConsistency(ctx context.Context, vm *
462462
return fmt.Errorf("%w: waiting for the Ready condition of the virtual disk %q to be True", ErrVirtualDiskResizing, vd.Name)
463463
}
464464

465-
resizingReady, _ := conditions.GetCondition(vdcondition.ResizedType, vd.Status.Conditions)
465+
resizingReady, _ := conditions.GetCondition(vdcondition.ResizingType, vd.Status.Conditions)
466466
if resizingReady.Reason == vdcondition.InProgress.String() {
467467
return fmt.Errorf("%w: waiting for the virtual disk %q to be resized", ErrVirtualDiskResizing, vd.Name)
468468
}

images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var _ = Describe("LifeCycle handler", func() {
5353
Status: metav1.ConditionTrue,
5454
},
5555
{
56-
Type: vdcondition.Resized.String(),
56+
Type: vdcondition.ResizingType.String(),
5757
Status: metav1.ConditionTrue,
5858
Reason: vdcondition.Resized.String(),
5959
},
@@ -198,7 +198,7 @@ var _ = Describe("LifeCycle handler", func() {
198198

199199
It("The virtual disk is the process of Resizing", func() {
200200
snapshotter.GetVirtualDiskFunc = func(_ context.Context, _, _ string) (*virtv2.VirtualDisk, error) {
201-
cb := conditions.NewConditionBuilder(vdcondition.Resized).
201+
cb := conditions.NewConditionBuilder(vdcondition.ResizingType).
202202
Generation(vd.Generation).
203203
Status(metav1.ConditionFalse).
204204
Reason(vdcondition.InProgress)

images/virtualization-artifact/pkg/controller/vmsnapshot/internal/watcher/vd_watcher.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func (w VirtualDiskWatcher) filterUpdateEvents(e event.UpdateEvent) bool {
105105
return false
106106
}
107107

108-
oldResized, _ := conditions.GetCondition(vdcondition.ResizedType, oldVD.Status.Conditions)
109-
newResized, _ := conditions.GetCondition(vdcondition.ResizedType, newVD.Status.Conditions)
108+
oldResized, _ := conditions.GetCondition(vdcondition.ResizingType, oldVD.Status.Conditions)
109+
newResized, _ := conditions.GetCondition(vdcondition.ResizingType, newVD.Status.Conditions)
110110

111111
return oldResized.Status != newResized.Status || oldResized.Reason != newResized.Reason
112112
}

0 commit comments

Comments
 (0)