From 0ddeacf4427e087dc64d28b46effefc90c31b44a Mon Sep 17 00:00:00 2001 From: QcFe Date: Thu, 12 Jan 2023 16:26:41 +0100 Subject: [PATCH] noVNC/websockify upgrade, cleanup and healthz --- .github/workflows/build-matrix.json | 5 -- deploy/crownlabs/values.yaml | 1 - operators/pkg/forge/containers.go | 2 +- operators/pkg/forge/containers_test.go | 2 +- .../containers/gui-common/novnc/Dockerfile | 46 -------------- .../containers/gui-common/novnc/entrypoint.sh | 15 ----- .../gui-common/novnc/nginx.conf.template | 63 ------------------- .../novnc/novnc-overrides/app/styles/base.css | 17 ----- .../novnc/novnc-overrides/app/ui.js | 34 ---------- .../novnc/novnc-overrides/app/webutil.js | 5 -- .../gui-common/novnc/prepare-novnc.sh | 38 ----------- .../gui-common/tigervnc/fluxbox/init | 6 +- .../gui-common/websockify/Dockerfile | 2 +- .../containers/gui-common/websockify/go.mod | 32 +++++----- .../containers/gui-common/websockify/go.sum | 30 +++++++++ .../containers/gui-common/websockify/main.go | 17 ++++- .../gui-common/websockify/metrics.go | 12 +++- .../websockify/remote_instmetrics.go | 3 +- 18 files changed, 79 insertions(+), 251 deletions(-) delete mode 100644 provisioning/containers/gui-common/novnc/Dockerfile delete mode 100644 provisioning/containers/gui-common/novnc/entrypoint.sh delete mode 100644 provisioning/containers/gui-common/novnc/nginx.conf.template delete mode 100644 provisioning/containers/gui-common/novnc/novnc-overrides/app/styles/base.css delete mode 100644 provisioning/containers/gui-common/novnc/novnc-overrides/app/ui.js delete mode 100644 provisioning/containers/gui-common/novnc/novnc-overrides/app/webutil.js delete mode 100644 provisioning/containers/gui-common/novnc/prepare-novnc.sh diff --git a/.github/workflows/build-matrix.json b/.github/workflows/build-matrix.json index f33276b6e..afae60b1f 100644 --- a/.github/workflows/build-matrix.json +++ b/.github/workflows/build-matrix.json @@ -59,11 +59,6 @@ "harbor-project": "crownlabs-core" }, - { - "component": "novnc", - "context": "./provisioning/containers/gui-common/novnc", - "harbor-project": "crownlabs-container-envs-tools" - }, { "component": "tigervnc", "context": "./provisioning/containers/gui-common/tigervnc", diff --git a/deploy/crownlabs/values.yaml b/deploy/crownlabs/values.yaml index c006c93bb..77913f038 100644 --- a/deploy/crownlabs/values.yaml +++ b/deploy/crownlabs/values.yaml @@ -72,7 +72,6 @@ instance-operator: tag: "" vncImage: crownlabs/tigervnc websockifyImage: crownlabs/websockify - novncImage: crownlabs/novnc filebrowserImage: filebrowser/filebrowser filebrowserImageTag: latest instmetricsServerEndpoint: crownlabs-instmetrics.crownlabs-production:9090 diff --git a/operators/pkg/forge/containers.go b/operators/pkg/forge/containers.go index 6ef7cd34b..47c201a15 100644 --- a/operators/pkg/forge/containers.go +++ b/operators/pkg/forge/containers.go @@ -212,7 +212,7 @@ func WebsockifyContainer(opts *ContainerEnvOpts, environment *clv1alpha2.Environ AddContainerArg(&websockifyContainer, "pod-name", fmt.Sprintf("$(%s)", PodNameEnvName)) AddContainerArg(&websockifyContainer, "cpu-limit", fmt.Sprintf("$(%s)", AppCPULimitsEnvName)) AddContainerArg(&websockifyContainer, "memory-limit", fmt.Sprintf("$(%s)", AppMEMLimitsEnvName)) - SetContainerReadinessHTTPProbe(&websockifyContainer, GUIPortName, IngressGUICleanPath(instance)) + SetContainerReadinessHTTPProbe(&websockifyContainer, GUIPortName, HealthzEndpoint) return websockifyContainer } diff --git a/operators/pkg/forge/containers_test.go b/operators/pkg/forge/containers_test.go index c69a98049..8ed9c7e13 100644 --- a/operators/pkg/forge/containers_test.go +++ b/operators/pkg/forge/containers_test.go @@ -388,7 +388,7 @@ var _ = Describe("Containers and Deployment spec forging", func() { Expect(actual.Ports).To(Equal(expected.Ports)) }) It("Should set the readiness probe", func() { - forge.SetContainerReadinessHTTPProbe(&expected, "gui", forge.IngressGUICleanPath(&instance)) + forge.SetContainerReadinessHTTPProbe(&expected, "gui", forge.HealthzEndpoint) Expect(actual.ReadinessProbe).To(Equal(expected.ReadinessProbe)) }) It("Should set the env varibles", func() { diff --git a/provisioning/containers/gui-common/novnc/Dockerfile b/provisioning/containers/gui-common/novnc/Dockerfile deleted file mode 100644 index 6f7ed9bef..000000000 --- a/provisioning/containers/gui-common/novnc/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM alpine:3.14 AS builder - -WORKDIR /build -RUN mkdir -p /BUILD -ENV HTML_DATA=/build - -RUN apk add bash - -COPY . . -RUN bash ./prepare-novnc.sh - - -FROM nginx:1.19.5-alpine - -ENV HTML_DATA=/usr/share/nginx/html - -# Copy config template and entrypoint -COPY nginx.conf.template /etc/nginx/nginx.conf.template -COPY entrypoint.sh /entrypoint.sh -COPY --from=builder /build ${HTML_DATA} - -# Set default build arguments -ARG HTTP_PORT=8080 - -ARG UID=1010 -ARG USER=crownlabs - -# Create default env variables -ENV HTTP_PORT=${HTTP_PORT}\ - HIDE_NOVNC_BAR=false\ - USER=${USER} - -# Add non-root user and ensure authorizations -RUN adduser -D -H -u ${UID} -s /sbin/nologin ${USER} && \ - chown -R ${USER}:${USER} $HTML_DATA && \ - chown -R ${USER}:${USER} /var/cache/nginx && \ - chown -R ${USER}:${USER} /var/log/nginx && \ - chown -R ${USER}:${USER} /etc/nginx/nginx.conf && \ - chmod a+x /entrypoint.sh - -EXPOSE ${HTTP_PORT} - -# Enforce non-root user -USER ${USER} - -ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/provisioning/containers/gui-common/novnc/entrypoint.sh b/provisioning/containers/gui-common/novnc/entrypoint.sh deleted file mode 100644 index 7a6d927ea..000000000 --- a/provisioning/containers/gui-common/novnc/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -set -e - -envsubst "\$WEBSOCKIFY_HOST \$WEBSOCKIFY_PORT \$HTTP_PORT" \ - < /etc/nginx/nginx.conf.template \ - > /etc/nginx/nginx.conf - -# Hide noVNC control bar (mostly used for clipboard) if requested -if [ "$HIDE_NOVNC_BAR" = true ]; then - echo "#noVNC_control_bar_anchor {display:none !important;}" \ - >> "$HTML_DATA"/app/styles/base.css -fi - -# Start nginx (not in daemon mode for Docker use) -nginx -g "daemon off;" "$@" diff --git a/provisioning/containers/gui-common/novnc/nginx.conf.template b/provisioning/containers/gui-common/novnc/nginx.conf.template deleted file mode 100644 index cbfe6f8dc..000000000 --- a/provisioning/containers/gui-common/novnc/nginx.conf.template +++ /dev/null @@ -1,63 +0,0 @@ -# Templated nginx configuration, derived from the default nginx config - -worker_processes auto; - -# Save pid into /tmp to fix errors when running as non-root -pid /tmp/nginx.pid; - -# Workers configuration -events { - worker_connections 1024; -} - -# Main interface -http { - # Default file server configuration - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - # See https://thoughts.t37.net/nginx-optimization-understanding-sendfile-tcp-nodelay-and-tcp-nopush-c55cdd276765 for better understanding the following options: - # - Enable sendfile() syscall to avoid use of userspace buffers when possible - sendfile on; - # - Disable nopush & enable nodelay: this should reduce latency by making smaller packets, to improve user experience with novnc - tcp_nopush off; - tcp_nodelay on; - - # Disable compression. - # Should be tested if there is any appreciable difference on a real scenario - #gzip on; - - # Actual server configuration - server { - listen ${HTTP_PORT}; # Server port - - # Serve noVNC client files on server root - location / { - # Disable caching to prevent issues on novnc updates - add_header Cache-Control no-cache; - root /usr/share/nginx/html; - # Set default document served on root - index vnc.html; - gzip_static on; - sub_filter '' ''; - } - - # Define healthz endpoint for Prometheus - location /healthz { - access_log off; - return 200 "healthy\n"; - } - - # Provide error pages locations - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - } -} diff --git a/provisioning/containers/gui-common/novnc/novnc-overrides/app/styles/base.css b/provisioning/containers/gui-common/novnc/novnc-overrides/app/styles/base.css deleted file mode 100644 index 09e9772b0..000000000 --- a/provisioning/containers/gui-common/novnc/novnc-overrides/app/styles/base.css +++ /dev/null @@ -1,17 +0,0 @@ -#noVNC_container { - border-bottom-right-radius: 0 !important; -} -#noVNC_connect_dlg .noVNC_logo { - font-size: 25px !important; - margin-bottom: 40px !important; - color: #F55; - font-family: sans-serif; - text-shadow: none; -} -#noVNC_connect_dlg::before { - content: 'CrownLabs'; - color: #DDD; - display: block; - text-align: center; - font-size: 60px; -} diff --git a/provisioning/containers/gui-common/novnc/novnc-overrides/app/ui.js b/provisioning/containers/gui-common/novnc/novnc-overrides/app/ui.js deleted file mode 100644 index d7587776c..000000000 --- a/provisioning/containers/gui-common/novnc/novnc-overrides/app/ui.js +++ /dev/null @@ -1,34 +0,0 @@ -window.onhashchange = () => { - const { hash } = window.location; - UI.forceSetting('resize', hash.includes('noresize') ? 'scale' : 'remote'); - UI.forceSetting('view_only', hash.includes('readonly')); - UI.updateViewOnly(); - UI.applyResizeMode(); -}; -const ois = UI.initSettings; -UI.initSettings = () => { - ois(); - if (window.websockifyTargetUrl) { - UI.forceSetting('path', window.websockifyTargetUrl); - } else { - let { pathname } = window.location; - pathname = pathname.split('/').filter(e => e).join('/'); - if (pathname) UI.forceSetting('path', pathname + '/vnc'); - } - UI.forceSetting('show_dot', true); - UI.forceSetting('reconnect', true); - UI.forceSetting('reconnect_delay', Math.floor(Math.random() * 2000)); - window.onhashchange(); -} -const oocp = UI.openConnectPanel; -let connAttempts = 0; -UI.openConnectPanel = () => { - connAttempts++; - if (connAttempts < 5) { - setTimeout(UI.connect, 100); - } else { - document.querySelector('#noVNC_connect_dlg .noVNC_logo').innerText = 'Connection failed' - connAttempts = 0; - oocp(); - } -} diff --git a/provisioning/containers/gui-common/novnc/novnc-overrides/app/webutil.js b/provisioning/containers/gui-common/novnc/novnc-overrides/app/webutil.js deleted file mode 100644 index 7c363a0b9..000000000 --- a/provisioning/containers/gui-common/novnc/novnc-overrides/app/webutil.js +++ /dev/null @@ -1,5 +0,0 @@ -const ogcv = getConfigVar; -getConfigVar = (a, b) => { - if (a === 'autoconnect') return true; - return ogcv(a, b); -} diff --git a/provisioning/containers/gui-common/novnc/prepare-novnc.sh b/provisioning/containers/gui-common/novnc/prepare-novnc.sh deleted file mode 100644 index 5283d4df0..000000000 --- a/provisioning/containers/gui-common/novnc/prepare-novnc.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -e - -if [ -z "$NONVC_VER" ]; then - NONVC_VER=v1.3.0 -fi - -if [ -z "$HTML_DATA" ]; then - echo "HTML_DATA is not set" - exit 1 -fi - -# ensure directory exists -mkdir -p "$HTML_DATA" - -echo "Downloading and extracting noVNC $NONVC_VER" -wget -qO- https://github.com/novnc/noVNC/archive/$NONVC_VER.tar.gz | tar xz -C "$HTML_DATA" --strip 1 - -echo "Injecting noVNC customizations" -for filename in $(cd novnc-overrides && find . -type f); do - echo "Customizing $filename" - DIRNAME=$(dirname "$filename") - mkdir -p "$HTML_DATA"/"$DIRNAME" - if [[ $(basename "$filename") == *.js || $(basename "$filename") == *.css ]]; then - printf "\n/* CrownLabs overrides */\n" >> "$HTML_DATA"/"$filename" - fi - cat novnc-overrides/"$filename" >> "$HTML_DATA"/"$filename" -done - -# cleanup -echo "Cleaning up" -rm -rf "$HTML_DATA"/docs -rm -rf "$HTML_DATA"/snap -rm -rf "$HTML_DATA"/tests -rm -rf "$HTML_DATA"/utils -rm -rf "$HTML_DATA"/po -rm -rf "$HTML_DATA"/.github - -echo "Done" diff --git a/provisioning/containers/gui-common/tigervnc/fluxbox/init b/provisioning/containers/gui-common/tigervnc/fluxbox/init index 1b8ded0cc..575f01919 100644 --- a/provisioning/containers/gui-common/tigervnc/fluxbox/init +++ b/provisioning/containers/gui-common/tigervnc/fluxbox/init @@ -31,7 +31,7 @@ session.screen0.focusModel: ClickFocus session.screen0.showwindowposition: false session.screen0.maxIgnoreIncrement: true session.screen0.workspaces: 1 -session.screen0.maxDisableMove: false +session.screen0.maxDisableMove: true session.screen0.autoRaise: true session.screen0.tooltipDelay: 500 session.screen0.edgeSnapThreshold: 10 @@ -39,13 +39,13 @@ session.screen0.colPlacementDirection: TopToBottom session.screen0.tabFocusModel: ClickToTabFocus session.screen0.opaqueMove: true session.screen0.strftimeFormat: %02k:%M:%S - %d/%m/%Y -session.screen0.windowPlacement: RowMinOverlapPlacement +session.screen0.windowPlacement: CascadePlacement session.screen0.focusNewWindows: true session.screen0.clickRaises: true session.screen0.maxDisableResize: false session.screen0.allowRemoteActions: false session.screen0.focusSameHead: false -session.screen0.workspacewarping: true +session.screen0.workspacewarping: false session.screen0.fullMaximization: false session.screen0.defaultDeco: NORMAL session.screen0.noFocusWhileTypingDelay: 0 diff --git a/provisioning/containers/gui-common/websockify/Dockerfile b/provisioning/containers/gui-common/websockify/Dockerfile index 1002b6c6c..8d0b55e54 100644 --- a/provisioning/containers/gui-common/websockify/Dockerfile +++ b/provisioning/containers/gui-common/websockify/Dockerfile @@ -1,5 +1,5 @@ -FROM golang:1.17 as builder +FROM golang:1.19 as builder WORKDIR /tmp/builder COPY go.mod ./go.mod diff --git a/provisioning/containers/gui-common/websockify/go.mod b/provisioning/containers/gui-common/websockify/go.mod index 8cca8d9e5..c51e9b145 100644 --- a/provisioning/containers/gui-common/websockify/go.mod +++ b/provisioning/containers/gui-common/websockify/go.mod @@ -1,28 +1,28 @@ module github.com/novnc/websockify-other/websockify -go 1.17 +go 1.19 require ( - github.com/google/uuid v1.1.2 - github.com/gorilla/websocket v1.4.2 - github.com/prometheus/client_golang v1.12.1 - google.golang.org/grpc v1.46.0 - google.golang.org/protobuf v1.27.1 - k8s.io/apimachinery v0.24.0 + github.com/google/uuid v1.3.0 + github.com/gorilla/websocket v1.5.0 + github.com/prometheus/client_golang v1.14.0 + google.golang.org/grpc v1.52.0 + google.golang.org/protobuf v1.28.1 + k8s.io/apimachinery v0.26.0 ) require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect - golang.org/x/text v0.3.7 // indirect - google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/common v0.39.0 // indirect + github.com/prometheus/procfs v0.9.0 // indirect + golang.org/x/net v0.5.0 // indirect + golang.org/x/sys v0.4.0 // indirect + golang.org/x/text v0.6.0 // indirect + google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect gopkg.in/inf.v0 v0.9.1 // indirect ) diff --git a/provisioning/containers/gui-common/websockify/go.sum b/provisioning/containers/gui-common/websockify/go.sum index 345f5ae6c..cdb17032d 100644 --- a/provisioning/containers/gui-common/websockify/go.sum +++ b/provisioning/containers/gui-common/websockify/go.sum @@ -52,6 +52,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -156,11 +158,15 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -189,6 +195,8 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -219,22 +227,30 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -335,6 +351,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -401,6 +419,8 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -411,6 +431,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -517,6 +539,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 h1:bFFRpT+e8JJVY7lMMfvezL1ZIwqiwmPl2bsE2yx4HqM= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -533,6 +557,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= +google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -547,6 +573,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -577,6 +605,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/apimachinery v0.24.0 h1:ydFCyC/DjCvFCHK5OPMKBlxayQytB8pxy8YQInd5UyQ= k8s.io/apimachinery v0.24.0/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= +k8s.io/apimachinery v0.26.0 h1:1feANjElT7MvPqp0JT6F3Ss6TWDwmcjLypwoPpEf7zg= +k8s.io/apimachinery v0.26.0/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/provisioning/containers/gui-common/websockify/main.go b/provisioning/containers/gui-common/websockify/main.go index 818bdc6f9..03ae59461 100644 --- a/provisioning/containers/gui-common/websockify/main.go +++ b/provisioning/containers/gui-common/websockify/main.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Main websockify package package main import ( @@ -70,7 +71,9 @@ func main() { // SyncMap shared between NoVncHandler and InstanceMetricsHandler var connectionsTracking sync.Map - http.Handle("/", &NoVncHandler{ + mux := http.NewServeMux() + + mux.Handle("/", &NoVncHandler{ BasePath: *basePath, NoVncFS: http.FileServer(http.FS(novncFS)), ShowNoVncBar: *showBar, @@ -87,7 +90,17 @@ func main() { }, }) - if err := http.ListenAndServe(*httpAddr, nil); err != nil { + mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + }) + + server := &http.Server{ + Addr: *httpAddr, + ReadHeaderTimeout: 5 * time.Second, + Handler: mux, + } + + if err := server.ListenAndServe(); err != nil { log.Fatal("failed starting websockify server", err) } } diff --git a/provisioning/containers/gui-common/websockify/metrics.go b/provisioning/containers/gui-common/websockify/metrics.go index c4d2e68cb..537946ba2 100644 --- a/provisioning/containers/gui-common/websockify/metrics.go +++ b/provisioning/containers/gui-common/websockify/metrics.go @@ -17,6 +17,7 @@ package main import ( "log" "net/http" + "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -35,9 +36,16 @@ var ( ) func runMetricsServer(addr, metricsEndpoint string) { - http.Handle(metricsEndpoint, promhttp.Handler()) + mux := http.NewServeMux() + mux.Handle(metricsEndpoint, promhttp.Handler()) - if err := http.ListenAndServe(addr, nil); err != nil { + server := &http.Server{ + Addr: addr, + ReadHeaderTimeout: 5 * time.Second, + Handler: mux, + } + + if err := server.ListenAndServe(); err != nil { log.Fatal("failed starting metrics server", err) } } diff --git a/provisioning/containers/gui-common/websockify/remote_instmetrics.go b/provisioning/containers/gui-common/websockify/remote_instmetrics.go index ea43efd69..a3b057295 100644 --- a/provisioning/containers/gui-common/websockify/remote_instmetrics.go +++ b/provisioning/containers/gui-common/websockify/remote_instmetrics.go @@ -21,6 +21,7 @@ import ( pb "github.com/novnc/websockify-other/websockify/instmetrics" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) // InstanceMetricsClient is a gRPC implementation of pb.InstanceMetricsClient. @@ -47,7 +48,7 @@ func GetInstanceMetricsClient(ctx context.Context, connectionTimeout time.Durati func newInstanceMetricsClient(ctx context.Context, endpoint string) (*InstanceMetricsClient, error) { log.Println("Connecting to instance metrics server", "endpoint", endpoint) - connection, err := grpc.DialContext(ctx, endpoint, grpc.WithInsecure(), grpc.WithBlock()) + connection, err := grpc.DialContext(ctx, endpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { log.Printf("An error occurred while creating instance metrics server client: %v", err) return nil, err