@@ -13,7 +13,6 @@ import (
1313 "strconv"
1414 "strings"
1515 "time"
16- "unicode/utf8"
1716
1817 "github.com/containers/common/libnetwork/types"
1918 "github.com/containers/common/pkg/config"
@@ -36,14 +35,14 @@ import (
3635
3736// GenerateForKube takes a slice of libpod containers and generates
3837// one v1.Pod description that includes just a single container.
39- func GenerateForKube (ctx context.Context , ctrs []* Container , getService , useLongAnnotations , podmanOnly bool ) (* v1.Pod , error ) {
38+ func GenerateForKube (ctx context.Context , ctrs []* Container , getService , podmanOnly bool ) (* v1.Pod , error ) {
4039 // Generate the v1.Pod yaml description
41- return simplePodWithV1Containers (ctx , ctrs , getService , useLongAnnotations , podmanOnly )
40+ return simplePodWithV1Containers (ctx , ctrs , getService , podmanOnly )
4241}
4342
4443// GenerateForKube takes a slice of libpod containers and generates
4544// one v1.Pod description
46- func (p * Pod ) GenerateForKube (ctx context.Context , getService , useLongAnnotations , podmanOnly bool ) (* v1.Pod , []v1.ServicePort , error ) {
45+ func (p * Pod ) GenerateForKube (ctx context.Context , getService , podmanOnly bool ) (* v1.Pod , []v1.ServicePort , error ) {
4746 // Generate the v1.Pod yaml description
4847 var (
4948 ports []v1.ContainerPort
@@ -95,7 +94,7 @@ func (p *Pod) GenerateForKube(ctx context.Context, getService, useLongAnnotation
9594 hostUsers = infraContainer .IDMappings ().HostUIDMapping && infraContainer .IDMappings ().HostGIDMapping
9695 infraName = infraContainer .config .Name
9796 }
98- pod , err := p .podWithContainers (ctx , allContainers , ports , hostNetwork , hostUsers , getService , useLongAnnotations , podmanOnly , infraName )
97+ pod , err := p .podWithContainers (ctx , allContainers , ports , hostNetwork , hostUsers , getService , podmanOnly , infraName )
9998 if err != nil {
10099 return nil , servicePorts , err
101100 }
@@ -451,16 +450,6 @@ func newServicePortState() servicePortState {
451450 }
452451}
453452
454- func truncateKubeAnnotation (str string , useLongAnnotations bool ) string {
455- str = strings .TrimSpace (str )
456- if useLongAnnotations || utf8 .RuneCountInString (str ) < define .MaxKubeAnnotation {
457- return str
458- }
459- trunc := string ([]rune (str )[:define .MaxKubeAnnotation ])
460- logrus .Warnf ("Truncation Annotation: %q to %q: Kubernetes only allows %d characters" , str , trunc , define .MaxKubeAnnotation )
461- return trunc
462- }
463-
464453// containerPortsToServicePorts takes a slice of containerports and generates a
465454// slice of service ports
466455func (state * servicePortState ) containerPortsToServicePorts (containerPorts []v1.ContainerPort ) ([]v1.ServicePort , error ) {
@@ -507,7 +496,7 @@ func containersToServicePorts(containers []v1.Container) ([]v1.ServicePort, erro
507496 return sps , nil
508497}
509498
510- func (p * Pod ) podWithContainers (ctx context.Context , containers []* Container , ports []v1.ContainerPort , hostNetwork , hostUsers , getService , useLongAnnotations , podmanOnly bool , infraName string ) (* v1.Pod , error ) {
499+ func (p * Pod ) podWithContainers (ctx context.Context , containers []* Container , ports []v1.ContainerPort , hostNetwork , hostUsers , getService , podmanOnly bool , infraName string ) (* v1.Pod , error ) {
511500 deDupPodVolumes := make (map [string ]* v1.Volume )
512501 first := true
513502 podContainers := make ([]v1.Container , 0 , len (containers ))
@@ -529,11 +518,11 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
529518 if ! podmanOnly && (define .IsReservedAnnotation (k ) || annotations .IsReservedAnnotation (k )) {
530519 continue
531520 }
532- podAnnotations [fmt .Sprintf ("%s/%s" , k , removeUnderscores (ctr .Name ()))] = truncateKubeAnnotation ( v , useLongAnnotations )
521+ podAnnotations [fmt .Sprintf ("%s/%s" , k , removeUnderscores (ctr .Name ()))] = v
533522 }
534523 // Convert auto-update labels into kube annotations
535- for k , v := range getAutoUpdateAnnotations (ctr .Name (), ctr .Labels (), useLongAnnotations ) {
536- podAnnotations [k ] = truncateKubeAnnotation ( v , useLongAnnotations )
524+ for k , v := range getAutoUpdateAnnotations (ctr .Name (), ctr .Labels ()) {
525+ podAnnotations [k ] = v
537526 }
538527 isInit := ctr .IsInitCtr ()
539528 // Since hostname is only set at pod level, set the hostname to the hostname of the first container we encounter
@@ -556,7 +545,7 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
556545 return nil , err
557546 }
558547 for k , v := range annotations {
559- podAnnotations [define .BindMountPrefix ] = truncateKubeAnnotation ( k + ":" + v , useLongAnnotations )
548+ podAnnotations [define .BindMountPrefix ] = k + ":" + v
560549 }
561550 // Since port bindings for the pod are handled by the
562551 // infra container, wipe them here only if we are sharing the net namespace
@@ -605,7 +594,7 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
605594 // If the infraName is not the podID-infra, that means the user set another infra name using
606595 // --infra-name during pod creation
607596 if infraName != "" && infraName != p .ID ()[:12 ]+ "-infra" {
608- podAnnotations [define .InfraNameAnnotation ] = truncateKubeAnnotation ( infraName , useLongAnnotations )
597+ podAnnotations [define .InfraNameAnnotation ] = infraName
609598 }
610599 }
611600 }
@@ -674,7 +663,7 @@ func newPodObject(podName string, annotations map[string]string, initCtrs, conta
674663
675664// simplePodWithV1Containers is a function used by inspect when kube yaml needs to be generated
676665// for a single container. we "insert" that container description in a pod.
677- func simplePodWithV1Containers (ctx context.Context , ctrs []* Container , getService , useLongAnnotations , podmanOnly bool ) (* v1.Pod , error ) {
666+ func simplePodWithV1Containers (ctx context.Context , ctrs []* Container , getService , podmanOnly bool ) (* v1.Pod , error ) {
678667 kubeCtrs := make ([]v1.Container , 0 , len (ctrs ))
679668 kubeInitCtrs := []v1.Container {}
680669 kubeVolumes := make ([]v1.Volume , 0 )
@@ -694,12 +683,12 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
694683 if ! podmanOnly && (define .IsReservedAnnotation (k ) || annotations .IsReservedAnnotation (k )) {
695684 continue
696685 }
697- kubeAnnotations [fmt .Sprintf ("%s/%s" , k , removeUnderscores (ctr .Name ()))] = truncateKubeAnnotation ( v , useLongAnnotations )
686+ kubeAnnotations [fmt .Sprintf ("%s/%s" , k , removeUnderscores (ctr .Name ()))] = v
698687 }
699688
700689 // Convert auto-update labels into kube annotations
701- for k , v := range getAutoUpdateAnnotations (ctr .Name (), ctr .Labels (), useLongAnnotations ) {
702- kubeAnnotations [k ] = truncateKubeAnnotation ( v , useLongAnnotations )
690+ for k , v := range getAutoUpdateAnnotations (ctr .Name (), ctr .Labels ()) {
691+ kubeAnnotations [k ] = v
703692 }
704693
705694 isInit := ctr .IsInitCtr ()
@@ -752,7 +741,7 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
752741 return nil , err
753742 }
754743 for k , v := range annotations {
755- kubeAnnotations [define .BindMountPrefix ] = truncateKubeAnnotation ( k + ":" + v , useLongAnnotations )
744+ kubeAnnotations [define .BindMountPrefix ] = k + ":" + v
756745 }
757746 if isInit {
758747 kubeInitCtrs = append (kubeInitCtrs , kubeCtr )
@@ -1384,7 +1373,7 @@ func removeUnderscores(s string) string {
13841373
13851374// getAutoUpdateAnnotations searches for auto-update container labels
13861375// and returns them as kube annotations
1387- func getAutoUpdateAnnotations (ctrName string , ctrLabels map [string ]string , useLongAnnotations bool ) map [string ]string {
1376+ func getAutoUpdateAnnotations (ctrName string , ctrLabels map [string ]string ) map [string ]string {
13881377 autoUpdateLabel := "io.containers.autoupdate"
13891378 annotations := make (map [string ]string )
13901379
@@ -1394,7 +1383,7 @@ func getAutoUpdateAnnotations(ctrName string, ctrLabels map[string]string, useLo
13941383 // since labels can variate between containers within a pod, they will be
13951384 // identified with the container name when converted into kube annotations
13961385 kc := fmt .Sprintf ("%s/%s" , k , ctrName )
1397- annotations [kc ] = truncateKubeAnnotation ( v , useLongAnnotations )
1386+ annotations [kc ] = v
13981387 }
13991388 }
14001389
0 commit comments