Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add length limits to API name #602

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
})
8 changes: 6 additions & 2 deletions pkg/cluster-operator/customcluster_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,15 @@ func generateClusterConfigKey(customCluster *v1alpha1.CustomCluster) client.Obje
}

func generateClusterHostsName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterHostsName
hostName := customCluster.Name + "-" + ClusterHostsName
hostName = names.SimpleNameGenerator.GenerateName(hostName)
return hostName
}

func generateClusterConfigName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterConfigName
configName := customCluster.Name + "-" + ClusterConfigName
configName = names.SimpleNameGenerator.GenerateName(configName)
return configName
}

func generateOwnerRefFromCustomCluster(customCluster *v1alpha1.CustomCluster) metav1.OwnerReference {
Expand Down
5 changes: 4 additions & 1 deletion pkg/cluster-operator/customcluster_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/storage/names"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
"sigs.k8s.io/cluster-api/util/conditions"
Expand Down Expand Up @@ -234,7 +235,9 @@ func generateScaleUpHostsKey(customCluster *v1alpha1.CustomCluster) client.Objec
}

func generateScaleUpHostsName(customCluster *v1alpha1.CustomCluster) string {
return customCluster.Name + "-" + ClusterHostsName + "-scale-up"
scaleUpHostName := customCluster.Name + "-" + ClusterHostsName + "-scale-up"
scaleUpHostName = names.SimpleNameGenerator.GenerateName(scaleUpHostName)
return scaleUpHostName
}

// generateScaleDownManageCMD generate a kubespray cmd to delete the node from the list of nodesNeedDelete.
Expand Down
3 changes: 3 additions & 0 deletions pkg/fleet-manager/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apiserver/pkg/storage/names"
ctrl "sigs.k8s.io/controller-runtime"

fleetapi "kurator.dev/kurator/pkg/apis/fleet/v1alpha1"
Expand All @@ -45,6 +46,7 @@ func (f *FleetManager) reconcileControlPlane(ctx context.Context, fleet *fleetap
}
// TODO: generate a valid name
podName := fleet.Name + "-init"
podName = names.SimpleNameGenerator.GenerateName(podName)
namespace := fleet.Namespace

clusterKey := types.NamespacedName{Name: podName, Namespace: namespace}
Expand Down Expand Up @@ -155,6 +157,7 @@ func (f *FleetManager) deleteControlPlane(ctx context.Context, fleet *fleetapi.F
return nil
}
podName := fleet.Name + "-delete"
podName = names.SimpleNameGenerator.GenerateName(podName)
namespace := fleet.Namespace

clusterKey := types.NamespacedName{Name: podName, Namespace: namespace}
Expand Down
Loading