From 9ba2efc72c8569afe7687c2a4de3561f46391c67 Mon Sep 17 00:00:00 2001 From: Brad Davidson <brad.davidson@rancher.com> Date: Tue, 21 Sep 2021 12:42:21 -0700 Subject: [PATCH] Use short host name in job name (#150) The Kubernetes job controller unsafely trims the Job name when setting the GenerateName for the Job Pods, but if we keep the hostname short we're less likely to trip over it until the bug can be fixed upstream. Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --- pkg/upgrade/job/job.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/upgrade/job/job.go b/pkg/upgrade/job/job.go index fd71e5ed..9e35748d 100644 --- a/pkg/upgrade/job/job.go +++ b/pkg/upgrade/job/job.go @@ -4,6 +4,7 @@ import ( "os" "sort" "strconv" + "strings" "github.com/rancher/system-upgrade-controller/pkg/apis/condition" upgradeapi "github.com/rancher/system-upgrade-controller/pkg/apis/upgrade.cattle.io" @@ -96,9 +97,10 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat hostPathDirectory := corev1.HostPathDirectory labelPlanName := upgradeapi.LabelPlanName(plan.Name) nodeHostname := upgradenode.Hostname(node) + shortNodeName := strings.SplitN(nodeHostname, ".", 2)[0] job := &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ - Name: name.SafeConcatName("apply", plan.Name, "on", node.Name, "with", plan.Status.LatestHash), + Name: name.SafeConcatName("apply", plan.Name, "on", shortNodeName, "with", plan.Status.LatestHash), Namespace: plan.Namespace, Annotations: labels.Set{ upgradeapi.AnnotationTTLSecondsAfterFinished: strconv.FormatInt(int64(TTLSecondsAfterFinished), 10), -- GitLab