mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-04 20:24:02 +00:00
Refactor the code to get the plugin images for migration cases.
Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
@@ -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"
|
||||
@@ -146,22 +147,26 @@ 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"
|
||||
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + "," + migrationNeedPlugins[AWS][0]
|
||||
}
|
||||
}
|
||||
veleroCLI2Version.VeleroCLI, err = InstallVeleroCLI(veleroCLI2Version.VeleroVersion)
|
||||
|
||||
@@ -35,8 +35,9 @@ 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"
|
||||
|
||||
@@ -47,7 +48,7 @@ const (
|
||||
VeleroVSphereConfigMapName = "velero-vsphere-plugin-config"
|
||||
)
|
||||
|
||||
var PublicCloudProviders = []string{AWS, Azure, Gcp, Vsphere}
|
||||
var PublicCloudProviders = []string{AWS, Azure, GCP, Vsphere}
|
||||
var LocalCloudProviders = []string{Kind, VanillaZFS}
|
||||
var CloudProviders = append(PublicCloudProviders, LocalCloudProviders...)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -54,77 +54,56 @@ 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"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -132,10 +111,10 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider string, nee
|
||||
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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user