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
@@ -0,0 +1,33 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package internal

import (
"context"

virtv1 "kubevirt.io/api/core/v1"

"github.com/deckhouse/virtualization/api/core/v1alpha2"
)

//go:generate go tool moq -rm -out mock.go . AttachmentService

type AttachmentService interface {
GetVirtualMachine(ctx context.Context, name, namespace string) (*v1alpha2.VirtualMachine, error)
GetKVVMI(ctx context.Context, vm *v1alpha2.VirtualMachine) (*virtv1.VirtualMachineInstance, error)
GetKVVM(ctx context.Context, vm *v1alpha2.VirtualMachine) (*virtv1.VirtualMachine, error)
}
189 changes: 189 additions & 0 deletions images/virtualization-artifact/pkg/controller/vmbda/internal/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2026 Flant JSC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package internal

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestVirtualMachineBlockDeviceAttachment(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "VirtualMachineBlockDeviceAttachment Handlers Suite")
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

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

type VirtualMachineReadyHandler struct {
attachment *service.AttachmentService
attachment AttachmentService
}

func NewVirtualMachineReadyHandler(attachment *service.AttachmentService) *VirtualMachineReadyHandler {
func NewVirtualMachineReadyHandler(attachment AttachmentService) *VirtualMachineReadyHandler {
return &VirtualMachineReadyHandler{
attachment: attachment,
}
Expand Down Expand Up @@ -72,7 +71,7 @@ func (h VirtualMachineReadyHandler) Handle(ctx context.Context, vmbda *v1alpha2.
}

switch vm.Status.Phase {
case v1alpha2.MachineRunning:
case v1alpha2.MachineRunning, v1alpha2.MachineMigrating:
// OK.
case v1alpha2.MachineStopping, v1alpha2.MachineStopped, v1alpha2.MachineStarting:
vmbda.Status.Phase = v1alpha2.BlockDeviceAttachmentPhasePending
Expand Down
Loading
Loading