Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!--What happened: Provsioning a PVC using a storage class with vSphere as the cloud provider failed with error "runtime error: index out of range". What you expected to happen: The PVC should have been created. How to reproduce it (as minimally and precisely as possible): Create a PVC using a storage class with vSphere as the cloud provider and a VMware vCenter Server where the default language is not English. Anything else we need to know?: K8s in conjunction with vSphere PVC relies on English error messages from the VMware API in order to determine the canonical path for a newly created volume (VMDK file). The faulting code (v1.11.3, still the same on master) can be found here (starting at line 312): The line "canonicalVolumePath = match[1]" (340) in the above code is the problem because "File (.*?) was not found" (English) never matches for a different language (e.g. German: "Datei [DATASTORE] kubevols/kube- wurde nicht gefunden") and a “runtime error: index out of range” oocurs in the "kube-controller-manager". This causes the already created volume (VMDK file) not to be reported back to the K8s system which in turn will try to recreate it repeatedly in a loop (fails with "Cannot complete the operation because the file or folder [DATASTORE] /kubevols/kubernetes-dynamic-pvc-[UUID] already exists"). Find below the corresponding log excerpt (kube-controller-manager): Environment: Kubernetes version (use ):Cloud provider or hardware configuration: vSphere OS (e.g. from /etc/os-release): n/a Kernel (e.g. ): n/a Install tools: n/a Others: n/a <!-- DO NOT EDIT BELOW THIS LINE --/kind bug
/assign

Discussion:
"//vendor/github.com/vmware/govmomi/vapi/tags:go_default_library", "//vendor/github.com/vmware/govmomi/vim25:go_default_library", "//vendor/github.com/vmware/govmomi/vim25/mo:go_default_library", <ins> "//vendor/github.com/vmware/govmomi/vim25/soap:go_default_library", "//vendor/github.com/vmware/govmomi/vim25/types:go_default_library", </ins> "//vendor/gopkg.in/gcfg.v1:go_default_library", "//vendor/k8s.io/klog:go_default_library", ],

srcs = [ "credentialmanager_test.go", "vsphere_test.go", <ins> "vsphere_util_test.go", </ins> ], embed = [":go_default_library"], deps = [

"//staging/src/k8s.io/client-go/informers:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library", <ins> "//vendor/github.com/vmware/govmomi:go_default_library", </ins> "//vendor/github.com/vmware/govmomi/lookup/simulator:go_default_library", "//vendor/github.com/vmware/govmomi/property:go_default_library", "//vendor/github.com/vmware/govmomi/simulator:go_default_library",

"io/ioutil" "os" "path/filepath" <del> "regexp" </del> "strings" "time" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" <ins> "github.com/vmware/govmomi/vim25/soap" "github.com/vmware/govmomi/vim25/types" </ins> "k8s.io/klog" "k8s.io/api/core/v1"

// Querying a non-existent dummy disk on the datastore folder. // It would fail and return an folder ID in the error message. _, err := dc.GetVirtualDiskPage83Data(ctx, dummyDiskVolPath) <ins> canonicalVolumePath, err = getPathFromFileNotFound(err) </ins> if err != nil { <del> re := regexp.MustCompile("File (.*?) was not found") match := re.FindStringSubmatch(err.Error()) canonicalVolumePath = match[1] </del> <ins> return "", fmt.Errorf("failed to get path from dummy request: %v", err) </ins> } } diskPath := vclib.GetPathFromVMDiskPath(canonicalVolumePath)

return canonicalVolumePath, nil } <ins> // getPathFromFileNotFound returns the path from a fileNotFound error func getPathFromFileNotFound(err error) (string, error) { if soap.IsSoapFault(err) { fault := soap.ToSoapFault(err) f, ok := fault.VimFault().(types.FileNotFound) if !ok { return "", fmt.Errorf("%v is not a FileNotFound error", err) } return f.File, nil } return "", fmt.Errorf("%v is not a soap fault", err) } </ins> func setdatastoreFolderIDMap( datastoreFolderIDMap map[string]map[string]string, datastore string,

<ins> /* Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package vsphere import ( "context" "fmt" "testing" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib" "github.com/vmware/govmomi" "github.com/vmware/govmomi/simulator" ) func TestGetPathFromFileNotFound(t *testing.T) { ctx := context.Background() // vCenter model + initial set of objects (cluster, hosts, VMs, network, datastore, etc) model := simulator.VPX() defer model.Remove() err := model.Create() if err != nil { t.Fatal(err) } s := model.Service.NewServer() defer s.Close() c, err := govmomi.NewClient(ctx, s.URL, true) if err != nil { t.Fatal(err) } vc := &vclib.VSphereConnection{Client: c.Client} dc, err := vclib.GetDatacenter(ctx, vc, vclib.TestDefaultDatacenter) if err != nil { t.Errorf("failed to get datacenter: %v", err) } requestDiskPath := fmt.Sprintf("[%s] %s", vclib.TestDefaultDatastore, DummyDiskName) _, err = dc.GetVirtualDiskPage83Data(ctx, requestDiskPath) if err == nil { t.Error("expected error when calling GetVirtualDiskPage83Data") } _, err = getPathFromFileNotFound(err) if err != nil { t.Errorf("expected err to be nil but was %v", err) } _, err = getPathFromFileNotFound(nil) if err == nil { t.Errorf("expected err when calling getPathFromFileNotFound with nil err") } } </ins>