Skip to content

Commit

Permalink
Merge pull request #8349 from blackpiglet/fix_v1.15.0_migration_case_…
Browse files Browse the repository at this point in the history
…error

Fix v1.15.0 migration case error
  • Loading branch information
blackpiglet authored Oct 28, 2024
2 parents d2dec9d + 6f79c54 commit 1d4f147
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 76 deletions.
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ run-e2e: ginkgo
--standby-cluster-name=$(STANDBY_CLUSTER_NAME) \
--eks-policy-arn=$(EKS_POLICY_ARN) \
--default-cls-service-account-name=$(DEFAULT_CLS_SERVICE_ACCOUNT_NAME) \
--standby-cls-service-account-name=$(STANDBY_CLS_SERVICE_ACCOUNT_NAME)
--standby-cls-service-account-name=$(STANDBY_CLS_SERVICE_ACCOUNT_NAME) \
--kibishii-directory=$(KIBISHII_DIRECTORY) \
--disable-informer-cache=$(DISABLE_INFORMER_CACHE)

Expand Down
28 changes: 16 additions & 12 deletions test/e2e/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/mod/semver"

. "github.com/vmware-tanzu/velero/test"
util "github.com/vmware-tanzu/velero/test/util/csi"
Expand Down Expand Up @@ -146,24 +147,27 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
OriginVeleroCfg.RestoreHelperImage = ""
OriginVeleroCfg.Plugins = ""

// It is for v1.13.x migration scenario only, because since v1.14, nightly CI won't
// pass velero-plugin-for-csi to E2E test anymore, and velero installation will not
// fetch velero-plugin-for-csi automatically, so add it as hardcode below.
// TODO: remove this section from future version like v1.15, e.g.
versionWithoutPatch := semver.MajorMinor(veleroCLI2Version.VeleroVersion)
// Read migration case needs plugins from the PluginsMatrix map.
migrationNeedPlugins, ok := PluginsMatrix[versionWithoutPatch]
Expect(ok).To(BeTrue())

if OriginVeleroCfg.CloudProvider == Azure {
OriginVeleroCfg.Plugins = "velero/velero-plugin-for-microsoft-azure:v1.9.0"
OriginVeleroCfg.Plugins = migrationNeedPlugins[Azure][0]
}
if OriginVeleroCfg.CloudProvider == AWS {
OriginVeleroCfg.Plugins = "velero/velero-plugin-for-aws:v1.9.0"
OriginVeleroCfg.Plugins = migrationNeedPlugins[AWS][0]
}
if strings.Contains(OriginVeleroCfg.Features, FeatureCSI) {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + ",velero/velero-plugin-for-csi:v0.7.0"
// Because Velero CSI plugin is deprecated in v1.14,
// only need to install it for version lower than v1.14.
if strings.Contains(OriginVeleroCfg.Features, FeatureCSI) &&
semver.Compare(versionWithoutPatch, "v1.14") < 0 {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + "," + migrationNeedPlugins[CSI][0]
}
if OriginVeleroCfg.SnapshotMoveData {
if OriginVeleroCfg.CloudProvider == Azure {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + ",velero/velero-plugin-for-aws:v1.9.0"
}
if OriginVeleroCfg.SnapshotMoveData && OriginVeleroCfg.CloudProvider == Azure {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + "," + migrationNeedPlugins[AWS][0]
}

veleroCLI2Version.VeleroCLI, err = InstallVeleroCLI(veleroCLI2Version.VeleroVersion)
Expect(err).To(Succeed())
}
Expand Down
5 changes: 3 additions & 2 deletions test/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ const Azure = "azure"
const AzureCSI = "azure-csi"
const AwsCSI = "aws-csi"
const AWS = "aws"
const Gcp = "gcp"
const GCP = "gcp"
const Vsphere = "vsphere"
const CSI = "csi"

const UploaderTypeRestic = "restic"

var PublicCloudProviders = []string{AWS, Azure, Gcp, Vsphere}
var PublicCloudProviders = []string{AWS, Azure, GCP, Vsphere}
var LocalCloudProviders = []string{Kind, VanillaZFS}
var CloudProviders = append(PublicCloudProviders, LocalCloudProviders...)

Expand Down
2 changes: 1 addition & 1 deletion test/util/providers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func getProvider(cloudProvider string) (ObjectsInStorage, error) {
case AWS, Vsphere:
aws := AWSStorage("")
s = &aws
case Gcp:
case GCP:
gcs := GCSStorage("")
s = &gcs
case Azure:
Expand Down
99 changes: 39 additions & 60 deletions test/util/velero/velero_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,88 +54,67 @@ const BackupObjectsPrefix = "backups"
const RestoreObjectsPrefix = "restores"
const PluginsObjectsPrefix = "plugins"

var pluginsMatrix = map[string]map[string][]string{
"v1.7": {
"aws": {"velero/velero-plugin-for-aws:v1.3.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.3.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.3.0"},
"gcp": {"velero/velero-plugin-for-gcp:v1.3.0"},
"csi": {"velero/velero-plugin-for-csi:v0.2.0"},
},
"v1.8": {
"aws": {"velero/velero-plugin-for-aws:v1.4.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.4.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.3.1"},
"gcp": {"velero/velero-plugin-for-gcp:v1.4.0"},
"csi": {"velero/velero-plugin-for-csi:v0.2.0"},
},
"v1.9": {
"aws": {"velero/velero-plugin-for-aws:v1.5.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.5.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.4.0"},
"gcp": {"velero/velero-plugin-for-gcp:v1.5.0"},
"csi": {"velero/velero-plugin-for-csi:v0.3.0"},
},
var PluginsMatrix = map[string]map[string][]string{
"v1.10": {
"aws": {"velero/velero-plugin-for-aws:v1.6.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.6.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"velero/velero-plugin-for-gcp:v1.6.0"},
"csi": {"velero/velero-plugin-for-csi:v0.4.0"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.6.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.6.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.6.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.4.0"},
},
"v1.11": {
"aws": {"velero/velero-plugin-for-aws:v1.7.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.7.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"velero/velero-plugin-for-gcp:v1.7.0"},
"csi": {"velero/velero-plugin-for-csi:v0.5.0"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.7.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.7.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.7.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.5.0"},
},
"v1.12": {
"aws": {"velero/velero-plugin-for-aws:v1.8.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.8.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"velero/velero-plugin-for-gcp:v1.8.0"},
"csi": {"velero/velero-plugin-for-csi:v0.6.0"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.8.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.8.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.8.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.6.0"},
},
"v1.13": {
"aws": {"velero/velero-plugin-for-aws:v1.9.2"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.9.2"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.9.2"},
"csi": {"velero/velero-plugin-for-csi:v0.7.1"},
"datamover": {"velero/velero-plugin-for-aws:v1.9.2"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.9.2"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.9.2"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.9.2"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.7.1"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.9.2"},
},
"v1.14": {
"aws": {"velero/velero-plugin-for-aws:v1.10.1"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.10.1"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.10.1"},
"datamover": {"velero/velero-plugin-for-aws:v1.10.1"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.10.1"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.10.1"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.10.1"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.10.1"},
},
"v1.15": {
"aws": {"velero/velero-plugin-for-aws:v1.11.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.11.0"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.11.0"},
"datamover": {"velero/velero-plugin-for-aws:v1.11.0"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.11.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.11.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.11.0"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.11.0"},
},
"main": {
"aws": {"velero/velero-plugin-for-aws:main"},
"azure": {"velero/velero-plugin-for-microsoft-azure:main"},
"vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:main"},
"datamover": {"velero/velero-plugin-for-aws:main"},
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:main"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:main"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:main"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:main"},
},
}

func getPluginsByVersion(version, cloudProvider, objectStoreProvider string, needDataMoverPlugin bool) ([]string, error) {
var cloudMap map[string][]string
arr := strings.Split(version, ".")
if len(arr) >= 3 {
cloudMap = pluginsMatrix[arr[0]+"."+arr[1]]
cloudMap = PluginsMatrix[arr[0]+"."+arr[1]]
}
if len(cloudMap) == 0 {
cloudMap = pluginsMatrix["main"]
cloudMap = PluginsMatrix["main"]
if len(cloudMap) == 0 {
return nil, errors.Errorf("fail to get plugins by version: main")
}
Expand Down

0 comments on commit 1d4f147

Please sign in to comment.