diff --git a/e2e/suite_test.go b/e2e/suite_test.go index a1644087d..982d21f18 100644 --- a/e2e/suite_test.go +++ b/e2e/suite_test.go @@ -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()) }) diff --git a/pkg/cluster-operator/customcluster_helper.go b/pkg/cluster-operator/customcluster_helper.go index a75587622..44dc08ad9 100644 --- a/pkg/cluster-operator/customcluster_helper.go +++ b/pkg/cluster-operator/customcluster_helper.go @@ -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 { diff --git a/pkg/cluster-operator/customcluster_scale.go b/pkg/cluster-operator/customcluster_scale.go index 99d49d2b3..2fc7d4c78 100644 --- a/pkg/cluster-operator/customcluster_scale.go +++ b/pkg/cluster-operator/customcluster_scale.go @@ -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" @@ -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. diff --git a/pkg/fleet-manager/controlplane.go b/pkg/fleet-manager/controlplane.go index 38b2231bf..cc4896b6b 100644 --- a/pkg/fleet-manager/controlplane.go +++ b/pkg/fleet-manager/controlplane.go @@ -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" @@ -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} @@ -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}