Skip to content
Draft
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
3 changes: 2 additions & 1 deletion images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ shell:
install:
- |
echo "Git clone {{ $gitRepoName }} repository..."
git clone --depth=1 $(cat /run/secrets/SOURCE_REPO)/{{ $gitRepoUrl }} --branch {{ $tag }} /src/kubevirt
echo kek12345
git clone --depth=1 $(cat /run/secrets/SOURCE_REPO)/{{ $gitRepoUrl }} --branch v1.6.2-virtualization-fix-thawning /src/kubevirt

rm -rf /src/kubevirt/.git

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,29 @@ package internal

import (
"context"
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/deckhouse/virtualization-controller/pkg/controller/conditions"
"github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/state"
"github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition"
subv1alpha2 "github.com/deckhouse/virtualization/api/subresources/v1alpha2"
)

const nameFilesystemHandler = "FilesystemHandler"
const (
nameFilesystemHandler = "FilesystemHandler"
annKek = "kek"
)

func NewFilesystemHandler() *FilesystemHandler {
return &FilesystemHandler{}
func NewFilesystemHandler(virtClient VirtClient) *FilesystemHandler {
return &FilesystemHandler{virtClient: virtClient}
}

type FilesystemHandler struct{}
type FilesystemHandler struct {
virtClient VirtClient
}

func (h *FilesystemHandler) Handle(ctx context.Context, s state.VirtualMachineState) (reconcile.Result, error) {
if s.VirtualMachine().IsEmpty() {
Expand Down Expand Up @@ -67,6 +74,20 @@ func (h *FilesystemHandler) Handle(ctx context.Context, s state.VirtualMachineSt
return reconcile.Result{}, nil
}

if request, ok := changed.Annotations[annKek]; ok {
switch request {
case "freeze":
if err = h.virtClient.VirtualMachines(changed.Namespace).Freeze(ctx, changed.Name, subv1alpha2.VirtualMachineFreeze{}); err != nil {
return reconcile.Result{}, fmt.Errorf("freeze virtual machine %s/%s: %w", changed.Namespace, changed.Name, err)
}
case "unfreeze":
if err = h.virtClient.VirtualMachines(changed.Namespace).Unfreeze(ctx, changed.Name); err != nil {
return reconcile.Result{}, fmt.Errorf("unfreeze virtual machine %s/%s: %w", changed.Namespace, changed.Name, err)
}
}
delete(changed.Annotations, annKek)
}

agentReady, _ := conditions.GetCondition(vmcondition.TypeAgentReady, changed.Status.Conditions)
if agentReady.Status != metav1.ConditionTrue {
return reconcile.Result{}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func SetupController(
internal.NewUSBDeviceAttachHandler(client, virtClient),
internal.NewProvisioningHandler(client),
internal.NewAgentHandler(),
internal.NewFilesystemHandler(),
internal.NewFilesystemHandler(virtClient),
internal.NewSnapshottingHandler(client),
internal.NewPodHandler(client),
internal.NewSizePolicyHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *v1alpha2.Virtu
Status(readyCondition.Status).
Reason(conditions.CommonReason(readyCondition.Reason)).
Message(readyCondition.Message)

_, err = h.unfreezeVirtualMachineIfCan(ctx, vmSnapshot, vm, kvvmi)
if err != nil {
if errors.Is(err, service.ErrUntrustedFilesystemFrozenCondition) {
log.Debug(err.Error())
return reconcile.Result{}, nil
}
if k8serrors.IsConflict(err) {
log.Debug(fmt.Sprintf("failed to unfreeze filesystem; resource update conflict error: %s", err))
return reconcile.Result{RequeueAfter: 5 * time.Second}, nil
}
cb.Message(fmt.Sprintf("%s, %s", err.Error(), cb.Condition().Message))
return reconcile.Result{}, fmt.Errorf("failed to unfreeze filesystem: %w", err)
}
return reconcile.Result{}, nil
case v1alpha2.VirtualMachineSnapshotPhaseReady:
// Ensure vd snapshots aren't lost.
Expand Down
Loading