Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cbf52183
Unverified
Commit
cbf52183
authored
Jan 29, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73115 from alvaroaleman/71997-non-english-vsphere-pvc
Fix PV allocation on non-English vSphere
parents
819dcaaa
345049b6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
4 deletions
+93
-4
BUILD
pkg/cloudprovider/providers/vsphere/BUILD
+4
-0
vsphere_util.go
pkg/cloudprovider/providers/vsphere/vsphere_util.go
+17
-4
vsphere_util_test.go
pkg/cloudprovider/providers/vsphere/vsphere_util_test.go
+72
-0
No files found.
pkg/cloudprovider/providers/vsphere/BUILD
View file @
cbf52183
...
@@ -31,6 +31,8 @@ go_library(
...
@@ -31,6 +31,8 @@ go_library(
"//vendor/github.com/vmware/govmomi/vapi/tags:go_default_library",
"//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:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/mo:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/mo:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/soap:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/types:go_default_library",
"//vendor/gopkg.in/gcfg.v1:go_default_library",
"//vendor/gopkg.in/gcfg.v1:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
],
...
@@ -41,6 +43,7 @@ go_test(
...
@@ -41,6 +43,7 @@ go_test(
srcs = [
srcs = [
"credentialmanager_test.go",
"credentialmanager_test.go",
"vsphere_test.go",
"vsphere_test.go",
"vsphere_util_test.go",
],
],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
...
@@ -55,6 +58,7 @@ go_test(
...
@@ -55,6 +58,7 @@ go_test(
"//staging/src/k8s.io/client-go/informers:go_default_library",
"//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/client-go/kubernetes/fake:go_default_library",
"//staging/src/k8s.io/cloud-provider:go_default_library",
"//staging/src/k8s.io/cloud-provider:go_default_library",
"//vendor/github.com/vmware/govmomi:go_default_library",
"//vendor/github.com/vmware/govmomi/lookup/simulator:go_default_library",
"//vendor/github.com/vmware/govmomi/lookup/simulator:go_default_library",
"//vendor/github.com/vmware/govmomi/property:go_default_library",
"//vendor/github.com/vmware/govmomi/property:go_default_library",
"//vendor/github.com/vmware/govmomi/simulator:go_default_library",
"//vendor/github.com/vmware/govmomi/simulator:go_default_library",
...
...
pkg/cloudprovider/providers/vsphere/vsphere_util.go
View file @
cbf52183
...
@@ -23,12 +23,13 @@ import (
...
@@ -23,12 +23,13 @@ import (
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"regexp"
"strings"
"strings"
"time"
"time"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
"k8s.io/klog"
"k8s.io/klog"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
@@ -330,10 +331,9 @@ func getcanonicalVolumePath(ctx context.Context, dc *vclib.Datacenter, volumePat
...
@@ -330,10 +331,9 @@ func getcanonicalVolumePath(ctx context.Context, dc *vclib.Datacenter, volumePat
// Querying a non-existent dummy disk on the datastore folder.
// Querying a non-existent dummy disk on the datastore folder.
// It would fail and return an folder ID in the error message.
// It would fail and return an folder ID in the error message.
_
,
err
:=
dc
.
GetVirtualDiskPage83Data
(
ctx
,
dummyDiskVolPath
)
_
,
err
:=
dc
.
GetVirtualDiskPage83Data
(
ctx
,
dummyDiskVolPath
)
canonicalVolumePath
,
err
=
getPathFromFileNotFound
(
err
)
if
err
!=
nil
{
if
err
!=
nil
{
re
:=
regexp
.
MustCompile
(
"File (.*?) was not found"
)
return
""
,
fmt
.
Errorf
(
"failed to get path from dummy request: %v"
,
err
)
match
:=
re
.
FindStringSubmatch
(
err
.
Error
())
canonicalVolumePath
=
match
[
1
]
}
}
}
}
diskPath
:=
vclib
.
GetPathFromVMDiskPath
(
canonicalVolumePath
)
diskPath
:=
vclib
.
GetPathFromVMDiskPath
(
canonicalVolumePath
)
...
@@ -347,6 +347,19 @@ func getcanonicalVolumePath(ctx context.Context, dc *vclib.Datacenter, volumePat
...
@@ -347,6 +347,19 @@ func getcanonicalVolumePath(ctx context.Context, dc *vclib.Datacenter, volumePat
return
canonicalVolumePath
,
nil
return
canonicalVolumePath
,
nil
}
}
// 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
)
}
func
setdatastoreFolderIDMap
(
func
setdatastoreFolderIDMap
(
datastoreFolderIDMap
map
[
string
]
map
[
string
]
string
,
datastoreFolderIDMap
map
[
string
]
map
[
string
]
string
,
datastore
string
,
datastore
string
,
...
...
pkg/cloudprovider/providers/vsphere/vsphere_util_test.go
0 → 100644
View file @
cbf52183
/*
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"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment