From 55b6582aa1457b12754bf4fdbb9027a0c5cb397e Mon Sep 17 00:00:00 2001 From: yaroslavborbat Date: Sun, 19 Jan 2025 01:32:09 +0300 Subject: [PATCH] fix Signed-off-by: yaroslavborbat --- api/client/kubeclient/vm.go | 8 ++++++++ api/subresources/v1alpha2/types.go | 5 +++++ .../pkg/controller/vmbda/internal/watcher/vi_watcher.go | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/api/client/kubeclient/vm.go b/api/client/kubeclient/vm.go index b1b81eda92..346d176785 100644 --- a/api/client/kubeclient/vm.go +++ b/api/client/kubeclient/vm.go @@ -153,11 +153,19 @@ func (v vm) Migrate(ctx context.Context, name string, opts v1alpha2.VirtualMachi func (v vm) AddVolume(ctx context.Context, name string, opts v1alpha2.VirtualMachineAddVolume) error { path := fmt.Sprintf(subresourceURLTpl, v.namespace, v.resource, name, "addvolume") + opts.TypeMeta = metav1.TypeMeta{ + Kind: v1alpha2.VirtualMachineAddVolumeKind, + APIVersion: v1alpha2.SchemeGroupVersion.String(), + } return v.doRequest(ctx, path, &opts) } func (v vm) RemoveVolume(ctx context.Context, name string, opts v1alpha2.VirtualMachineRemoveVolume) error { path := fmt.Sprintf(subresourceURLTpl, v.namespace, v.resource, name, "removevolume") + opts.TypeMeta = metav1.TypeMeta{ + Kind: v1alpha2.VirtualMachineRemoveVolumeKind, + APIVersion: v1alpha2.SchemeGroupVersion.String(), + } return v.doRequest(ctx, path, &opts) } diff --git a/api/subresources/v1alpha2/types.go b/api/subresources/v1alpha2/types.go index a4c1a054cb..b414d3d518 100644 --- a/api/subresources/v1alpha2/types.go +++ b/api/subresources/v1alpha2/types.go @@ -18,6 +18,11 @@ package v1alpha2 import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +const ( + VirtualMachineAddVolumeKind = "VirtualMachineAddVolume" + VirtualMachineRemoveVolumeKind = "VirtualMachineRemoveVolume" +) + // +genclient // +genclient:readonly // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/images/virtualization-artifact/pkg/controller/vmbda/internal/watcher/vi_watcher.go b/images/virtualization-artifact/pkg/controller/vmbda/internal/watcher/vi_watcher.go index 1e7e83054b..4bb3c8b693 100644 --- a/images/virtualization-artifact/pkg/controller/vmbda/internal/watcher/vi_watcher.go +++ b/images/virtualization-artifact/pkg/controller/vmbda/internal/watcher/vi_watcher.go @@ -48,7 +48,7 @@ func NewVirtualImageWatcherr(client client.Client) *VirtualImageWatcher { func (w VirtualImageWatcher) Watch(mgr manager.Manager, ctr controller.Controller) error { return ctr.Watch( - source.Kind(mgr.GetCache(), &virtv2.VirtualDisk{}), + source.Kind(mgr.GetCache(), &virtv2.VirtualImage{}), handler.EnqueueRequestsFromMapFunc(w.enqueueRequests), predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { return false }, @@ -85,13 +85,13 @@ func (w VirtualImageWatcher) enqueueRequests(ctx context.Context, obj client.Obj } func (w VirtualImageWatcher) filterUpdateEvents(e event.UpdateEvent) bool { - oldVI, ok := e.ObjectOld.(*virtv2.VirtualDisk) + oldVI, ok := e.ObjectOld.(*virtv2.VirtualImage) if !ok { slog.Default().Error(fmt.Sprintf("expected an old VirtualImage but got a %T", e.ObjectOld)) return false } - newVI, ok := e.ObjectNew.(*virtv2.VirtualDisk) + newVI, ok := e.ObjectNew.(*virtv2.VirtualImage) if !ok { slog.Default().Error(fmt.Sprintf("expected a new VirtualImage but got a %T", e.ObjectNew)) return false