Skip to content

Commit 2ef3d77

Browse files
authored
Use short host name in job name (#151)
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 <[email protected]>
1 parent 32a31b2 commit 2ef3d77

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/upgrade/job/job.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package job
33
import (
44
"os"
55
"strconv"
6+
"strings"
67

78
"github.com/rancher/system-upgrade-controller/pkg/apis/condition"
89
upgradeapi "github.com/rancher/system-upgrade-controller/pkg/apis/upgrade.cattle.io"
@@ -94,9 +95,10 @@ var (
9495
func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *batchv1.Job {
9596
hostPathDirectory := corev1.HostPathDirectory
9697
labelPlanName := upgradeapi.LabelPlanName(plan.Name)
98+
shortNodeName := strings.SplitN(upgradenode.Hostname(node), ".", 2)[0]
9799
job := &batchv1.Job{
98100
ObjectMeta: metav1.ObjectMeta{
99-
Name: name.SafeConcatName("apply", plan.Name, "on", node.Name, "with", plan.Status.LatestHash),
101+
Name: name.SafeConcatName("apply", plan.Name, "on", shortNodeName, "with", plan.Status.LatestHash),
100102
Namespace: plan.Namespace,
101103
Annotations: labels.Set{
102104
upgradeapi.AnnotationTTLSecondsAfterFinished: strconv.FormatInt(int64(TTLSecondsAfterFinished), 10),

0 commit comments

Comments
 (0)