From fb7dd20f8b4af00a941aea121f70e50ab47354f5 Mon Sep 17 00:00:00 2001 From: Tina Kurian Date: Fri, 19 Mar 2021 13:13:48 -0400 Subject: [PATCH] fix hanging terminal --- pkg/constants/constants.go | 3 +++ pkg/webhook/deployment.go | 7 ++++--- webhook/server/server.go | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 95f0cb742..fb7867029 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -79,6 +79,9 @@ const ( // this annotation will be cleared WorkspaceStopReasonAnnotation = "controller.devfile.io/stopped-by" + // WebhookRestartedAtAnnotation holds the the time (unixnano) of when the webhook server was forced to restart by controller + WebhookRestartedAtAnnotation = "controller.devfile.io/restarted-at" + // PVCCleanupPodMemoryLimit is the memory limit used for PVC clean up pods PVCCleanupPodMemoryLimit = "100Mi" diff --git a/pkg/webhook/deployment.go b/pkg/webhook/deployment.go index 4b85b3d74..fe4d65adf 100755 --- a/pkg/webhook/deployment.go +++ b/pkg/webhook/deployment.go @@ -92,9 +92,10 @@ func getSpecDeployment(webhooksSecretName, namespace string) (*appsv1.Deployment }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: server.WebhookServerDeploymentName, - Namespace: namespace, - Labels: server.WebhookServerAppLabels(), + Name: server.WebhookServerDeploymentName, + Namespace: namespace, + Labels: server.WebhookServerAppLabels(), + Annotations: server.WebhookServerAppAnnotations(), }, Spec: corev1.PodSpec{ Containers: []corev1.Container{ diff --git a/webhook/server/server.go b/webhook/server/server.go index 98a5cbb92..ae0781cc0 100644 --- a/webhook/server/server.go +++ b/webhook/server/server.go @@ -14,7 +14,10 @@ import ( "errors" "io/ioutil" "os" + "strconv" + "time" + "github.com/devfile/devworkspace-operator/pkg/constants" "github.com/devfile/devworkspace-operator/pkg/infrastructure" "sigs.k8s.io/controller-runtime/pkg/manager" @@ -54,6 +57,17 @@ var WebhookServerAppLabels = func() map[string]string { } } +var WebhookServerAppAnnotations = func() map[string]string { + //Add restart timestamp which will update the webhook server + //deployment to force restart. This is done so that the + //serviceaccount uid is updated to use the latest and the + //web-terminal does not hang. + now := time.Now() + return map[string]string{ + constants.WebhookRestartedAtAnnotation: strconv.FormatInt(now.UnixNano(), 10), + } +} + func ConfigureWebhookServer(mgr manager.Manager) error { enabled, err := infrastructure.IsWebhookConfigurationEnabled()