Commit 9498a127 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #42024 from luomiao/fix-vsphere-remove-port

Automatic merge from submit-queue Remove VCenterPort from vsphere cloud provider. **What this PR does / why we need it**: Address a bug inside vsphere cloud provider when a port number other than 443 is specified inside the config file. The url which is used for communicating with govmomi should not include port number. A port number other than 443 will result in 404 error. VCenterPort stays in VSphereConfig structure for backward compatibility. **Which issue this PR fixes** : fixes https://github.com/kubernetes/kubernetes-anywhere/issues/338
parents d790851c 6e96a1b8
......@@ -273,6 +273,9 @@ func newVSphere(cfg VSphereConfig) (*VSphere, error) {
if cfg.Global.RoundTripperCount == 0 {
cfg.Global.RoundTripperCount = RoundTripperDefaultCount
}
if cfg.Global.VCenterPort != "" {
glog.Warningf("port is a deprecated field in vsphere.conf and will be removed in future release.")
}
c, err := newClient(context.TODO(), &cfg)
if err != nil {
......@@ -310,7 +313,7 @@ func logout(vs *VSphere) {
func newClient(ctx context.Context, cfg *VSphereConfig) (*govmomi.Client, error) {
// Parse URL from string
u, err := url.Parse(fmt.Sprintf("https://%s:%s/sdk", cfg.Global.VCenterIP, cfg.Global.VCenterPort))
u, err := url.Parse(fmt.Sprintf("https://%s/sdk", cfg.Global.VCenterIP))
if err != nil {
return nil, err
}
......
......@@ -33,7 +33,6 @@ func configFromEnv() (cfg VSphereConfig, ok bool) {
var InsecureFlag bool
var err error
cfg.Global.VCenterIP = os.Getenv("VSPHERE_VCENTER")
cfg.Global.VCenterPort = os.Getenv("VSPHERE_VCENTER_PORT")
cfg.Global.User = os.Getenv("VSPHERE_USER")
cfg.Global.Password = os.Getenv("VSPHERE_PASSWORD")
cfg.Global.Datacenter = os.Getenv("VSPHERE_DATACENTER")
......@@ -81,10 +80,6 @@ vm-uuid = 1234
t.Errorf("incorrect vcenter ip: %s", cfg.Global.VCenterIP)
}
if cfg.Global.VCenterPort != "443" {
t.Errorf("incorrect vcenter port: %s", cfg.Global.VCenterPort)
}
if cfg.Global.Datacenter != "us-west" {
t.Errorf("incorrect datacenter: %s", cfg.Global.Datacenter)
}
......
......@@ -43,7 +43,6 @@ func GetVSphere() (*VSphere, error) {
func getVSphereConfig() *VSphereConfig {
var cfg VSphereConfig
cfg.Global.VCenterIP = os.Getenv("VSPHERE_VCENTER")
cfg.Global.VCenterPort = os.Getenv("VSPHERE_VCENTER_PORT")
cfg.Global.User = os.Getenv("VSPHERE_USER")
cfg.Global.Password = os.Getenv("VSPHERE_PASSWORD")
cfg.Global.Datacenter = os.Getenv("VSPHERE_DATACENTER")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment