-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cvi,vi): unlock pending vi/cvi from vd ref #416
base: main
Are you sure you want to change the base?
Conversation
images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref_vd.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/cvi/internal/datasource_ready.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/cvi/internal/source/errors.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/internal/attachee.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref_vd.go
Outdated
Show resolved
Hide resolved
45552d1
to
8e5b4f1
Compare
images/virtualization-artifact/pkg/controller/vd/internal/attachee.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/internal/attachee.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/internal/attachee.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/vd_reconciler.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref_vd.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vm/internal/block_device.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vm/internal/block_device.go
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/internal/inuse.go
Outdated
Show resolved
Hide resolved
523f4a4
to
f8134b5
Compare
70fd271
to
0f11fd4
Compare
images/virtualization-artifact/pkg/controller/vi/internal/source/errors.go
Outdated
Show resolved
Hide resolved
d37bad7
to
7b7bcd5
Compare
7b7bcd5
to
11bbb7f
Compare
f5f5d24
to
2c03739
Compare
images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref_vd.go
Outdated
Show resolved
Hide resolved
images/virtualization-artifact/pkg/controller/vd/internal/inuse.go
Outdated
Show resolved
Hide resolved
8d2b638
to
8b0c8b6
Compare
03a7ea4
to
a959b5b
Compare
Signed-off-by: dmitry.lopatin <[email protected]>
Signed-off-by: dmitry.lopatin <[email protected]>
Signed-off-by: dmitry.lopatin <[email protected]>
a959b5b
to
3132202
Compare
Signed-off-by: dmitry.lopatin <[email protected]>
3132202
to
c7c091c
Compare
@@ -34,6 +34,8 @@ const ( | |||
SnapshottingType Type = "Snapshotting" | |||
// StorageClassReadyType indicates whether the storage class is ready. | |||
StorageClassReadyType Type = "StorageClassReady" | |||
// InUseType indicates whether the VirtualDisk is attached to a running VirtualMachine or is being used in a process of a VirtualImage creation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of an image creation
allowedPhases := []virtv2.ImagePhase{virtv2.ImageProvisioning, virtv2.ImagePending} | ||
|
||
for _, vi := range vis.Items { | ||
if slices.Contains(allowedPhases, vi.Status.Phase) && vi.Spec.DataSource.Type == virtv2.DataSourceTypeObjectRef && vi.Spec.DataSource.ObjectRef != nil && vi.Spec.DataSource.ObjectRef.Kind == virtv2.VirtualDiskKind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vi.Spec.DataSource.ObjectRef.Name == vd.Name
allowedPhases := []virtv2.ImagePhase{virtv2.ImageProvisioning, virtv2.ImagePending} | ||
|
||
for _, vi := range vis.Items { | ||
if slices.Contains(allowedPhases, vi.Status.Phase) && vi.Spec.DataSource.Type == virtv2.DataSourceTypeObjectRef && vi.Spec.DataSource.ObjectRef != nil && vi.Spec.DataSource.ObjectRef.Kind == virtv2.VirtualDiskKind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too long line
cb := conditions.NewConditionBuilder(vdcondition.InUseType) | ||
|
||
switch { | ||
case allowUseForVM && inUseCondition.Status == metav1.ConditionUnknown: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a little optimization is possible here: you dont have to list vi and cvi if allowUseForVM is true
conditions.SetCondition(cb, &vd.Status.Conditions) | ||
} | ||
default: | ||
needChange := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mb rename to setUnkown := false ?
import ( | ||
"context" | ||
|
||
"github.com/onsi/ginkgo/v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why dont use dot import alias?
}) | ||
|
||
ginkgo.Context("when VirtualDisk is used by not ready VirtualMachine", func() { | ||
ginkgo.It("must set status True and reason AllowedForVirtualMachineUsage", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it sets Unknown
}) | ||
}) | ||
|
||
ginkgo.Context("when VirtualDisk is not in use after create image", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after image creation
}) | ||
}) | ||
|
||
ginkgo.Context("when VirtualDisk is not in use after running VM", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after VM deletion
Namespace: vm.GetNamespace(), | ||
LabelSelector: labels.SelectorFromSet(map[string]string{virtv1.VirtualMachineNameLabel: vm.GetName()}), | ||
}) | ||
if err != nil && !k8serrors.IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List cannot return not found error
Signed-off-by: dmitry.lopatin <[email protected]>
Description
Why do we need it, and what problem does it solve?
Fix problem with lock VirtualImage and ClusterVirtual image in phase 'Pending' after stopping or deleting VirtualMachine, when used needed VirtualDisk in them.
What is the expected result?
Checklist