diff --git a/Dockerfile b/Dockerfile index 0ecbc18ea..366ba9128 100644 --- a/Dockerfile +++ b/Dockerfile @@ -95,6 +95,9 @@ RUN apk add --no-cache openssh sshpass # Install dependancy for OCP 4.14 CLI RUN apk --update add gcompat +#Install aws-cli +RUN apk add aws-cli && aws --version + # Install yq RUN wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64 -O /usr/bin/yq && \ chmod +x /usr/bin/yq diff --git a/pkg/asyncdr/asyncdr.go b/pkg/asyncdr/asyncdr.go index ecff0551b..e467bec05 100644 --- a/pkg/asyncdr/asyncdr.go +++ b/pkg/asyncdr/asyncdr.go @@ -766,7 +766,7 @@ func ChangePxServiceToLoadBalancer(internalLB bool) error { // Check if service is already of type loadbalancer const ( pxStcServiceTypeKey = "portworx.io/service-type" - stcLoadBalancerValue = "LoadBalancer" + stcLoadBalancerValue = "portworx-service:LoadBalancer" pxStcServiceKey = "service/portworx-service" awsInternalLBKey = "service.beta.kubernetes.io/aws-load-balancer-internal" awsInternalLBValue = "true" diff --git a/tests/basic/async_dr_test.go b/tests/basic/async_dr_test.go index 1f4a90fef..4e1291cab 100644 --- a/tests/basic/async_dr_test.go +++ b/tests/basic/async_dr_test.go @@ -235,7 +235,7 @@ var _ = Describe("{MigrateDeploymentMetroAsync}", func() { namespace := GetAppNamespace(ctx, taskName) migrationNamespaces = append(migrationNamespaces, namespace) log.Infof("Creating clusterpair between first and second cluster") - err = ScheduleBidirectionalClusterPair(defaultClusterPairName, namespace, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(defaultClusterPairName, namespace, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, nil) log.FailOnError(err, "Failed creating bidirectional cluster pair") } } @@ -268,7 +268,7 @@ var _ = Describe("{MigrateDeploymentMetroAsync}", func() { for i, currMigNamespace := range migrationNamespaces { log.Infof("Creating clusterpair between second and third cluster") - ScheduleBidirectionalClusterPair(defaultClusterPairNameNew, currMigNamespace, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.SecondCluster, asyncdr.ThirdCluster) + ScheduleBidirectionalClusterPair(defaultClusterPairNameNew, currMigNamespace, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.SecondCluster, asyncdr.ThirdCluster, nil) migrationName := migrationKey + fmt.Sprintf("%d", i) + time.Now().Format("15h03m05s") currMig, err := asyncdr.CreateMigration(migrationName, currMigNamespace, defaultClusterPairNameNew, currMigNamespace, &includeVolumesFlagAsync, &includeResourcesFlag, &startApplicationsFlag, nil) Expect(err).NotTo(HaveOccurred(), @@ -651,36 +651,6 @@ var _ = Describe("{StorkctlPerformFailoverFailbackeckEsClusterwide}", func() { }) }) -var _ = Describe("{ChangePXSvc}", func() { - // testrailID = 297921 - // testrailID corresponds to: https://portworx.testrail.net/index.php?/cases/view/297921 - BeforeEach(func() { - if !kubeConfigWritten { - // Write kubeconfig files after reading from the config maps created by torpedo deploy script - WriteKubeconfigToFiles() - kubeConfigWritten = true - } - wantAllAfterSuiteActions = false - }) - - // JustBeforeEach(func() { - // StartTorpedoTest("Change PX Svc", "Change PX Svc", nil, testrailID) - // runID = testrailuttils.AddRunsToMilestone(testrailID) - // }) - - It("Change PX service type", func() { - Step("Change PX service type", func() { - err := asyncdr.ChangePxServiceToLoadBalancer(false) - log.Infof("Error is: %v", err) - }) - }) - - // JustAfterEach(func() { - // defer EndTorpedoTest() - // AfterEachTest(contexts, testrailID, runID) - // }) -}) - var _ = Describe("{UpgradeVolumeDriverDuringAppBkpRestore}", func() { BeforeEach(func() { if !kubeConfigWritten { @@ -859,7 +829,7 @@ var _ = Describe("{UpgradeVolumeDriverDuringAsyncDrMigration}", func() { Step("create clusterpair and start migration", func() { log.InfoD("Creating clusterpair between first and second cluster") - err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, nil) log.FailOnError(err, "Failed creating bidirectional cluster pair") log.InfoD("Start migration schedule and perform failover") @@ -1046,16 +1016,29 @@ func validateFailoverFailback(clusterType, taskNamePrefix string, single, skipSo } isCloud, cloudName := asyncdr.IsCloud() + var srcEp, destEp string + extraArgsCp := map[string]string{} + const defaultPort = "9001" if isCloud { if err = asyncdr.ChangePxServiceToLoadBalancer(false); err != nil { log.FailOnError(err, "failed to change PX service to LoadBalancer on source cluster") } + if cloudName == "eks" { + pxService, err := core.Instance().GetService("portworx-service", "kube-system") + log.FailOnError(err, "failed to get px service") + srcEp = pxService.Status.LoadBalancer.Ingress[0].Hostname + } err = SetDestinationKubeConfig() log.FailOnError(err, "Failed to set destination kubeconfig") if err = asyncdr.ChangePxServiceToLoadBalancer(false); err != nil { log.FailOnError(err, "failed to change PX service to LoadBalancer on destination cluster") } + if cloudName == "eks" { + pxService, err := core.Instance().GetService("portworx-service", "kube-system") + log.FailOnError(err, "failed to get px service") + destEp = pxService.Status.LoadBalancer.Ingress[0].Hostname + } err = SetSourceKubeConfig() log.FailOnError(err, "Failed to set source kubeconfig") } @@ -1068,13 +1051,18 @@ func validateFailoverFailback(clusterType, taskNamePrefix string, single, skipSo defaultBackupLocation = googleBackupLocation } + if cloudName == "eks" { + extraArgsCp["src-ep"] = srcEp + ":" + defaultPort + extraArgsCp["dest-ep"] = destEp + ":" + defaultPort + } + log.Infof("Creating clusterpair between first and second cluster") cpName := defaultClusterPairName + time.Now().Format("15h03m05s") if clusterType == "asyncdr" { - err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, extraArgsCp) } else { - err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(cpName, defaultNs, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, extraArgsCp) } log.FailOnError(err, "Failed creating bidirectional cluster pair") @@ -1418,9 +1406,9 @@ func validateOperatorMigFailover(namespace, clusterType, opName, crName string, kubeConfigPathDest, err := GetCustomClusterConfigPath(asyncdr.SecondCluster) log.FailOnError(err, "Failed to get destination configPath: %v", err) if clusterType == "asyncdr" { - err = ScheduleBidirectionalClusterPair(cpName, namespace, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(cpName, namespace, "", storkapi.BackupLocationType(defaultBackupLocation), defaultSecret, "async-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, nil) } else { - err = ScheduleBidirectionalClusterPair(cpName, namespace, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster) + err = ScheduleBidirectionalClusterPair(cpName, namespace, "", "", "", "sync-dr", asyncdr.FirstCluster, asyncdr.SecondCluster, nil) } log.FailOnError(err, "Failed creating bidirectional cluster pair") log.Infof("Start migration schedule and perform failover") diff --git a/tests/common.go b/tests/common.go index 69155d9f1..03257b09d 100644 --- a/tests/common.go +++ b/tests/common.go @@ -4113,7 +4113,7 @@ func CreateClusterPairFile(pairInfo map[string]string, skipStorage, resetConfig return addStorageOptions(pairInfo, clusterPairFileName) } -func ScheduleBidirectionalClusterPair(cpName, cpNamespace, projectMappings string, objectStoreType storkv1.BackupLocationType, secretName string, mode string, sourceCluster int, destCluster int) (err error) { +func ScheduleBidirectionalClusterPair(cpName, cpNamespace, projectMappings string, objectStoreType storkv1.BackupLocationType, secretName string, mode string, sourceCluster int, destCluster int, extraArgs map[string]string) (err error) { // var token string // Setting kubeconfig to source because we will create bidirectional cluster pair based on source as reference err = SetCustomKubeConfig(sourceCluster) @@ -4196,6 +4196,13 @@ func ScheduleBidirectionalClusterPair(cpName, cpNamespace, projectMappings strin } } + if extraArgs != nil { + for key, value := range extraArgs { + cmdArgs = append(cmdArgs, "--"+key) + cmdArgs = append(cmdArgs, value) + } + } + if projectMappings != "" { cmdArgs = append(cmdArgs, "--project-mappings") cmdArgs = append(cmdArgs, projectMappings)