From b0501a91c4d8a5212f2c10b513930c04ba179b02 Mon Sep 17 00:00:00 2001 From: Daniil Antoshin Date: Thu, 5 Dec 2024 14:11:44 +0200 Subject: [PATCH] feat(api): console,vnc reconnect (#553) * feat(api): console,vnc reconnect Signed-off-by: Daniil Antoshin --- Taskfile.yaml | 2 +- .../025-stream-graceful-shutdown.patch | 23 +++++++++++++++++++ .../hack/dlv-apiserver.Dockerfile | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 images/virt-artifact/patches/025-stream-graceful-shutdown.patch diff --git a/Taskfile.yaml b/Taskfile.yaml index ef95a691e..8af220c0a 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -150,7 +150,7 @@ tasks: dlv:virt-handler:build: desc: "Build image virt-handler with dlv" - cmd: docker build -f ./images/virt-handler/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" . + cmd: docker build -f ./images/virt-handler/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 . dlv:virt-handler:build-push: desc: "Build and Push image virt-handler with dlv" diff --git a/images/virt-artifact/patches/025-stream-graceful-shutdown.patch b/images/virt-artifact/patches/025-stream-graceful-shutdown.patch new file mode 100644 index 000000000..fcb328b9a --- /dev/null +++ b/images/virt-artifact/patches/025-stream-graceful-shutdown.patch @@ -0,0 +1,23 @@ +diff --git a/pkg/virt-handler/rest/console.go b/pkg/virt-handler/rest/console.go +index 4eb681018d..f76f6187a7 100644 +--- a/pkg/virt-handler/rest/console.go ++++ b/pkg/virt-handler/rest/console.go +@@ -43,6 +43,8 @@ import ( + + "kubevirt.io/kubevirt/pkg/util" + "kubevirt.io/kubevirt/pkg/virt-handler/isolation" ++ ++ "github.com/gorilla/websocket" + ) + + //const failedRetrieveVMI = "Failed to retrieve VMI" +@@ -326,7 +328,7 @@ func (t *ConsoleHandler) stream(vmi *v1.VirtualMachineInstance, request *restful + + select { + case <-stopCh: +- break ++ clientSocket.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseGoingAway, "close by another connection")) + case err := <-errCh: + if err != nil && err != io.EOF { + log.Log.Object(vmi).Reason(err).Error("Error in proxing websocket and unix socket") + diff --git a/images/virtualization-artifact/hack/dlv-apiserver.Dockerfile b/images/virtualization-artifact/hack/dlv-apiserver.Dockerfile index ad65390a4..c6b928106 100644 --- a/images/virtualization-artifact/hack/dlv-apiserver.Dockerfile +++ b/images/virtualization-artifact/hack/dlv-apiserver.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.8-bookworm@sha256:ac14cc827536ef1a124cd2f7a03178c3335c1db8ad3807e7fdd57f74096abfa0 AS builder +FROM golang:1.22.8-bookworm@sha256:3f0457a0a56a926d93c2baf4cf0057a645e8ff69ff31314080fcc62389643b8e AS builder ARG TARGETOS ARG TARGETARCH