Skip to content

Commit

Permalink
add length limits to API name
Browse files Browse the repository at this point in the history
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
  • Loading branch information
LiZhenCheng9527 committed Feb 20, 2024
1 parent 386cab0 commit 6348727
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
gomega.Expect(secretCreateErr).ShouldNot(gomega.HaveOccurred())

attachedCreateErr := resources.CreateAttachedCluster(kuratorClient, attachedcluster)
gomega.Expect(attachedCreateErr).ShouldNot(gomega.HaveOccurred())
resources.WaitAttachedClusterFitWith(kuratorClient, namespace, memberClusterName, func(attachedCluster *clusterv1a1.AttachedCluster) bool {
return attachedCluster.Status.Ready
})
gomega.Expect(attachedCreateErr).ShouldNot(gomega.HaveOccurred())
})
14 changes: 12 additions & 2 deletions pkg/cluster-operator/customcluster_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,21 @@ func generateClusterConfigKey(customCluster *v1alpha1.CustomCluster) client.Obje
}

func generateClusterHostsName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterHostsName
name := customCluster.Name + "-" + ClusterHostsName
name = strings.ToLower(name)
if len(name) > 63 {
name = name[:63]
}
return name
}

func generateClusterConfigName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterConfigName
name := customCluster.Name + "-" + ClusterConfigName
name = strings.ToLower(name)
if len(name) > 63 {
name = name[:63]
}
return name
}

func generateOwnerRefFromCustomCluster(customCluster *v1alpha1.CustomCluster) metav1.OwnerReference {
Expand Down
7 changes: 6 additions & 1 deletion pkg/cluster-operator/customcluster_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ func generateScaleUpHostsKey(customCluster *v1alpha1.CustomCluster) client.Objec
}

func generateScaleUpHostsName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterHostsName + "-scale-up"
name := customCluster.Name + "-" + ClusterHostsName + "-scale-up"
name = strings.ToLower(name)
if len(name) > 63 {
name = name[:63]
}
return name
}

// generateScaleDownManageCMD generate a kubespray cmd to delete the node from the list of nodesNeedDelete.
Expand Down
2 changes: 1 addition & 1 deletion pkg/fleet-manager/application/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func getSyncPolicyKind(syncPolicy *applicationapi.ApplicationSyncPolicy) string
}

// generatePolicyResourceName creates a unique name for a policy resource (such as helmRelease or kustomization)
// based on the provided application, cluster kind, and cluster name.
// based on the provided application, cluster kind and cluster name.
func generatePolicyResourceName(policyName, clusterKind, clusterName string) string {
name := policyName + "-" + clusterKind + "-" + clusterName
name = strings.ToLower(name)
Expand Down
8 changes: 7 additions & 1 deletion pkg/fleet-manager/backup/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"reflect"
"sort"
"strings"
"time"

"github.com/robfig/cron/v3"
Expand Down Expand Up @@ -241,7 +242,12 @@ func generateVeleroResourceObjectMeta(veleroResourceName string, labels map[stri

// generateVeleroResourceName generate a name uniquely across object store
func generateVeleroResourceName(clusterName, creatorKind, creatorNamespace, creatorName string) string {
return clusterName + "-" + creatorKind + "-" + creatorNamespace + "-" + creatorName
name := clusterName + "-" + creatorKind + "-" + creatorNamespace + "-" + creatorName
name = strings.ToLower(name)
if len(name) > 63 {
name = name[:63]
}
return name
}

// MostRecentCompletedBackup returns the most recent backup that's completed from a list of backups.
Expand Down

0 comments on commit 6348727

Please sign in to comment.