Skip to content

Commit bf46c41

Browse files
authored
Merge pull request #340 from tinakurian/wto-77-fix-hanging-terminal-main
fix hanging terminal
2 parents 95cb199 + fb7dd20 commit bf46c41

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

pkg/constants/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ const (
7979
// this annotation will be cleared
8080
WorkspaceStopReasonAnnotation = "controller.devfile.io/stopped-by"
8181

82+
// WebhookRestartedAtAnnotation holds the the time (unixnano) of when the webhook server was forced to restart by controller
83+
WebhookRestartedAtAnnotation = "controller.devfile.io/restarted-at"
84+
8285
// PVCCleanupPodMemoryLimit is the memory limit used for PVC clean up pods
8386
PVCCleanupPodMemoryLimit = "100Mi"
8487

pkg/webhook/deployment.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ func getSpecDeployment(webhooksSecretName, namespace string) (*appsv1.Deployment
9292
},
9393
Template: corev1.PodTemplateSpec{
9494
ObjectMeta: metav1.ObjectMeta{
95-
Name: server.WebhookServerDeploymentName,
96-
Namespace: namespace,
97-
Labels: server.WebhookServerAppLabels(),
95+
Name: server.WebhookServerDeploymentName,
96+
Namespace: namespace,
97+
Labels: server.WebhookServerAppLabels(),
98+
Annotations: server.WebhookServerAppAnnotations(),
9899
},
99100
Spec: corev1.PodSpec{
100101
Containers: []corev1.Container{

webhook/server/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import (
1414
"errors"
1515
"io/ioutil"
1616
"os"
17+
"strconv"
18+
"time"
1719

20+
"github.com/devfile/devworkspace-operator/pkg/constants"
1821
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
1922

2023
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -54,6 +57,17 @@ var WebhookServerAppLabels = func() map[string]string {
5457
}
5558
}
5659

60+
var WebhookServerAppAnnotations = func() map[string]string {
61+
//Add restart timestamp which will update the webhook server
62+
//deployment to force restart. This is done so that the
63+
//serviceaccount uid is updated to use the latest and the
64+
//web-terminal does not hang.
65+
now := time.Now()
66+
return map[string]string{
67+
constants.WebhookRestartedAtAnnotation: strconv.FormatInt(now.UnixNano(), 10),
68+
}
69+
}
70+
5771
func ConfigureWebhookServer(mgr manager.Manager) error {
5872
enabled, err := infrastructure.IsWebhookConfigurationEnabled()
5973

0 commit comments

Comments
 (0)