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
1df1181b
Commit
1df1181b
authored
Jul 09, 2018
by
Seungcheol Ko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add region label to dynamic provisioned cinder PVs
parent
86b9a532
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
13 deletions
+19
-13
openstack_test.go
pkg/cloudprovider/providers/openstack/openstack_test.go
+6
-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
+5
-4
No files found.
pkg/cloudprovider/providers/openstack/openstack_test.go
View file @
1df1181b
...
@@ -104,6 +104,7 @@ func TestReadConfig(t *testing.T) {
...
@@ -104,6 +104,7 @@ func TestReadConfig(t *testing.T) {
auth-url = http://auth.url
auth-url = http://auth.url
user-id = user
user-id = user
tenant-name = demo
tenant-name = demo
region = RegionOne
[LoadBalancer]
[LoadBalancer]
create-monitor = yes
create-monitor = yes
monitor-delay = 1m
monitor-delay = 1m
...
@@ -136,6 +137,10 @@ func TestReadConfig(t *testing.T) {
...
@@ -136,6 +137,10 @@ func TestReadConfig(t *testing.T) {
t
.
Errorf
(
"incorrect tenant name: %s"
,
cfg
.
Global
.
TenantName
)
t
.
Errorf
(
"incorrect tenant name: %s"
,
cfg
.
Global
.
TenantName
)
}
}
if
cfg
.
Global
.
Region
!=
"RegionOne"
{
t
.
Errorf
(
"incorrect region: %s"
,
cfg
.
Global
.
Region
)
}
if
!
cfg
.
LoadBalancer
.
CreateMonitor
{
if
!
cfg
.
LoadBalancer
.
CreateMonitor
{
t
.
Errorf
(
"incorrect lb.createmonitor: %t"
,
cfg
.
LoadBalancer
.
CreateMonitor
)
t
.
Errorf
(
"incorrect lb.createmonitor: %t"
,
cfg
.
LoadBalancer
.
CreateMonitor
)
}
}
...
@@ -554,7 +559,7 @@ func TestVolumes(t *testing.T) {
...
@@ -554,7 +559,7 @@ func TestVolumes(t *testing.T) {
tags
:=
map
[
string
]
string
{
tags
:=
map
[
string
]
string
{
"test"
:
"value"
,
"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
{
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot create a new Cinder volume: %v"
,
err
)
t
.
Fatalf
(
"Cannot create a new Cinder volume: %v"
,
err
)
}
}
...
...
pkg/cloudprovider/providers/openstack/openstack_volumes.go
View file @
1df1181b
...
@@ -443,10 +443,10 @@ func (os *OpenStack) getVolume(volumeID string) (Volume, error) {
...
@@ -443,10 +443,10 @@ func (os *OpenStack) getVolume(volumeID string) (Volume, error) {
}
}
// CreateVolume creates a volume of given size (in GiB)
// 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
,
bool
,
error
)
{
func
(
os
*
OpenStack
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
string
,
bool
,
error
)
{
volumes
,
err
:=
os
.
volumeService
(
""
)
volumes
,
err
:=
os
.
volumeService
(
""
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
fmt
.
Errorf
(
"unable to initialize cinder client for region: %s, err: %v"
,
os
.
region
,
err
)
return
""
,
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
fmt
.
Errorf
(
"unable to initialize cinder client for region: %s, err: %v"
,
os
.
region
,
err
)
}
}
opts
:=
volumeCreateOpts
{
opts
:=
volumeCreateOpts
{
...
@@ -462,11 +462,11 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str
...
@@ -462,11 +462,11 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str
volumeID
,
volumeAZ
,
err
:=
volumes
.
createVolume
(
opts
)
volumeID
,
volumeAZ
,
err
:=
volumes
.
createVolume
(
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
fmt
.
Errorf
(
"failed to create a %d GB volume: %v"
,
size
,
err
)
return
""
,
""
,
""
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
fmt
.
Errorf
(
"failed to create a %d GB volume: %v"
,
size
,
err
)
}
}
glog
.
Infof
(
"Created volume %v in Availability Zone: %v
Ignore volume AZ: %v"
,
volumeID
,
volumeAZ
,
os
.
bsOpts
.
IgnoreVolumeAZ
)
glog
.
Infof
(
"Created volume %v in Availability Zone: %v
Region: %v Ignore volume AZ: %v"
,
volumeID
,
volumeAZ
,
os
.
region
,
os
.
bsOpts
.
IgnoreVolumeAZ
)
return
volumeID
,
volumeAZ
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
nil
return
volumeID
,
volumeAZ
,
os
.
region
,
os
.
bsOpts
.
IgnoreVolumeAZ
,
nil
}
}
// GetDevicePathBySerialID returns the path of an attached block storage volume, specified by its id.
// GetDevicePathBySerialID returns the path of an attached block storage volume, specified by its id.
...
...
pkg/volume/cinder/attacher_test.go
View file @
1df1181b
...
@@ -615,8 +615,8 @@ func (testcase *testcase) DiskIsAttachedByName(nodeName types.NodeName, volumeID
...
@@ -615,8 +615,8 @@ func (testcase *testcase) DiskIsAttachedByName(nodeName types.NodeName, volumeID
return
expected
.
isAttached
,
expected
.
instanceID
,
expected
.
ret
return
expected
.
isAttached
,
expected
.
instanceID
,
expected
.
ret
}
}
func
(
testcase
*
testcase
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
bool
,
error
)
{
func
(
testcase
*
testcase
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
string
,
bool
,
error
)
{
return
""
,
""
,
false
,
errors
.
New
(
"Not implemented"
)
return
""
,
""
,
""
,
false
,
errors
.
New
(
"Not implemented"
)
}
}
func
(
testcase
*
testcase
)
GetDevicePath
(
volumeID
string
)
string
{
func
(
testcase
*
testcase
)
GetDevicePath
(
volumeID
string
)
string
{
...
...
pkg/volume/cinder/cinder.go
View file @
1df1181b
...
@@ -53,7 +53,7 @@ type BlockStorageProvider interface {
...
@@ -53,7 +53,7 @@ type BlockStorageProvider interface {
AttachDisk
(
instanceID
,
volumeID
string
)
(
string
,
error
)
AttachDisk
(
instanceID
,
volumeID
string
)
(
string
,
error
)
DetachDisk
(
instanceID
,
volumeID
string
)
error
DetachDisk
(
instanceID
,
volumeID
string
)
error
DeleteVolume
(
volumeID
string
)
error
DeleteVolume
(
volumeID
string
)
error
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
bool
,
error
)
CreateVolume
(
name
string
,
size
int
,
vtype
,
availability
string
,
tags
*
map
[
string
]
string
)
(
string
,
string
,
string
,
bool
,
error
)
GetDevicePath
(
volumeID
string
)
string
GetDevicePath
(
volumeID
string
)
string
InstanceID
()
(
string
,
error
)
InstanceID
()
(
string
,
error
)
GetAttachmentDiskPath
(
instanceID
,
volumeID
string
)
(
string
,
error
)
GetAttachmentDiskPath
(
instanceID
,
volumeID
string
)
(
string
,
error
)
...
...
pkg/volume/cinder/cinder_util.go
View file @
1df1181b
...
@@ -208,10 +208,10 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
...
@@ -208,10 +208,10 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
}
}
}
}
volumeID
,
volumeAZ
,
IgnoreVolumeAZ
,
er
rr
:=
cloud
.
CreateVolume
(
name
,
volSizeGB
,
vtype
,
availability
,
c
.
options
.
CloudTags
)
volumeID
,
volumeAZ
,
volumeRegion
,
IgnoreVolumeAZ
,
e
rr
:=
cloud
.
CreateVolume
(
name
,
volSizeGB
,
vtype
,
availability
,
c
.
options
.
CloudTags
)
if
err
r
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Error creating cinder volume: %v"
,
err
r
)
glog
.
V
(
2
)
.
Infof
(
"Error creating cinder volume: %v"
,
err
)
return
""
,
0
,
nil
,
""
,
err
r
return
""
,
0
,
nil
,
""
,
err
}
}
glog
.
V
(
2
)
.
Infof
(
"Successfully created cinder volume %s"
,
volumeID
)
glog
.
V
(
2
)
.
Infof
(
"Successfully created cinder volume %s"
,
volumeID
)
...
@@ -219,6 +219,7 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
...
@@ -219,6 +219,7 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
volumeLabels
=
make
(
map
[
string
]
string
)
volumeLabels
=
make
(
map
[
string
]
string
)
if
IgnoreVolumeAZ
==
false
{
if
IgnoreVolumeAZ
==
false
{
volumeLabels
[
kubeletapis
.
LabelZoneFailureDomain
]
=
volumeAZ
volumeLabels
[
kubeletapis
.
LabelZoneFailureDomain
]
=
volumeAZ
volumeLabels
[
kubeletapis
.
LabelZoneRegion
]
=
volumeRegion
}
}
return
volumeID
,
volSizeGB
,
volumeLabels
,
fstype
,
nil
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