diff --git a/hosted/eks/helper/helper_cluster.go b/hosted/eks/helper/helper_cluster.go index 2a011bc3..bb1018e7 100644 --- a/hosted/eks/helper/helper_cluster.go +++ b/hosted/eks/helper/helper_cluster.go @@ -312,7 +312,7 @@ func ScaleNodeGroup(cluster *management.Cluster, client *rancher.Client, nodeCou // if checkClusterConfig is true, it validates the update func UpdateLogging(cluster *management.Cluster, client *rancher.Client, loggingTypes []string, checkClusterConfig bool) (*management.Cluster, error) { upgradedCluster := cluster - *upgradedCluster.EKSConfig.LoggingTypes = loggingTypes + upgradedCluster.EKSConfig.LoggingTypes = &loggingTypes cluster, err := client.Management.Cluster.Update(cluster, &upgradedCluster) Expect(err).To(BeNil()) @@ -335,8 +335,8 @@ func UpdateLogging(cluster *management.Cluster, client *rancher.Client, loggingT // if checkClusterConfig is true, it validates the update func UpdateAccess(cluster *management.Cluster, client *rancher.Client, publicAccess, privateAccess bool, checkClusterConfig bool) (*management.Cluster, error) { upgradedCluster := cluster - *upgradedCluster.EKSConfig.PublicAccess = publicAccess - *upgradedCluster.EKSConfig.PrivateAccess = privateAccess + upgradedCluster.EKSConfig.PublicAccess = &publicAccess + upgradedCluster.EKSConfig.PrivateAccess = &privateAccess cluster, err := client.Management.Cluster.Update(cluster, &upgradedCluster) diff --git a/hosted/eks/k8s_chart_support/upgrade/k8s_chart_support_upgrade_suite_test.go b/hosted/eks/k8s_chart_support/upgrade/k8s_chart_support_upgrade_suite_test.go index 09a7139a..2351e70d 100644 --- a/hosted/eks/k8s_chart_support/upgrade/k8s_chart_support_upgrade_suite_test.go +++ b/hosted/eks/k8s_chart_support/upgrade/k8s_chart_support_upgrade_suite_test.go @@ -169,12 +169,8 @@ func commonchecks(ctx *helpers.RancherContext, cluster *management.Cluster, clus cluster, err = helper.UpgradeClusterKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true) Expect(err).To(BeNil()) - var useEksctl bool - if helpers.IsImport { - useEksctl = true - } By("upgrading the NodeGroups", func() { - cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true, true, useEksctl) + cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true, true, helpers.IsImport) Expect(err).To(BeNil()) }) }) diff --git a/hosted/eks/p0/p0_suite_test.go b/hosted/eks/p0/p0_suite_test.go index 2c80d716..b5ae68af 100644 --- a/hosted/eks/p0/p0_suite_test.go +++ b/hosted/eks/p0/p0_suite_test.go @@ -80,12 +80,8 @@ func p0upgradeK8sVersionChecks(cluster *management.Cluster, client *rancher.Clie Expect(err).To(BeNil()) }) - var useEksctl bool - if helpers.IsImport { - useEksctl = true - } By("upgrading the NodeGroups", func() { - cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, client, true, true, useEksctl) + cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, client, true, true, helpers.IsImport) Expect(err).To(BeNil()) }) } diff --git a/hosted/eks/p1/p1_import_test.go b/hosted/eks/p1/p1_import_test.go index 70525f4c..9c21ee01 100644 --- a/hosted/eks/p1/p1_import_test.go +++ b/hosted/eks/p1/p1_import_test.go @@ -166,6 +166,23 @@ var _ = Describe("P1Import", func() { updateTagsAndLabels(cluster, ctx.RancherAdminClient) }) + It("Add a nodegroup in EKS -> Syncs to Rancher -> Update cluster, the nodegroup is intact", func() { + testCaseID = 87 + nodepoolcount := len(cluster.EKSStatus.UpstreamSpec.NodeGroups) + err := helper.AddNodeGroupOnAWS(namegen.AppendRandomString("ng"), clusterName, region) + Expect(err).To(BeNil()) + Eventually(func() bool { + cluster, err = ctx.RancherAdminClient.Management.Cluster.ByID(cluster.ID) + Expect(err).To(BeNil()) + return len(cluster.EKSStatus.UpstreamSpec.NodeGroups) == nodepoolcount+1 + }, "10m", "7s").Should(BeTrue(), "Timed out while waiting for rancher to sync") + cluster, err = helper.UpdateLogging(cluster, ctx.RancherAdminClient, []string{"authenticator"}, true) + Expect(err).To(BeNil()) + + // verify that the nodegroups are intact + Expect(cluster.EKSStatus.UpstreamSpec.NodeGroups).To(HaveLen(nodepoolcount + 1)) + }) + Context("Reimporting/Editing a cluster with invalid config", func() { It("Reimport a cluster to Rancher should fail", func() { testCaseID = 101 diff --git a/hosted/eks/p1/p1_provisioning_test.go b/hosted/eks/p1/p1_provisioning_test.go index 36891396..a87570e0 100644 --- a/hosted/eks/p1/p1_provisioning_test.go +++ b/hosted/eks/p1/p1_provisioning_test.go @@ -7,6 +7,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" + "github.com/rancher/shepherd/extensions/clusters" "github.com/rancher/shepherd/extensions/clusters/eks" namegen "github.com/rancher/shepherd/pkg/namegenerator" @@ -168,6 +169,25 @@ var _ = Describe("P1Provisioning", func() { Expect(amiID).To(Or(Equal("AL2_x86_64_GPU"), Equal("AL2023_x86_64_NVIDIA"))) }) + XIt("Deploy a cluster with Public/Priv access then disable Public access", func() { + // https://github.com/rancher/eks-operator/issues/752#issuecomment-2609144199 + testCaseID = 151 + createFunc := func(clusterConfig *eks.ClusterConfig) { + clusterConfig.PublicAccess = pointer.Bool(true) + clusterConfig.PrivateAccess = pointer.Bool(true) + } + var err error + cluster, err = helper.CreateEKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, region, createFunc) + Expect(err).To(BeNil()) + cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient) + Expect(err).To(BeNil()) + + cluster, err = helper.UpdateAccess(cluster, ctx.RancherAdminClient, false, true, true) + Expect(err).To(BeNil()) + + helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName) + }) + Context("Upgrade testing", func() { var upgradeToVersion string @@ -206,6 +226,54 @@ var _ = Describe("P1Provisioning", func() { updateClusterInUpdatingState(cluster, ctx.RancherAdminClient, upgradeToVersion) }) }) + + When("a cluster is created with multiple nodegroups", func() { + BeforeEach(func() { + var err error + createFunc := func(clusterConfig *eks.ClusterConfig) { + *clusterConfig, err = helper.AddNodeGroupToConfig(*clusterConfig, 4) + Expect(err).To(BeNil()) + } + cluster, err = helper.CreateEKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, region, createFunc) + Expect(err).To(BeNil()) + cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient) + Expect(err).To(BeNil()) + }) + + It("Update k8s version of node groups - sequential & simultaneous upgrade of multiple node groups", func() { + testCaseID = 153 + var err error + cluster, err = helper.UpgradeClusterKubernetesVersion(cluster, upgradeToVersion, ctx.RancherAdminClient, true) + Expect(err).To(BeNil()) + + // upgrade 2 nodegroups simultaneously + updateFunc := func(cluster *management.Cluster) { + nodeGroups := cluster.EKSConfig.NodeGroups + for i := 0; i <= 1; i++ { + nodeGroups[i].Version = &upgradeToVersion + } + } + cluster, err = helper.UpdateCluster(cluster, ctx.RancherAdminClient, updateFunc) + Expect(err).To(BeNil()) + err = clusters.WaitClusterToBeUpgraded(ctx.RancherAdminClient, cluster.ID) + Expect(err).To(BeNil()) + Eventually(func() bool { + cluster, err = ctx.RancherAdminClient.Management.Cluster.ByID(cluster.ID) + Expect(err).To(BeNil()) + nodeGroups := cluster.EKSStatus.UpstreamSpec.NodeGroups + for i := 0; i <= 1; i++ { + if nodeGroups[i].Version == nil || *nodeGroups[i].Version != upgradeToVersion { + return false + } + } + return true + }, "10m", "7s").Should(BeTrue()) + + // upgrade the remaining nodegroups + cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, ctx.RancherAdminClient, true, true, false) + Expect(err).To(BeNil()) + }) + }) }) When("a cluster is created", func() {