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
e45457b0
Commit
e45457b0
authored
Oct 06, 2017
by
Jesse Haka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add possibility to ignore volume label in dynamic provisioning
ignorelabel -> addlabel FIX tests small fix to test fixes according what was asked fix test fix test
parent
c1703a49
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
12 deletions
+19
-12
openstack.go
pkg/cloudprovider/providers/openstack/openstack.go
+2
-0
openstack_test.go
pkg/cloudprovider/providers/openstack/openstack_test.go
+5
-1
openstack_volumes.go
pkg/cloudprovider/providers/openstack/openstack_volumes.go
+5
-5
attacher_test.go
pkg/volume/cinder/attacher_test.go
+2
-2
cinder.go
pkg/volume/cinder/cinder.go
+1
-1
cinder_util.go
pkg/volume/cinder/cinder_util.go
+4
-3
No files found.
pkg/cloudprovider/providers/openstack/openstack.go
View file @
e45457b0
...
...
@@ -94,6 +94,7 @@ type LoadBalancerOpts struct {
type
BlockStorageOpts
struct
{
BSVersion
string
`gcfg:"bs-version"`
// overrides autodetection. v1 or v2. Defaults to auto
TrustDevicePath
bool
`gcfg:"trust-device-path"`
// See Issue #33128
IgnoreVolumeAZ
bool
`gcfg:"ignore-volume-az"`
}
type
RouterOpts
struct
{
...
...
@@ -187,6 +188,7 @@ func readConfig(config io.Reader) (Config, error) {
// Set default values for config params
cfg
.
BlockStorage
.
BSVersion
=
"auto"
cfg
.
BlockStorage
.
TrustDevicePath
=
false
cfg
.
BlockStorage
.
IgnoreVolumeAZ
=
false
cfg
.
Metadata
.
SearchOrder
=
fmt
.
Sprintf
(
"%s,%s"
,
configDriveID
,
metadataID
)
err
:=
gcfg
.
ReadInto
(
&
cfg
,
config
)
...
...
pkg/cloudprovider/providers/openstack/openstack_test.go
View file @
e45457b0
...
...
@@ -101,6 +101,7 @@ func TestReadConfig(t *testing.T) {
[BlockStorage]
bs-version = auto
trust-device-path = yes
ignore-volume-az = yes
[Metadata]
search-order = configDrive, metadataService
`
))
...
...
@@ -129,6 +130,9 @@ func TestReadConfig(t *testing.T) {
if
cfg
.
BlockStorage
.
BSVersion
!=
"auto"
{
t
.
Errorf
(
"incorrect bs.bs-version: %v"
,
cfg
.
BlockStorage
.
BSVersion
)
}
if
cfg
.
BlockStorage
.
IgnoreVolumeAZ
!=
true
{
t
.
Errorf
(
"incorrect bs.IgnoreVolumeAZ: %v"
,
cfg
.
BlockStorage
.
IgnoreVolumeAZ
)
}
if
cfg
.
Metadata
.
SearchOrder
!=
"configDrive, metadataService"
{
t
.
Errorf
(
"incorrect md.search-order: %v"
,
cfg
.
Metadata
.
SearchOrder
)
}
...
...
@@ -514,7 +518,7 @@ func TestVolumes(t *testing.T) {
tags
:=
map
[
string
]
string
{
"test"
:
"value"
,
}
vol
,
_
,
err
:=
os
.
CreateVolume
(
"kubernetes-test-volume-"
+
rand
.
String
(
10
),
1
,
""
,
""
,
&
tags
)
vol
,
_
,
_
,
err
:=
os
.
CreateVolume
(
"kubernetes-test-volume-"
+
rand
.
String
(
10
),
1
,
""
,
""
,
&
tags
)
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot create a new Cinder volume: %v"
,
err
)
}
...
...
pkg/cloudprovider/providers/openstack/openstack_volumes.go
View file @
e45457b0
...
...
@@ -299,11 +299,11 @@ func (os *OpenStack) getVolume(volumeID string) (Volume, error) {
}
// CreateVolume creates a volume of given size (in GiB)
func
(
os
*
OpenStack
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
error
)
{
func
(
os
*
OpenStack
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
bool
,
error
)
{
volumes
,
err
:=
os
.
volumeService
(
""
)
if
err
!=
nil
||
volumes
==
nil
{
glog
.
Errorf
(
"Unable to initialize cinder client for region: %s"
,
os
.
region
)
return
""
,
""
,
err
return
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
err
}
opts
:=
VolumeCreateOpts
{
...
...
@@ -320,11 +320,11 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to create a %d GB volume: %v"
,
size
,
err
)
return
""
,
""
,
err
return
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
err
}
glog
.
Infof
(
"Created volume %v in Availability Zone: %v
"
,
volumeID
,
v
olumeAZ
)
return
volumeID
,
volumeAZ
,
nil
glog
.
Infof
(
"Created volume %v in Availability Zone: %v
Ignore volume AZ: %v"
,
volumeID
,
volumeAZ
,
os
.
bsOpts
.
IgnoreV
olumeAZ
)
return
volumeID
,
volumeAZ
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
nil
}
// GetDevicePath returns the path of an attached block storage volume, specified by its id.
...
...
pkg/volume/cinder/attacher_test.go
View file @
e45457b0
...
...
@@ -571,8 +571,8 @@ func (testcase *testcase) ShouldTrustDevicePath() bool {
return
true
}
func
(
testcase
*
testcase
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
error
)
{
return
""
,
""
,
errors
.
New
(
"Not implemented"
)
func
(
testcase
*
testcase
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
bool
,
error
)
{
return
""
,
""
,
false
,
errors
.
New
(
"Not implemented"
)
}
func
(
testcase
*
testcase
)
GetDevicePath
(
volumeID
string
)
string
{
...
...
pkg/volume/cinder/cinder.go
View file @
e45457b0
...
...
@@ -46,7 +46,7 @@ type CinderProvider interface {
AttachDisk
(
instanceID
,
volumeID
string
)
(
string
,
error
)
DetachDisk
(
instanceID
,
volumeID
string
)
error
DeleteVolume
(
volumeID
string
)
error
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
error
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
bool
,
error
)
GetDevicePath
(
volumeID
string
)
string
InstanceID
()
(
string
,
error
)
GetAttachmentDiskPath
(
instanceID
,
volumeID
string
)
(
string
,
error
)
...
...
pkg/volume/cinder/cinder_util.go
View file @
e45457b0
...
...
@@ -204,7 +204,7 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
}
}
volumeID
,
volumeAZ
,
errr
:=
cloud
.
CreateVolume
(
name
,
volSizeGB
,
vtype
,
availability
,
c
.
options
.
CloudTags
)
volumeID
,
volumeAZ
,
IgnoreVolumeAZ
,
errr
:=
cloud
.
CreateVolume
(
name
,
volSizeGB
,
vtype
,
availability
,
c
.
options
.
CloudTags
)
if
errr
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Error creating cinder volume: %v"
,
errr
)
return
""
,
0
,
nil
,
""
,
errr
...
...
@@ -213,8 +213,9 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
// these are needed that pod is spawning to same AZ
volumeLabels
=
make
(
map
[
string
]
string
)
volumeLabels
[
kubeletapis
.
LabelZoneFailureDomain
]
=
volumeAZ
if
IgnoreVolumeAZ
==
false
{
volumeLabels
[
kubeletapis
.
LabelZoneFailureDomain
]
=
volumeAZ
}
return
volumeID
,
volSizeGB
,
volumeLabels
,
fstype
,
nil
}
...
...
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