Merge pull request #111255 from divyenpatel/declare-not-supported-vSphere-versions

declare unsupported vSphere versions for in-tree plugin
This commit is contained in:
Kubernetes Prow Robot 2022-07-27 13:20:04 -07:00 committed by GitHub
commit 1fe71e7f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 21 deletions

View File

@ -29,9 +29,8 @@ import (
"github.com/vmware/govmomi/sts" "github.com/vmware/govmomi/sts"
"github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap" "github.com/vmware/govmomi/vim25/soap"
"k8s.io/klog/v2"
"k8s.io/client-go/pkg/version" "k8s.io/client-go/pkg/version"
"k8s.io/klog/v2"
) )
// VSphereConnection contains information for connecting to vCenter // VSphereConnection contains information for connecting to vCenter
@ -218,16 +217,12 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
connection.RoundTripperCount = RoundTripperDefaultCount connection.RoundTripperCount = RoundTripperDefaultCount
} }
client.RoundTripper = vim25.Retry(client.RoundTripper, vim25.TemporaryNetworkError(int(connection.RoundTripperCount))) client.RoundTripper = vim25.Retry(client.RoundTripper, vim25.TemporaryNetworkError(int(connection.RoundTripperCount)))
vcdeprecated, err := isvCenterDeprecated(client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion) vcNotSupported, err := isvCenterNotSupported(client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion)
if err != nil { if err != nil {
klog.Errorf("failed to check if vCenter version:%v and api version: %s is deprecated. Error: %v", client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion, err) klog.Errorf("failed to check if vCenter version:%v and api version: %s is supported or not. Error: %v", client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion, err)
} }
if vcdeprecated { if vcNotSupported {
// After this deprecation, vSphere 6.5 support period is extended to October 15, 2022 as klog.Warningf("vCenter version (version: %q, api verson: %q) is not supported for CSI Migration. Please consider upgrading vCenter and ESXi servers to 7.0u2 or higher for migrating vSphere volumes to CSI.", client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion)
// https://blogs.vmware.com/vsphere/2021/03/announcing-limited-extension-of-vmware-vsphere-6-5-general-support-period.html
// In addition, the external vSphere cloud provider does not support vSphere 6.5.
// Please keep vSphere 6.5 support til the period.
klog.Warningf("vCenter is deprecated. version: %s, api verson: %s Please consider upgrading vCenter and ESXi servers to 6.7u3 or higher", client.ServiceContent.About.Version, client.ServiceContent.About.ApiVersion)
} }
return client, nil return client, nil
} }

View File

@ -201,8 +201,9 @@ func VerifyVolumePathsForVMDevices(vmDevices object.VirtualDeviceList, volPaths
} }
// isvCenterDeprecated takes vCenter version and vCenter API version as input and return true if vCenter is deprecated // isvCenterNotSupported takes vCenter version and vCenter API version as input and return true if vCenter is no longer
func isvCenterDeprecated(vCenterVersion string, vCenterAPIVersion string) (bool, error) { // supported by VMware for in-tree vSphere volume plugin
func isvCenterNotSupported(vCenterVersion string, vCenterAPIVersion string) (bool, error) {
var vcversion, vcapiversion, minvcversion vcVersion var vcversion, vcapiversion, minvcversion vcVersion
var err error var err error
err = vcversion.parse(vCenterVersion) err = vcversion.parse(vCenterVersion)

View File

@ -70,11 +70,11 @@ func TestUtils(t *testing.T) {
} }
} }
func TestIsvCenterDeprecated(t *testing.T) { func TestIsvCenterNotSupported(t *testing.T) {
type testsData struct { type testsData struct {
vcVersion string vcVersion string
vcAPIVersion string vcAPIVersion string
isDeprecated bool isNotSupported bool
} }
testdataArray := []testsData{ testdataArray := []testsData{
{"8.0.0", "8.0.0.0", false}, {"8.0.0", "8.0.0.0", false},
@ -90,16 +90,16 @@ func TestIsvCenterDeprecated(t *testing.T) {
} }
for _, test := range testdataArray { for _, test := range testdataArray {
deprecated, err := isvCenterDeprecated(test.vcVersion, test.vcAPIVersion) notsupported, err := isvCenterNotSupported(test.vcVersion, test.vcAPIVersion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if deprecated != test.isDeprecated { if notsupported != test.isNotSupported {
t.Fatalf("deprecation test failed for vc version: %q and vc API version: %q", t.Fatalf("test failed for vc version: %q and vc API version: %q",
test.vcVersion, test.vcAPIVersion) test.vcVersion, test.vcAPIVersion)
} else { } else {
t.Logf("deprecation test for vc version: %q and vc API version: %q passed. Is Deprecated : %v", t.Logf("test for vc version: %q and vc API version: %q passed. Is Not Supported : %v",
test.vcAPIVersion, test.vcAPIVersion, deprecated) test.vcAPIVersion, test.vcAPIVersion, notsupported)
} }
} }
} }