Skip to content

Commit

Permalink
Update task container generated name check (flyteorg#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katrina Rogan authored Mar 3, 2021
1 parent e84585e commit ad902fb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions go/tasks/pluginmachinery/flytek8s/container_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package flytek8s

import (
"context"
"regexp"

"github.com/lyft/flyteplugins/go/tasks/pluginmachinery/core/template"
"k8s.io/apimachinery/pkg/util/validation"

"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"
"github.com/lyft/flytestdlib/logger"
Expand All @@ -18,8 +18,6 @@ import (
"github.com/lyft/flyteplugins/go/tasks/pluginmachinery/io"
)

var isAcceptableK8sName, _ = regexp.Compile("[a-z0-9]([-a-z0-9]*[a-z0-9])?")

const resourceGPU = "gpu"

// ResourceNvidiaGPU is the name of the Nvidia GPU resource.
Expand Down Expand Up @@ -115,7 +113,7 @@ func ToK8sContainer(ctx context.Context, taskExecutionMetadata pluginsCore.TaskE
// Make the container name the same as the pod name, unless it violates K8s naming conventions
// Container names are subject to the DNS-1123 standard
containerName := taskExecutionMetadata.GetTaskExecutionID().GetGeneratedName()
if !isAcceptableK8sName.MatchString(containerName) || len(containerName) > 63 {
if errs := validation.IsDNS1123Label(containerName); len(errs) > 0 {
containerName = rand.String(4)
}
c := &v1.Container{
Expand Down

0 comments on commit ad902fb

Please sign in to comment.