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
73b46ff7
Commit
73b46ff7
authored
Feb 03, 2018
by
Davanum Srinivas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix golint for openstack and cinder packages
parent
c6e581ff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
220 additions
and
206 deletions
+220
-206
.golint_failures
hack/.golint_failures
+0
-2
metadata.go
pkg/cloudprovider/providers/openstack/metadata.go
+16
-15
metadata_test.go
pkg/cloudprovider/providers/openstack/metadata_test.go
+3
-3
openstack.go
pkg/cloudprovider/providers/openstack/openstack.go
+0
-0
openstack_client.go
pkg/cloudprovider/providers/openstack/openstack_client.go
+6
-0
openstack_instances.go
pkg/cloudprovider/providers/openstack/openstack_instances.go
+6
-3
openstack_loadbalancer.go
...oudprovider/providers/openstack/openstack_loadbalancer.go
+27
-26
openstack_metrics.go
pkg/cloudprovider/providers/openstack/openstack_metrics.go
+12
-12
openstack_routes.go
pkg/cloudprovider/providers/openstack/openstack_routes.go
+24
-19
openstack_routes_test.go
...loudprovider/providers/openstack/openstack_routes_test.go
+1
-1
openstack_test.go
pkg/cloudprovider/providers/openstack/openstack_test.go
+54
-57
openstack_volumes.go
pkg/cloudprovider/providers/openstack/openstack_volumes.go
+0
-0
attacher.go
pkg/volume/cinder/attacher.go
+10
-11
attacher_test.go
pkg/volume/cinder/attacher_test.go
+32
-32
cinder.go
pkg/volume/cinder/cinder.go
+16
-15
cinder_util.go
pkg/volume/cinder/cinder_util.go
+13
-10
No files found.
hack/.golint_failures
View file @
73b46ff7
...
...
@@ -88,7 +88,6 @@ pkg/cloudprovider/providers/aws
pkg/cloudprovider/providers/fake
pkg/cloudprovider/providers/gce
pkg/cloudprovider/providers/gce/cloud
pkg/cloudprovider/providers/openstack
pkg/cloudprovider/providers/ovirt
pkg/cloudprovider/providers/photon
pkg/cloudprovider/providers/vsphere
...
...
@@ -391,7 +390,6 @@ pkg/volume/aws_ebs
pkg/volume/azure_dd
pkg/volume/azure_file
pkg/volume/cephfs
pkg/volume/cinder
pkg/volume/configmap
pkg/volume/empty_dir
pkg/volume/fc
...
...
pkg/cloudprovider/providers/openstack/metadata.go
View file @
73b46ff7
...
...
@@ -33,12 +33,12 @@ import (
)
const
(
// metadataU
rl
Template allows building an OpenStack Metadata service URL.
// metadataU
RL
Template allows building an OpenStack Metadata service URL.
// It's a hardcoded IPv4 link-local address as documented in "OpenStack Cloud
// Administrator Guide", chapter Compute - Networking with nova-network.
//https://docs.openstack.org/nova/latest/admin/networking-nova.html#metadata-service
defaultMetadataVersion
=
"2012-08-10"
metadataU
rl
Template
=
"http://169.254.169.254/openstack/%s/meta_data.json"
metadataU
RL
Template
=
"http://169.254.169.254/openstack/%s/meta_data.json"
// metadataID is used as an identifier on the metadata search order configuration.
metadataID
=
"metadataService"
...
...
@@ -53,10 +53,10 @@ const (
configDriveID
=
"configDrive"
)
// ErrBadMetadata is used to indicate a problem parsing data from metadata server
var
ErrBadMetadata
=
errors
.
New
(
"invalid OpenStack metadata, got empty uuid"
)
// There are multiple device types. To keep it simple, we're using a single structure
// for all device metadata types.
// DeviceMetadata is a single/simplified data structure for all kinds of device metadata types.
type
DeviceMetadata
struct
{
Type
string
`json:"type"`
Bus
string
`json:"bus,omitempty"`
...
...
@@ -65,10 +65,11 @@ type DeviceMetadata struct {
// .. and other fields.
}
// Assumes the "2012-08-10" meta_data.json format.
//https://docs.openstack.org/nova/latest/user/config-drive.html
// Metadata has the information fetched from OpenStack metadata service or
// config drives. Assumes the "2012-08-10" meta_data.json format.
// See http://docs.openstack.org/user-guide/cli_config_drive.html
type
Metadata
struct
{
U
uid
string
`json:"uuid"`
U
UID
string
`json:"uuid"`
Hostname
string
`json:"hostname"`
AvailabilityZone
string
`json:"availability_zone"`
Devices
[]
DeviceMetadata
`json:"devices,omitempty"`
...
...
@@ -84,15 +85,15 @@ func parseMetadata(r io.Reader) (*Metadata, error) {
return
nil
,
err
}
if
metadata
.
U
uid
==
""
{
if
metadata
.
U
UID
==
""
{
return
nil
,
ErrBadMetadata
}
return
&
metadata
,
nil
}
func
getMetadataU
rl
(
metadataVersion
string
)
string
{
return
fmt
.
Sprintf
(
metadataU
rl
Template
,
metadataVersion
)
func
getMetadataU
RL
(
metadataVersion
string
)
string
{
return
fmt
.
Sprintf
(
metadataU
RL
Template
,
metadataVersion
)
}
func
getConfigDrivePath
(
metadataVersion
string
)
string
{
...
...
@@ -147,16 +148,16 @@ func getMetadataFromConfigDrive(metadataVersion string) (*Metadata, error) {
func
getMetadataFromMetadataService
(
metadataVersion
string
)
(
*
Metadata
,
error
)
{
// Try to get JSON from metadata server.
metadataU
rl
:=
getMetadataUrl
(
metadataVersion
)
glog
.
V
(
4
)
.
Infof
(
"Attempting to fetch metadata from %s"
,
metadataU
rl
)
resp
,
err
:=
http
.
Get
(
metadataU
rl
)
metadataU
RL
:=
getMetadataURL
(
metadataVersion
)
glog
.
V
(
4
)
.
Infof
(
"Attempting to fetch metadata from %s"
,
metadataU
RL
)
resp
,
err
:=
http
.
Get
(
metadataU
RL
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching %s: %v"
,
metadataU
rl
,
err
)
return
nil
,
fmt
.
Errorf
(
"error fetching %s: %v"
,
metadataU
RL
,
err
)
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
http
.
StatusOK
{
err
=
fmt
.
Errorf
(
"unexpected status code when reading metadata from %s: %s"
,
metadataU
rl
,
resp
.
Status
)
err
=
fmt
.
Errorf
(
"unexpected status code when reading metadata from %s: %s"
,
metadataU
RL
,
resp
.
Status
)
return
nil
,
err
}
...
...
pkg/cloudprovider/providers/openstack/metadata_test.go
View file @
73b46ff7
...
...
@@ -22,7 +22,7 @@ import (
)
var
FakeMetadata
=
Metadata
{
U
uid
:
"83679162-1378-4288-a2d4-70e13ec132aa"
,
U
UID
:
"83679162-1378-4288-a2d4-70e13ec132aa"
,
Hostname
:
"test"
,
AvailabilityZone
:
"nova"
,
}
...
...
@@ -85,8 +85,8 @@ func TestParseMetadata(t *testing.T) {
t
.
Errorf
(
"incorrect hostname: %s"
,
md
.
Hostname
)
}
if
md
.
U
uid
!=
"83679162-1378-4288-a2d4-70e13ec132aa"
{
t
.
Errorf
(
"incorrect uuid: %s"
,
md
.
U
uid
)
if
md
.
U
UID
!=
"83679162-1378-4288-a2d4-70e13ec132aa"
{
t
.
Errorf
(
"incorrect uuid: %s"
,
md
.
U
UID
)
}
if
md
.
AvailabilityZone
!=
"nova"
{
...
...
pkg/cloudprovider/providers/openstack/openstack.go
View file @
73b46ff7
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/openstack/openstack_client.go
View file @
73b46ff7
...
...
@@ -23,6 +23,7 @@ import (
"github.com/gophercloud/gophercloud/openstack"
)
// NewNetworkV2 creates a ServiceClient that may be used with the neutron v2 API
func
(
os
*
OpenStack
)
NewNetworkV2
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
network
,
err
:=
openstack
.
NewNetworkV2
(
os
.
provider
,
gophercloud
.
EndpointOpts
{
Region
:
os
.
region
,
...
...
@@ -33,6 +34,7 @@ func (os *OpenStack) NewNetworkV2() (*gophercloud.ServiceClient, error) {
return
network
,
nil
}
// NewComputeV2 creates a ServiceClient that may be used with the nova v2 API
func
(
os
*
OpenStack
)
NewComputeV2
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
compute
,
err
:=
openstack
.
NewComputeV2
(
os
.
provider
,
gophercloud
.
EndpointOpts
{
Region
:
os
.
region
,
...
...
@@ -43,6 +45,7 @@ func (os *OpenStack) NewComputeV2() (*gophercloud.ServiceClient, error) {
return
compute
,
nil
}
// NewBlockStorageV1 creates a ServiceClient that may be used with the Cinder v1 API
func
(
os
*
OpenStack
)
NewBlockStorageV1
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
storage
,
err
:=
openstack
.
NewBlockStorageV1
(
os
.
provider
,
gophercloud
.
EndpointOpts
{
Region
:
os
.
region
,
...
...
@@ -53,6 +56,7 @@ func (os *OpenStack) NewBlockStorageV1() (*gophercloud.ServiceClient, error) {
return
storage
,
nil
}
// NewBlockStorageV2 creates a ServiceClient that may be used with the Cinder v2 API
func
(
os
*
OpenStack
)
NewBlockStorageV2
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
storage
,
err
:=
openstack
.
NewBlockStorageV2
(
os
.
provider
,
gophercloud
.
EndpointOpts
{
Region
:
os
.
region
,
...
...
@@ -63,6 +67,7 @@ func (os *OpenStack) NewBlockStorageV2() (*gophercloud.ServiceClient, error) {
return
storage
,
nil
}
// NewBlockStorageV3 creates a ServiceClient that may be used with the Cinder v3 API
func
(
os
*
OpenStack
)
NewBlockStorageV3
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
storage
,
err
:=
openstack
.
NewBlockStorageV3
(
os
.
provider
,
gophercloud
.
EndpointOpts
{
Region
:
os
.
region
,
...
...
@@ -73,6 +78,7 @@ func (os *OpenStack) NewBlockStorageV3() (*gophercloud.ServiceClient, error) {
return
storage
,
nil
}
// NewLoadBalancerV2 creates a ServiceClient that may be used with the Neutron LBaaS v2 API
func
(
os
*
OpenStack
)
NewLoadBalancerV2
()
(
*
gophercloud
.
ServiceClient
,
error
)
{
var
lb
*
gophercloud
.
ServiceClient
var
err
error
...
...
pkg/cloudprovider/providers/openstack/openstack_instances.go
View file @
73b46ff7
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider"
)
// Instances encapsulates an implementation of Instances for OpenStack.
type
Instances
struct
{
compute
*
gophercloud
.
ServiceClient
opts
MetadataOpts
...
...
@@ -51,7 +52,7 @@ func (os *OpenStack) Instances() (cloudprovider.Instances, bool) {
},
true
}
//
Implementation of
Instances.CurrentNodeName
//
CurrentNodeName implements
Instances.CurrentNodeName
// Note this is *not* necessarily the same as hostname.
func
(
i
*
Instances
)
CurrentNodeName
(
hostname
string
)
(
types
.
NodeName
,
error
)
{
md
,
err
:=
getMetadata
(
i
.
opts
.
SearchOrder
)
...
...
@@ -61,10 +62,12 @@ func (i *Instances) CurrentNodeName(hostname string) (types.NodeName, error) {
return
types
.
NodeName
(
md
.
Hostname
),
nil
}
// AddSSHKeyToAllInstances is not implemented for OpenStack
func
(
i
*
Instances
)
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
{
return
cloudprovider
.
NotImplemented
}
// NodeAddresses implements Instances.NodeAddresses
func
(
i
*
Instances
)
NodeAddresses
(
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"NodeAddresses(%v) called"
,
name
)
...
...
@@ -212,9 +215,9 @@ func srvInstanceType(srv *servers.Server) (string, error) {
// See cloudprovider.GetInstanceProviderID and Instances.InstanceID.
func
instanceIDFromProviderID
(
providerID
string
)
(
instanceID
string
,
err
error
)
{
// If Instances.InstanceID or cloudprovider.GetInstanceProviderID is changed, the regexp should be changed too.
var
providerI
d
Regexp
=
regexp
.
MustCompile
(
`^`
+
ProviderName
+
`:///([^/]+)$`
)
var
providerI
D
Regexp
=
regexp
.
MustCompile
(
`^`
+
ProviderName
+
`:///([^/]+)$`
)
matches
:=
providerI
d
Regexp
.
FindStringSubmatch
(
providerID
)
matches
:=
providerI
D
Regexp
.
FindStringSubmatch
(
providerID
)
if
len
(
matches
)
!=
2
{
return
""
,
fmt
.
Errorf
(
"ProviderID
\"
%s
\"
didn't match expected format
\"
openstack:///InstanceID
\"
"
,
providerID
)
}
...
...
pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
View file @
73b46ff7
...
...
@@ -68,7 +68,7 @@ const (
activeStatus
=
"ACTIVE"
errorStatus
=
"ERROR"
ServiceAnnotationLoadBalancerFloatingNetworkI
d
=
"loadbalancer.openstack.org/floating-network-id"
ServiceAnnotationLoadBalancerFloatingNetworkI
D
=
"loadbalancer.openstack.org/floating-network-id"
// ServiceAnnotationLoadBalancerInternal is the annotation used on the service
// to indicate that we want an internal loadbalancer service.
...
...
@@ -76,7 +76,7 @@ const (
ServiceAnnotationLoadBalancerInternal
=
"service.beta.kubernetes.io/openstack-internal-load-balancer"
)
// L
oadBalancer implementation for LBaaS v2
// L
baasV2 is a LoadBalancer implementation for Neutron LBaaS v2 API
type
LbaasV2
struct
{
LoadBalancer
}
...
...
@@ -368,12 +368,10 @@ func waitLoadbalancerDeleted(client *gophercloud.ServiceClient, loadbalancerID s
if
err
!=
nil
{
if
err
==
ErrNotFound
{
return
true
,
nil
}
else
{
return
false
,
err
}
}
else
{
return
false
,
nil
return
false
,
err
}
return
false
,
nil
})
if
err
==
wait
.
ErrWaitTimeout
{
...
...
@@ -442,7 +440,7 @@ func (lbaas *LbaasV2) createLoadBalancer(service *v1.Service, name string, inter
createOpts
:=
loadbalancers
.
CreateOpts
{
Name
:
name
,
Description
:
fmt
.
Sprintf
(
"Kubernetes external service %s"
,
name
),
VipSubnetID
:
lbaas
.
opts
.
SubnetI
d
,
VipSubnetID
:
lbaas
.
opts
.
SubnetI
D
,
Provider
:
lbaas
.
opts
.
LBProvider
,
}
...
...
@@ -458,6 +456,7 @@ func (lbaas *LbaasV2) createLoadBalancer(service *v1.Service, name string, inter
return
loadbalancer
,
nil
}
// GetLoadBalancer returns whether the specified load balancer exists and its status
func
(
lbaas
*
LbaasV2
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
*
v1
.
LoadBalancerStatus
,
bool
,
error
)
{
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
loadbalancer
,
err
:=
getLoadbalancerByName
(
lbaas
.
lb
,
loadBalancerName
)
...
...
@@ -485,7 +484,7 @@ func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (
}
// The LB needs to be configured with instance addresses on the same
// subnet as the LB (aka opts.SubnetI
d
). Currently we're just
// subnet as the LB (aka opts.SubnetI
D
). Currently we're just
// guessing that the node's InternalIP is the right address - and that
// should be sufficient for all "normal" cases.
func
nodeAddressForLB
(
node
*
v1
.
Node
)
(
string
,
error
)
{
...
...
@@ -584,8 +583,8 @@ func isSecurityGroupNotFound(err error) bool {
return
false
}
// getFloatingNetworkI
d
ForLB returns a floating-network-id for cluster.
func
getFloatingNetworkI
d
ForLB
(
client
*
gophercloud
.
ServiceClient
)
(
string
,
error
)
{
// getFloatingNetworkI
D
ForLB returns a floating-network-id for cluster.
func
getFloatingNetworkI
D
ForLB
(
client
*
gophercloud
.
ServiceClient
)
(
string
,
error
)
{
var
floatingNetworkIds
[]
string
type
NetworkWithExternalExt
struct
{
...
...
@@ -635,6 +634,7 @@ func getFloatingNetworkIdForLB(client *gophercloud.ServiceClient) (string, error
// a list of regions (from config) and query/create loadbalancers in
// each region.
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one.
func
(
lbaas
*
LbaasV2
)
EnsureLoadBalancer
(
clusterName
string
,
apiService
*
v1
.
Service
,
nodes
[]
*
v1
.
Node
)
(
*
v1
.
LoadBalancerStatus
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v)"
,
clusterName
,
apiService
.
Namespace
,
apiService
.
Name
,
apiService
.
Spec
.
LoadBalancerIP
,
apiService
.
Spec
.
Ports
,
nodes
,
apiService
.
Annotations
)
...
...
@@ -642,16 +642,16 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
return
nil
,
fmt
.
Errorf
(
"there are no available nodes for LoadBalancer service %s/%s"
,
apiService
.
Namespace
,
apiService
.
Name
)
}
if
len
(
lbaas
.
opts
.
SubnetI
d
)
==
0
{
// Get SubnetI
d
automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetI
d
by one node.
if
len
(
lbaas
.
opts
.
SubnetI
D
)
==
0
{
// Get SubnetI
D
automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetI
D
by one node.
subnetID
,
err
:=
getSubnetIDForLB
(
lbaas
.
compute
,
*
nodes
[
0
])
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to find subnet-id for loadbalancer service %s/%s: %v"
,
apiService
.
Namespace
,
apiService
.
Name
,
err
)
return
nil
,
fmt
.
Errorf
(
"no subnet-id for service %s/%s : subnet-id not set in cloud provider config, "
+
"and failed to find subnet-id from OpenStack: %v"
,
apiService
.
Namespace
,
apiService
.
Name
,
err
)
}
lbaas
.
opts
.
SubnetI
d
=
subnetID
lbaas
.
opts
.
SubnetI
D
=
subnetID
}
ports
:=
apiService
.
Spec
.
Ports
...
...
@@ -659,10 +659,10 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
return
nil
,
fmt
.
Errorf
(
"no ports provided to openstack load balancer"
)
}
floatingPool
:=
getStringFromServiceAnnotation
(
apiService
,
ServiceAnnotationLoadBalancerFloatingNetworkI
d
,
lbaas
.
opts
.
FloatingNetworkId
)
floatingPool
:=
getStringFromServiceAnnotation
(
apiService
,
ServiceAnnotationLoadBalancerFloatingNetworkI
D
,
lbaas
.
opts
.
FloatingNetworkID
)
if
len
(
floatingPool
)
==
0
{
var
err
error
floatingPool
,
err
=
getFloatingNetworkI
d
ForLB
(
lbaas
.
network
)
floatingPool
,
err
=
getFloatingNetworkI
D
ForLB
(
lbaas
.
network
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to find floating-network-id for loadbalancer service %s/%s: %v"
,
apiService
.
Namespace
,
apiService
.
Name
,
err
)
}
...
...
@@ -816,7 +816,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
_
,
err
:=
v2pools
.
CreateMember
(
lbaas
.
lb
,
pool
.
ID
,
v2pools
.
CreateMemberOpts
{
ProtocolPort
:
int
(
port
.
NodePort
),
Address
:
addr
,
SubnetID
:
lbaas
.
opts
.
SubnetI
d
,
SubnetID
:
lbaas
.
opts
.
SubnetI
D
,
})
.
Extract
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error creating LB pool member for node: %s, %v"
,
node
.
Name
,
err
)
...
...
@@ -1111,8 +1111,8 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser
// update loadbalancer vip port
if
!
found
{
port
.
SecurityGroups
=
append
(
port
.
SecurityGroups
,
lbSecGroup
.
ID
)
update
_o
pts
:=
neutronports
.
UpdateOpts
{
SecurityGroups
:
&
port
.
SecurityGroups
}
res
:=
neutronports
.
Update
(
lbaas
.
network
,
portID
,
update
_o
pts
)
update
O
pts
:=
neutronports
.
UpdateOpts
{
SecurityGroups
:
&
port
.
SecurityGroups
}
res
:=
neutronports
.
Update
(
lbaas
.
network
,
portID
,
update
O
pts
)
if
res
.
Err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"Error occured updating port %s for loadbalancer service %s/%s: %v"
,
portID
,
apiService
.
Namespace
,
apiService
.
Name
,
res
.
Err
)
return
fmt
.
Errorf
(
msg
)
...
...
@@ -1152,20 +1152,21 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser
return
nil
}
// UpdateLoadBalancer updates hosts under the specified load balancer.
func
(
lbaas
*
LbaasV2
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodes
[]
*
v1
.
Node
)
error
{
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
glog
.
V
(
4
)
.
Infof
(
"UpdateLoadBalancer(%v, %v, %v)"
,
clusterName
,
loadBalancerName
,
nodes
)
if
len
(
lbaas
.
opts
.
SubnetI
d
)
==
0
&&
len
(
nodes
)
>
0
{
// Get SubnetI
d
automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetI
d
by one node.
if
len
(
lbaas
.
opts
.
SubnetI
D
)
==
0
&&
len
(
nodes
)
>
0
{
// Get SubnetI
D
automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetI
D
by one node.
subnetID
,
err
:=
getSubnetIDForLB
(
lbaas
.
compute
,
*
nodes
[
0
])
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to find subnet-id for loadbalancer service %s/%s: %v"
,
service
.
Namespace
,
service
.
Name
,
err
)
return
fmt
.
Errorf
(
"no subnet-id for service %s/%s : subnet-id not set in cloud provider config, "
+
"and failed to find subnet-id from OpenStack: %v"
,
service
.
Namespace
,
service
.
Name
,
err
)
}
lbaas
.
opts
.
SubnetI
d
=
subnetID
lbaas
.
opts
.
SubnetI
D
=
subnetID
}
ports
:=
service
.
Spec
.
Ports
...
...
@@ -1254,7 +1255,7 @@ func (lbaas *LbaasV2) UpdateLoadBalancer(clusterName string, service *v1.Service
_
,
err
:=
v2pools
.
CreateMember
(
lbaas
.
lb
,
pool
.
ID
,
v2pools
.
CreateMemberOpts
{
Address
:
addr
,
ProtocolPort
:
int
(
port
.
NodePort
),
SubnetID
:
lbaas
.
opts
.
SubnetI
d
,
SubnetID
:
lbaas
.
opts
.
SubnetI
D
,
})
.
Extract
()
if
err
!=
nil
{
return
err
...
...
@@ -1372,6 +1373,7 @@ func (lbaas *LbaasV2) updateSecurityGroup(clusterName string, apiService *v1.Ser
return
nil
}
// EnsureLoadBalancerDeleted deletes the specified load balancer
func
(
lbaas
*
LbaasV2
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancerDeleted(%v, %v)"
,
clusterName
,
loadBalancerName
)
...
...
@@ -1512,9 +1514,8 @@ func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *v1
if
isSecurityGroupNotFound
(
err
)
{
// It is OK when the security group has been deleted by others.
return
nil
}
else
{
return
fmt
.
Errorf
(
"Error occurred finding security group: %s: %v"
,
lbSecGroupName
,
err
)
}
return
fmt
.
Errorf
(
"Error occurred finding security group: %s: %v"
,
lbSecGroupName
,
err
)
}
lbSecGroup
:=
groups
.
Delete
(
lbaas
.
network
,
lbSecGroupID
)
...
...
pkg/cloudprovider/providers/openstack/openstack_metrics.go
View file @
73b46ff7
...
...
@@ -19,32 +19,32 @@ package openstack
import
"github.com/prometheus/client_golang/prometheus"
const
(
O
penstackSubsystem
=
"openstack"
O
penstackOperationKey
=
"cloudprovider_openstack_api_request_duration_seconds"
O
penstackOperationErrorKey
=
"cloudprovider_openstack_api_request_errors"
o
penstackSubsystem
=
"openstack"
o
penstackOperationKey
=
"cloudprovider_openstack_api_request_duration_seconds"
o
penstackOperationErrorKey
=
"cloudprovider_openstack_api_request_errors"
)
var
(
O
penstackOperationsLatency
=
prometheus
.
NewHistogramVec
(
o
penstackOperationsLatency
=
prometheus
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Subsystem
:
O
penstackSubsystem
,
Name
:
O
penstackOperationKey
,
Subsystem
:
o
penstackSubsystem
,
Name
:
o
penstackOperationKey
,
Help
:
"Latency of openstack api call"
,
},
[]
string
{
"request"
},
)
OpenstackApi
RequestErrors
=
prometheus
.
NewCounterVec
(
openstackAPI
RequestErrors
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
O
penstackSubsystem
,
Name
:
O
penstackOperationErrorKey
,
Subsystem
:
o
penstackSubsystem
,
Name
:
o
penstackOperationErrorKey
,
Help
:
"Cumulative number of openstack Api call errors"
,
},
[]
string
{
"request"
},
)
)
func
R
egisterMetrics
()
{
prometheus
.
MustRegister
(
O
penstackOperationsLatency
)
prometheus
.
MustRegister
(
OpenstackApi
RequestErrors
)
func
r
egisterMetrics
()
{
prometheus
.
MustRegister
(
o
penstackOperationsLatency
)
prometheus
.
MustRegister
(
openstackAPI
RequestErrors
)
}
pkg/cloudprovider/providers/openstack/openstack_routes.go
View file @
73b46ff7
...
...
@@ -29,17 +29,19 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider"
)
var
ErrNoRouterId
=
errors
.
New
(
"router-id not set in cloud provider config"
)
var
errNoRouterID
=
errors
.
New
(
"router-id not set in cloud provider config"
)
// Routes implements the cloudprovider.Routes for OpenStack clouds
type
Routes
struct
{
compute
*
gophercloud
.
ServiceClient
network
*
gophercloud
.
ServiceClient
opts
RouterOpts
}
// NewRoutes creates a new instance of Routes
func
NewRoutes
(
compute
*
gophercloud
.
ServiceClient
,
network
*
gophercloud
.
ServiceClient
,
opts
RouterOpts
)
(
cloudprovider
.
Routes
,
error
)
{
if
opts
.
RouterI
d
==
""
{
return
nil
,
ErrNoRouterId
if
opts
.
RouterI
D
==
""
{
return
nil
,
errNoRouterID
}
return
&
Routes
{
...
...
@@ -49,6 +51,7 @@ func NewRoutes(compute *gophercloud.ServiceClient, network *gophercloud.ServiceC
},
nil
}
// ListRoutes lists all managed routes that belong to the specified clusterName
func
(
r
*
Routes
)
ListRoutes
(
clusterName
string
)
([]
*
cloudprovider
.
Route
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"ListRoutes(%v)"
,
clusterName
)
...
...
@@ -70,7 +73,7 @@ func (r *Routes) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
return
nil
,
err
}
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
d
)
.
Extract
()
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
D
)
.
Extract
()
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -136,10 +139,11 @@ func updateAllowedAddressPairs(network *gophercloud.ServiceClient, port *neutron
return
unwinder
,
nil
}
// CreateRoute creates the described managed route
func
(
r
*
Routes
)
CreateRoute
(
clusterName
string
,
nameHint
string
,
route
*
cloudprovider
.
Route
)
error
{
glog
.
V
(
4
)
.
Infof
(
"CreateRoute(%v, %v, %v)"
,
clusterName
,
nameHint
,
route
)
onFailure
:=
N
ewCaller
()
onFailure
:=
n
ewCaller
()
addr
,
err
:=
getAddressByName
(
r
.
compute
,
route
.
TargetNode
)
if
err
!=
nil
{
...
...
@@ -148,7 +152,7 @@ func (r *Routes) CreateRoute(clusterName string, nameHint string, route *cloudpr
glog
.
V
(
4
)
.
Infof
(
"Using nexthop %v for node %v"
,
addr
,
route
.
TargetNode
)
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
d
)
.
Extract
()
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
D
)
.
Extract
()
if
err
!=
nil
{
return
err
}
...
...
@@ -171,7 +175,7 @@ func (r *Routes) CreateRoute(clusterName string, nameHint string, route *cloudpr
if
err
!=
nil
{
return
err
}
defer
onFailure
.
C
all
(
unwind
)
defer
onFailure
.
c
all
(
unwind
)
// get the port of addr on target node.
portID
,
err
:=
getPortIDByIP
(
r
.
compute
,
route
.
TargetNode
,
addr
)
...
...
@@ -200,25 +204,26 @@ func (r *Routes) CreateRoute(clusterName string, nameHint string, route *cloudpr
if
err
!=
nil
{
return
err
}
defer
onFailure
.
C
all
(
unwind
)
defer
onFailure
.
c
all
(
unwind
)
}
glog
.
V
(
4
)
.
Infof
(
"Route created: %v"
,
route
)
onFailure
.
D
isarm
()
onFailure
.
d
isarm
()
return
nil
}
// DeleteRoute deletes the specified managed route
func
(
r
*
Routes
)
DeleteRoute
(
clusterName
string
,
route
*
cloudprovider
.
Route
)
error
{
glog
.
V
(
4
)
.
Infof
(
"DeleteRoute(%v, %v)"
,
clusterName
,
route
)
onFailure
:=
N
ewCaller
()
onFailure
:=
n
ewCaller
()
addr
,
err
:=
getAddressByName
(
r
.
compute
,
route
.
TargetNode
)
if
err
!=
nil
{
return
err
}
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
d
)
.
Extract
()
router
,
err
:=
routers
.
Get
(
r
.
network
,
r
.
opts
.
RouterI
D
)
.
Extract
()
if
err
!=
nil
{
return
err
}
...
...
@@ -245,7 +250,7 @@ func (r *Routes) DeleteRoute(clusterName string, route *cloudprovider.Route) err
if
err
!=
nil
{
return
err
}
defer
onFailure
.
C
all
(
unwind
)
defer
onFailure
.
c
all
(
unwind
)
// get the port of addr on target node.
portID
,
err
:=
getPortIDByIP
(
r
.
compute
,
route
.
TargetNode
,
addr
)
...
...
@@ -257,9 +262,9 @@ func (r *Routes) DeleteRoute(clusterName string, route *cloudprovider.Route) err
return
err
}
addr
_p
airs
:=
port
.
AllowedAddressPairs
addr
P
airs
:=
port
.
AllowedAddressPairs
index
=
-
1
for
i
,
item
:=
range
addr
_p
airs
{
for
i
,
item
:=
range
addr
P
airs
{
if
item
.
IPAddress
==
route
.
DestinationCIDR
{
index
=
i
break
...
...
@@ -268,18 +273,18 @@ func (r *Routes) DeleteRoute(clusterName string, route *cloudprovider.Route) err
if
index
!=
-
1
{
// Delete element `index`
addr
_pairs
[
index
]
=
addr_pairs
[
len
(
addr_p
airs
)
-
1
]
addr
_pairs
=
addr_pairs
[
:
len
(
addr_p
airs
)
-
1
]
addr
Pairs
[
index
]
=
addrPairs
[
len
(
addrP
airs
)
-
1
]
addr
Pairs
=
addrPairs
[
:
len
(
addrP
airs
)
-
1
]
unwind
,
err
:=
updateAllowedAddressPairs
(
r
.
network
,
port
,
addr
_p
airs
)
unwind
,
err
:=
updateAllowedAddressPairs
(
r
.
network
,
port
,
addr
P
airs
)
if
err
!=
nil
{
return
err
}
defer
onFailure
.
C
all
(
unwind
)
defer
onFailure
.
c
all
(
unwind
)
}
glog
.
V
(
4
)
.
Infof
(
"Route deleted: %v"
,
route
)
onFailure
.
D
isarm
()
onFailure
.
d
isarm
()
return
nil
}
...
...
pkg/cloudprovider/providers/openstack/openstack_routes_test.go
View file @
73b46ff7
...
...
@@ -40,7 +40,7 @@ func TestRoutes(t *testing.T) {
}
// Pick the first router and server to try a test with
os
.
routeOpts
.
RouterI
d
=
getRouters
(
os
)[
0
]
.
ID
os
.
routeOpts
.
RouterI
D
=
getRouters
(
os
)[
0
]
.
ID
servername
:=
getServers
(
os
)[
0
]
.
Name
r
,
ok
:=
os
.
Routes
()
...
...
pkg/cloudprovider/providers/openstack/openstack_test.go
View file @
73b46ff7
...
...
@@ -37,9 +37,7 @@ import (
)
const
(
volumeAvailableStatus
=
"available"
volumeInUseStatus
=
"in-use"
testClusterName
=
"testCluster"
testClusterName
=
"testCluster"
volumeStatusTimeoutSeconds
=
30
// volumeStatus* is configuration of exponential backoff for
...
...
@@ -68,9 +66,8 @@ func WaitForVolumeStatus(t *testing.T, os *OpenStack, volumeName string, status
status
,
volumeStatusTimeoutSeconds
)
return
true
,
nil
}
else
{
return
false
,
nil
}
return
false
,
nil
})
if
err
==
wait
.
ErrWaitTimeout
{
t
.
Logf
(
"Volume (%s) status did not change to %s after %v seconds
\n
"
,
...
...
@@ -116,12 +113,12 @@ func TestReadConfig(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"Should succeed when a valid config is provided: %s"
,
err
)
}
if
cfg
.
Global
.
AuthU
rl
!=
"http://auth.url"
{
t
.
Errorf
(
"incorrect authurl: %s"
,
cfg
.
Global
.
AuthU
rl
)
if
cfg
.
Global
.
AuthU
RL
!=
"http://auth.url"
{
t
.
Errorf
(
"incorrect authurl: %s"
,
cfg
.
Global
.
AuthU
RL
)
}
if
cfg
.
Global
.
UserI
d
!=
"user"
{
t
.
Errorf
(
"incorrect userid: %s"
,
cfg
.
Global
.
UserI
d
)
if
cfg
.
Global
.
UserI
D
!=
"user"
{
t
.
Errorf
(
"incorrect userid: %s"
,
cfg
.
Global
.
UserI
D
)
}
if
cfg
.
Global
.
Password
!=
"mypass"
{
...
...
@@ -163,10 +160,10 @@ func TestToAuthOptions(t *testing.T) {
cfg
:=
Config
{}
cfg
.
Global
.
Username
=
"user"
cfg
.
Global
.
Password
=
"pass"
cfg
.
Global
.
DomainI
d
=
"2a73b8f597c04551a0fdc8e95544be8a"
cfg
.
Global
.
DomainI
D
=
"2a73b8f597c04551a0fdc8e95544be8a"
cfg
.
Global
.
DomainName
=
"local"
cfg
.
Global
.
AuthU
rl
=
"http://auth.url"
cfg
.
Global
.
UserI
d
=
"user"
cfg
.
Global
.
AuthU
RL
=
"http://auth.url"
cfg
.
Global
.
UserI
D
=
"user"
ao
:=
cfg
.
toAuthOptions
()
...
...
@@ -179,20 +176,20 @@ func TestToAuthOptions(t *testing.T) {
if
ao
.
Password
!=
cfg
.
Global
.
Password
{
t
.
Errorf
(
"Password %s != %s"
,
ao
.
Password
,
cfg
.
Global
.
Password
)
}
if
ao
.
DomainID
!=
cfg
.
Global
.
DomainI
d
{
t
.
Errorf
(
"DomainID %s != %s"
,
ao
.
DomainID
,
cfg
.
Global
.
DomainI
d
)
if
ao
.
DomainID
!=
cfg
.
Global
.
DomainI
D
{
t
.
Errorf
(
"DomainID %s != %s"
,
ao
.
DomainID
,
cfg
.
Global
.
DomainI
D
)
}
if
ao
.
IdentityEndpoint
!=
cfg
.
Global
.
AuthU
rl
{
t
.
Errorf
(
"IdentityEndpoint %s != %s"
,
ao
.
IdentityEndpoint
,
cfg
.
Global
.
AuthU
rl
)
if
ao
.
IdentityEndpoint
!=
cfg
.
Global
.
AuthU
RL
{
t
.
Errorf
(
"IdentityEndpoint %s != %s"
,
ao
.
IdentityEndpoint
,
cfg
.
Global
.
AuthU
RL
)
}
if
ao
.
UserID
!=
cfg
.
Global
.
UserI
d
{
t
.
Errorf
(
"UserID %s != %s"
,
ao
.
UserID
,
cfg
.
Global
.
UserI
d
)
if
ao
.
UserID
!=
cfg
.
Global
.
UserI
D
{
t
.
Errorf
(
"UserID %s != %s"
,
ao
.
UserID
,
cfg
.
Global
.
UserI
D
)
}
if
ao
.
DomainName
!=
cfg
.
Global
.
DomainName
{
t
.
Errorf
(
"DomainName %s != %s"
,
ao
.
DomainName
,
cfg
.
Global
.
DomainName
)
}
if
ao
.
TenantID
!=
cfg
.
Global
.
TenantI
d
{
t
.
Errorf
(
"TenantID %s != %s"
,
ao
.
TenantID
,
cfg
.
Global
.
TenantI
d
)
if
ao
.
TenantID
!=
cfg
.
Global
.
TenantI
D
{
t
.
Errorf
(
"TenantID %s != %s"
,
ao
.
TenantID
,
cfg
.
Global
.
TenantI
D
)
}
}
...
...
@@ -210,8 +207,8 @@ func TestCheckOpenStackOpts(t *testing.T) {
provider
:
nil
,
lbOpts
:
LoadBalancerOpts
{
LBVersion
:
"v2"
,
SubnetI
d
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
d
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
SubnetI
D
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
D
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
LBMethod
:
"ROUND_ROBIN"
,
LBProvider
:
"haproxy"
,
CreateMonitor
:
true
,
...
...
@@ -232,7 +229,7 @@ func TestCheckOpenStackOpts(t *testing.T) {
provider
:
nil
,
lbOpts
:
LoadBalancerOpts
{
LBVersion
:
"v2"
,
FloatingNetworkI
d
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
FloatingNetworkI
D
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
LBMethod
:
"ROUND_ROBIN"
,
CreateMonitor
:
true
,
MonitorDelay
:
delay
,
...
...
@@ -252,8 +249,8 @@ func TestCheckOpenStackOpts(t *testing.T) {
provider
:
nil
,
lbOpts
:
LoadBalancerOpts
{
LBVersion
:
"v2"
,
SubnetI
d
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
d
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
SubnetI
D
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
D
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
LBMethod
:
"ROUND_ROBIN"
,
CreateMonitor
:
true
,
MonitorTimeout
:
timeout
,
...
...
@@ -303,8 +300,8 @@ func TestCheckOpenStackOpts(t *testing.T) {
provider
:
nil
,
lbOpts
:
LoadBalancerOpts
{
LBVersion
:
"v2"
,
SubnetI
d
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
d
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
SubnetI
D
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
D
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
LBMethod
:
"ROUND_ROBIN"
,
CreateMonitor
:
true
,
MonitorDelay
:
delay
,
...
...
@@ -323,8 +320,8 @@ func TestCheckOpenStackOpts(t *testing.T) {
provider
:
nil
,
lbOpts
:
LoadBalancerOpts
{
LBVersion
:
"v2"
,
SubnetI
d
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
d
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
SubnetI
D
:
"6261548e-ffde-4bc7-bd22-59c83578c5ef"
,
FloatingNetworkI
D
:
"38b8b5f9-64dc-4424-bf86-679595714786"
,
LBMethod
:
"ROUND_ROBIN"
,
CreateMonitor
:
true
,
MonitorDelay
:
delay
,
...
...
@@ -356,39 +353,39 @@ func TestCaller(t *testing.T) {
called
:=
false
myFunc
:=
func
()
{
called
=
true
}
c
:=
N
ewCaller
()
c
.
C
all
(
myFunc
)
c
:=
n
ewCaller
()
c
.
c
all
(
myFunc
)
if
!
called
{
t
.
Errorf
(
"
C
aller failed to call function in default case"
)
t
.
Errorf
(
"
c
aller failed to call function in default case"
)
}
c
.
D
isarm
()
c
.
d
isarm
()
called
=
false
c
.
C
all
(
myFunc
)
c
.
c
all
(
myFunc
)
if
called
{
t
.
Error
(
"
C
aller still called function when disarmed"
)
t
.
Error
(
"
c
aller still called function when disarmed"
)
}
// Confirm the "usual" deferred
C
aller pattern works as expected
// Confirm the "usual" deferred
c
aller pattern works as expected
called
=
false
success
_c
ase
:=
func
()
{
c
:=
N
ewCaller
()
defer
c
.
C
all
(
func
()
{
called
=
true
})
c
.
D
isarm
()
success
C
ase
:=
func
()
{
c
:=
n
ewCaller
()
defer
c
.
c
all
(
func
()
{
called
=
true
})
c
.
d
isarm
()
}
if
success
_c
ase
();
called
{
if
success
C
ase
();
called
{
t
.
Error
(
"Deferred success case still invoked unwind"
)
}
called
=
false
failure
_c
ase
:=
func
()
{
c
:=
N
ewCaller
()
defer
c
.
C
all
(
func
()
{
called
=
true
})
failure
C
ase
:=
func
()
{
c
:=
n
ewCaller
()
defer
c
.
c
all
(
func
()
{
called
=
true
})
}
if
failure
_c
ase
();
!
called
{
if
failure
C
ase
();
!
called
{
t
.
Error
(
"Deferred failure case failed to invoke unwind"
)
}
}
...
...
@@ -563,15 +560,15 @@ func TestVolumes(t *testing.T) {
if
err
!=
nil
{
t
.
Logf
(
"Cannot find instance id: %v - perhaps you are running this test outside a VM launched by OpenStack"
,
err
)
}
else
{
diskI
d
,
err
:=
os
.
AttachDisk
(
id
,
vol
)
diskI
D
,
err
:=
os
.
AttachDisk
(
id
,
vol
)
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot AttachDisk Cinder volume %s: %v"
,
vol
,
err
)
}
t
.
Logf
(
"Volume (%s) attached, disk ID: %s
\n
"
,
vol
,
diskI
d
)
t
.
Logf
(
"Volume (%s) attached, disk ID: %s
\n
"
,
vol
,
diskI
D
)
WaitForVolumeStatus
(
t
,
os
,
vol
,
volumeInUseStatus
)
devicePath
:=
os
.
GetDevicePath
(
diskI
d
)
devicePath
:=
os
.
GetDevicePath
(
diskI
D
)
if
diskPathRegexp
.
FindString
(
devicePath
)
==
""
{
t
.
Fatalf
(
"GetDevicePath returned and unexpected path for Cinder volume %s, returned %s"
,
vol
,
devicePath
)
}
...
...
@@ -654,10 +651,10 @@ func TestToAuth3Options(t *testing.T) {
cfg
:=
Config
{}
cfg
.
Global
.
Username
=
"user"
cfg
.
Global
.
Password
=
"pass"
cfg
.
Global
.
DomainI
d
=
"2a73b8f597c04551a0fdc8e95544be8a"
cfg
.
Global
.
DomainI
D
=
"2a73b8f597c04551a0fdc8e95544be8a"
cfg
.
Global
.
DomainName
=
"local"
cfg
.
Global
.
AuthU
rl
=
"http://auth.url"
cfg
.
Global
.
UserI
d
=
"user"
cfg
.
Global
.
AuthU
RL
=
"http://auth.url"
cfg
.
Global
.
UserI
D
=
"user"
ao
:=
cfg
.
toAuth3Options
()
...
...
@@ -670,14 +667,14 @@ func TestToAuth3Options(t *testing.T) {
if
ao
.
Password
!=
cfg
.
Global
.
Password
{
t
.
Errorf
(
"Password %s != %s"
,
ao
.
Password
,
cfg
.
Global
.
Password
)
}
if
ao
.
DomainID
!=
cfg
.
Global
.
DomainI
d
{
t
.
Errorf
(
"DomainID %s != %s"
,
ao
.
DomainID
,
cfg
.
Global
.
DomainI
d
)
if
ao
.
DomainID
!=
cfg
.
Global
.
DomainI
D
{
t
.
Errorf
(
"DomainID %s != %s"
,
ao
.
DomainID
,
cfg
.
Global
.
DomainI
D
)
}
if
ao
.
IdentityEndpoint
!=
cfg
.
Global
.
AuthU
rl
{
t
.
Errorf
(
"IdentityEndpoint %s != %s"
,
ao
.
IdentityEndpoint
,
cfg
.
Global
.
AuthU
rl
)
if
ao
.
IdentityEndpoint
!=
cfg
.
Global
.
AuthU
RL
{
t
.
Errorf
(
"IdentityEndpoint %s != %s"
,
ao
.
IdentityEndpoint
,
cfg
.
Global
.
AuthU
RL
)
}
if
ao
.
UserID
!=
cfg
.
Global
.
UserI
d
{
t
.
Errorf
(
"UserID %s != %s"
,
ao
.
UserID
,
cfg
.
Global
.
UserI
d
)
if
ao
.
UserID
!=
cfg
.
Global
.
UserI
D
{
t
.
Errorf
(
"UserID %s != %s"
,
ao
.
UserID
,
cfg
.
Global
.
UserI
D
)
}
if
ao
.
DomainName
!=
cfg
.
Global
.
DomainName
{
t
.
Errorf
(
"DomainName %s != %s"
,
ao
.
DomainName
,
cfg
.
Global
.
DomainName
)
...
...
pkg/cloudprovider/providers/openstack/openstack_volumes.go
View file @
73b46ff7
This diff is collapsed.
Click to expand it.
pkg/volume/cinder/attacher.go
View file @
73b46ff7
...
...
@@ -35,7 +35,7 @@ import (
type
cinderDiskAttacher
struct
{
host
volume
.
VolumeHost
cinderProvider
Cinder
Provider
cinderProvider
BlockStorage
Provider
}
var
_
volume
.
Attacher
=
&
cinderDiskAttacher
{}
...
...
@@ -215,7 +215,7 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
volumeID
:=
volumeSource
.
VolumeID
if
devicePath
==
""
{
return
""
,
fmt
.
Errorf
(
"WaitForAttach failed for Cinder disk %q: devicePath is empty
.
"
,
volumeID
)
return
""
,
fmt
.
Errorf
(
"WaitForAttach failed for Cinder disk %q: devicePath is empty"
,
volumeID
)
}
ticker
:=
time
.
NewTicker
(
probeVolumeInitDelay
)
...
...
@@ -237,16 +237,15 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
if
exists
&&
err
==
nil
{
glog
.
Infof
(
"Successfully found attached Cinder disk %q at %v."
,
volumeID
,
devicePath
)
return
devicePath
,
nil
}
else
{
// Log an error, and continue checking periodically
glog
.
Errorf
(
"Error: could not find attached Cinder disk %q (path: %q): %v"
,
volumeID
,
devicePath
,
err
)
// Using exponential backoff instead of linear
ticker
.
Stop
()
duration
=
time
.
Duration
(
float64
(
duration
)
*
probeVolumeFactor
)
ticker
=
time
.
NewTicker
(
duration
)
}
// Log an error, and continue checking periodically
glog
.
Errorf
(
"Error: could not find attached Cinder disk %q (path: %q): %v"
,
volumeID
,
devicePath
,
err
)
// Using exponential backoff instead of linear
ticker
.
Stop
()
duration
=
time
.
Duration
(
float64
(
duration
)
*
probeVolumeFactor
)
ticker
=
time
.
NewTicker
(
duration
)
case
<-
timer
.
C
:
return
""
,
fmt
.
Errorf
(
"
Could not find attached Cinder disk %q. Timeout waiting for mount paths to be created.
"
,
volumeID
)
return
""
,
fmt
.
Errorf
(
"
could not find attached Cinder disk %q. Timeout waiting for mount paths to be created
"
,
volumeID
)
}
}
}
...
...
@@ -299,7 +298,7 @@ func (attacher *cinderDiskAttacher) MountDevice(spec *volume.Spec, devicePath st
type
cinderDiskDetacher
struct
{
mounter
mount
.
Interface
cinderProvider
Cinder
Provider
cinderProvider
BlockStorage
Provider
}
var
_
volume
.
Detacher
=
&
cinderDiskDetacher
{}
...
...
pkg/volume/cinder/attacher_test.go
View file @
73b46ff7
...
...
@@ -453,18 +453,18 @@ func (testcase *testcase) AttachDisk(instanceID, volumeID string) (string, error
if
expected
.
volumeID
==
""
&&
expected
.
instanceID
==
""
{
// testcase.attach looks uninitialized, test did not expect to call
// AttachDisk
testcase
.
t
.
Errorf
(
"
Unexpected AttachDisk call!
"
)
return
""
,
errors
.
New
(
"
Unexpected AttachDisk call!
"
)
testcase
.
t
.
Errorf
(
"
unexpected AttachDisk call
"
)
return
""
,
errors
.
New
(
"
unexpected AttachDisk call
"
)
}
if
expected
.
volumeID
!=
volumeID
{
testcase
.
t
.
Errorf
(
"
U
nexpected AttachDisk call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
""
,
errors
.
New
(
"
U
nexpected AttachDisk call: wrong volumeID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected AttachDisk call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
""
,
errors
.
New
(
"
u
nexpected AttachDisk call: wrong volumeID"
)
}
if
expected
.
instanceID
!=
instanceID
{
testcase
.
t
.
Errorf
(
"
U
nexpected AttachDisk call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
""
,
errors
.
New
(
"
U
nexpected AttachDisk call: wrong instanceID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected AttachDisk call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
""
,
errors
.
New
(
"
u
nexpected AttachDisk call: wrong instanceID"
)
}
glog
.
V
(
4
)
.
Infof
(
"AttachDisk call: %s, %s, returning %q, %v"
,
volumeID
,
instanceID
,
expected
.
retDeviceName
,
expected
.
ret
)
...
...
@@ -479,18 +479,18 @@ func (testcase *testcase) DetachDisk(instanceID, volumeID string) error {
if
expected
.
devicePath
==
""
&&
expected
.
instanceID
==
""
{
// testcase.detach looks uninitialized, test did not expect to call
// DetachDisk
testcase
.
t
.
Errorf
(
"
Unexpected DetachDisk call!
"
)
return
errors
.
New
(
"
Unexpected DetachDisk call!
"
)
testcase
.
t
.
Errorf
(
"
unexpected DetachDisk call
"
)
return
errors
.
New
(
"
unexpected DetachDisk call
"
)
}
if
expected
.
devicePath
!=
volumeID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DetachDisk call: expected volumeID %s, got %s"
,
expected
.
devicePath
,
volumeID
)
return
errors
.
New
(
"
U
nexpected DetachDisk call: wrong volumeID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DetachDisk call: expected volumeID %s, got %s"
,
expected
.
devicePath
,
volumeID
)
return
errors
.
New
(
"
u
nexpected DetachDisk call: wrong volumeID"
)
}
if
expected
.
instanceID
!=
instanceID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DetachDisk call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
errors
.
New
(
"
U
nexpected DetachDisk call: wrong instanceID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DetachDisk call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
errors
.
New
(
"
u
nexpected DetachDisk call: wrong instanceID"
)
}
glog
.
V
(
4
)
.
Infof
(
"DetachDisk call: %s, %s, returning %v"
,
volumeID
,
instanceID
,
expected
.
ret
)
...
...
@@ -527,18 +527,18 @@ func (testcase *testcase) DiskIsAttached(instanceID, volumeID string) (bool, err
if
expected
.
volumeID
==
""
&&
expected
.
instanceID
==
""
{
// testcase.diskIsAttached looks uninitialized, test did not expect to
// call DiskIsAttached
testcase
.
t
.
Errorf
(
"
Unexpected DiskIsAttached call!
"
)
return
false
,
errors
.
New
(
"
Unexpected DiskIsAttached call!
"
)
testcase
.
t
.
Errorf
(
"
unexpected DiskIsAttached call
"
)
return
false
,
errors
.
New
(
"
unexpected DiskIsAttached call
"
)
}
if
expected
.
volumeID
!=
volumeID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DiskIsAttached call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
false
,
errors
.
New
(
"
U
nexpected DiskIsAttached call: wrong volumeID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DiskIsAttached call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
false
,
errors
.
New
(
"
u
nexpected DiskIsAttached call: wrong volumeID"
)
}
if
expected
.
instanceID
!=
instanceID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DiskIsAttached call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
false
,
errors
.
New
(
"
U
nexpected DiskIsAttached call: wrong instanceID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DiskIsAttached call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
false
,
errors
.
New
(
"
u
nexpected DiskIsAttached call: wrong instanceID"
)
}
glog
.
V
(
4
)
.
Infof
(
"DiskIsAttached call: %s, %s, returning %v, %v"
,
volumeID
,
instanceID
,
expected
.
isAttached
,
expected
.
ret
)
...
...
@@ -551,18 +551,18 @@ func (testcase *testcase) GetAttachmentDiskPath(instanceID, volumeID string) (st
if
expected
.
volumeID
==
""
&&
expected
.
instanceID
==
""
{
// testcase.diskPath looks uninitialized, test did not expect to
// call GetAttachmentDiskPath
testcase
.
t
.
Errorf
(
"
Unexpected GetAttachmentDiskPath call!
"
)
return
""
,
errors
.
New
(
"
Unexpected GetAttachmentDiskPath call!
"
)
testcase
.
t
.
Errorf
(
"
unexpected GetAttachmentDiskPath call
"
)
return
""
,
errors
.
New
(
"
unexpected GetAttachmentDiskPath call
"
)
}
if
expected
.
volumeID
!=
volumeID
{
testcase
.
t
.
Errorf
(
"
U
nexpected GetAttachmentDiskPath call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
""
,
errors
.
New
(
"
U
nexpected GetAttachmentDiskPath call: wrong volumeID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected GetAttachmentDiskPath call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
""
,
errors
.
New
(
"
u
nexpected GetAttachmentDiskPath call: wrong volumeID"
)
}
if
expected
.
instanceID
!=
instanceID
{
testcase
.
t
.
Errorf
(
"
U
nexpected GetAttachmentDiskPath call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
""
,
errors
.
New
(
"
U
nexpected GetAttachmentDiskPath call: wrong instanceID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected GetAttachmentDiskPath call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
""
,
errors
.
New
(
"
u
nexpected GetAttachmentDiskPath call: wrong instanceID"
)
}
glog
.
V
(
4
)
.
Infof
(
"GetAttachmentDiskPath call: %s, %s, returning %v, %v"
,
volumeID
,
instanceID
,
expected
.
retPath
,
expected
.
ret
)
...
...
@@ -588,25 +588,25 @@ func (testcase *testcase) DiskIsAttachedByName(nodeName types.NodeName, volumeID
}
if
expected
.
nodeName
!=
nodeName
{
testcase
.
t
.
Errorf
(
"
U
nexpected DiskIsAttachedByName call: expected nodename %s, got %s"
,
expected
.
nodeName
,
nodeName
)
return
false
,
instanceID
,
errors
.
New
(
"
U
nexpected DiskIsAttachedByName call: wrong nodename"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DiskIsAttachedByName call: expected nodename %s, got %s"
,
expected
.
nodeName
,
nodeName
)
return
false
,
instanceID
,
errors
.
New
(
"
u
nexpected DiskIsAttachedByName call: wrong nodename"
)
}
if
expected
.
volumeID
==
""
&&
expected
.
instanceID
==
""
{
// testcase.diskIsAttached looks uninitialized, test did not expect to
// call DiskIsAttached
testcase
.
t
.
Errorf
(
"
Unexpected DiskIsAttachedByName call!
"
)
return
false
,
instanceID
,
errors
.
New
(
"
Unexpected DiskIsAttachedByName call!
"
)
testcase
.
t
.
Errorf
(
"
unexpected DiskIsAttachedByName call
"
)
return
false
,
instanceID
,
errors
.
New
(
"
unexpected DiskIsAttachedByName call
"
)
}
if
expected
.
volumeID
!=
volumeID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DiskIsAttachedByName call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
false
,
instanceID
,
errors
.
New
(
"
U
nexpected DiskIsAttachedByName call: wrong volumeID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DiskIsAttachedByName call: expected volumeID %s, got %s"
,
expected
.
volumeID
,
volumeID
)
return
false
,
instanceID
,
errors
.
New
(
"
u
nexpected DiskIsAttachedByName call: wrong volumeID"
)
}
if
expected
.
instanceID
!=
instanceID
{
testcase
.
t
.
Errorf
(
"
U
nexpected DiskIsAttachedByName call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
false
,
instanceID
,
errors
.
New
(
"
U
nexpected DiskIsAttachedByName call: wrong instanceID"
)
testcase
.
t
.
Errorf
(
"
u
nexpected DiskIsAttachedByName call: expected instanceID %s, got %s"
,
expected
.
instanceID
,
instanceID
)
return
false
,
instanceID
,
errors
.
New
(
"
u
nexpected DiskIsAttachedByName call: wrong instanceID"
)
}
glog
.
V
(
4
)
.
Infof
(
"DiskIsAttachedByName call: %s, %s, returning %v, %v"
,
volumeID
,
nodeName
,
expected
.
isAttached
,
expected
.
instanceID
,
expected
.
ret
)
...
...
pkg/volume/cinder/cinder.go
View file @
73b46ff7
...
...
@@ -38,15 +38,17 @@ import (
)
const
(
// DefaultCloudConfigPath is the default path for cloud configuration
DefaultCloudConfigPath
=
"/etc/kubernetes/cloud-config"
)
//
Thi
s is the primary entrypoint for volume plugins.
//
ProbeVolumePlugin
s is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
cinderPlugin
{}}
}
type
CinderProvider
interface
{
// BlockStorageProvider is the interface for accessing cinder functionality.
type
BlockStorageProvider
interface
{
AttachDisk
(
instanceID
,
volumeID
string
)
(
string
,
error
)
DetachDisk
(
instanceID
,
volumeID
string
)
error
DeleteVolume
(
volumeID
string
)
error
...
...
@@ -120,7 +122,7 @@ func (plugin *cinderPlugin) GetAccessModes() []v1.PersistentVolumeAccessMode {
}
func
(
plugin
*
cinderPlugin
)
NewMounter
(
spec
*
volume
.
Spec
,
pod
*
v1
.
Pod
,
_
volume
.
VolumeOptions
)
(
volume
.
Mounter
,
error
)
{
return
plugin
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
Cinder
DiskUtil
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
return
plugin
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
DiskUtil
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
}
func
(
plugin
*
cinderPlugin
)
newMounterInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
cdManager
,
mounter
mount
.
Interface
)
(
volume
.
Mounter
,
error
)
{
...
...
@@ -147,7 +149,7 @@ func (plugin *cinderPlugin) newMounterInternal(spec *volume.Spec, podUID types.U
}
func
(
plugin
*
cinderPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
return
plugin
.
newUnmounterInternal
(
volName
,
podUID
,
&
Cinder
DiskUtil
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
return
plugin
.
newUnmounterInternal
(
volName
,
podUID
,
&
DiskUtil
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
}
func
(
plugin
*
cinderPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
cdManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -162,7 +164,7 @@ func (plugin *cinderPlugin) newUnmounterInternal(volName string, podUID types.UI
}
func
(
plugin
*
cinderPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
return
plugin
.
newDeleterInternal
(
spec
,
&
Cinder
DiskUtil
{})
return
plugin
.
newDeleterInternal
(
spec
,
&
DiskUtil
{})
}
func
(
plugin
*
cinderPlugin
)
newDeleterInternal
(
spec
*
volume
.
Spec
,
manager
cdManager
)
(
volume
.
Deleter
,
error
)
{
...
...
@@ -179,7 +181,7 @@ func (plugin *cinderPlugin) newDeleterInternal(spec *volume.Spec, manager cdMana
}
func
(
plugin
*
cinderPlugin
)
NewProvisioner
(
options
volume
.
VolumeOptions
)
(
volume
.
Provisioner
,
error
)
{
return
plugin
.
newProvisionerInternal
(
options
,
&
Cinder
DiskUtil
{})
return
plugin
.
newProvisionerInternal
(
options
,
&
DiskUtil
{})
}
func
(
plugin
*
cinderPlugin
)
newProvisionerInternal
(
options
volume
.
VolumeOptions
,
manager
cdManager
)
(
volume
.
Provisioner
,
error
)
{
...
...
@@ -192,23 +194,22 @@ func (plugin *cinderPlugin) newProvisionerInternal(options volume.VolumeOptions,
},
nil
}
func
(
plugin
*
cinderPlugin
)
getCloudProvider
()
(
Cinder
Provider
,
error
)
{
func
(
plugin
*
cinderPlugin
)
getCloudProvider
()
(
BlockStorage
Provider
,
error
)
{
cloud
:=
plugin
.
host
.
GetCloudProvider
()
if
cloud
==
nil
{
if
_
,
err
:=
os
.
Stat
(
DefaultCloudConfigPath
);
err
==
nil
{
var
config
*
os
.
File
config
,
err
=
os
.
Open
(
DefaultCloudConfigPath
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"unable to load OpenStack configuration from default path : %v"
,
err
))
}
else
{
defer
config
.
Close
()
cloud
,
err
=
cloudprovider
.
GetCloudProvider
(
openstack
.
ProviderName
,
config
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"unable to create OpenStack cloud provider from default path : %v"
,
err
))
}
return
nil
,
fmt
.
Errorf
(
"unable to load OpenStack configuration from default path : %v"
,
err
)
}
defer
config
.
Close
()
cloud
,
err
=
cloudprovider
.
GetCloudProvider
(
openstack
.
ProviderName
,
config
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to create OpenStack cloud provider from default path : %v"
,
err
)
}
}
else
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"OpenStack cloud provider was not initialized properly : %v"
,
err
)
)
return
nil
,
fmt
.
Errorf
(
"OpenStack cloud provider was not initialized properly : %v"
,
err
)
}
}
...
...
pkg/volume/cinder/cinder_util.go
View file @
73b46ff7
...
...
@@ -35,11 +35,12 @@ import (
"k8s.io/utils/exec"
)
type
CinderDiskUtil
struct
{}
// DiskUtil has utility/helper methods
type
DiskUtil
struct
{}
// Attaches a disk specified by a volume.CinderPersistenDisk to the current kubelet.
// Attach
Disk attach
es a disk specified by a volume.CinderPersistenDisk to the current kubelet.
// Mounts the disk to its global path.
func
(
util
*
Cinder
DiskUtil
)
AttachDisk
(
b
*
cinderVolumeMounter
,
globalPDPath
string
)
error
{
func
(
util
*
DiskUtil
)
AttachDisk
(
b
*
cinderVolumeMounter
,
globalPDPath
string
)
error
{
options
:=
[]
string
{}
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
...
...
@@ -98,8 +99,8 @@ func (util *CinderDiskUtil) AttachDisk(b *cinderVolumeMounter, globalPDPath stri
return
nil
}
//
U
nmounts the device and detaches the disk from the kubelet's host machine.
func
(
util
*
Cinder
DiskUtil
)
DetachDisk
(
cd
*
cinderVolumeUnmounter
)
error
{
//
DetachDisk u
nmounts the device and detaches the disk from the kubelet's host machine.
func
(
util
*
DiskUtil
)
DetachDisk
(
cd
*
cinderVolumeUnmounter
)
error
{
globalPDPath
:=
makeGlobalPDName
(
cd
.
plugin
.
host
,
cd
.
pdName
)
if
err
:=
cd
.
mounter
.
Unmount
(
globalPDPath
);
err
!=
nil
{
return
err
...
...
@@ -124,7 +125,8 @@ func (util *CinderDiskUtil) DetachDisk(cd *cinderVolumeUnmounter) error {
return
nil
}
func
(
util
*
CinderDiskUtil
)
DeleteVolume
(
cd
*
cinderVolumeDeleter
)
error
{
// DeleteVolume uses the cloud entrypoint to delete specified volume
func
(
util
*
DiskUtil
)
DeleteVolume
(
cd
*
cinderVolumeDeleter
)
error
{
cloud
,
err
:=
cd
.
plugin
.
getCloudProvider
()
if
err
!=
nil
{
return
err
...
...
@@ -158,7 +160,8 @@ func getZonesFromNodes(kubeClient clientset.Interface) (sets.String, error) {
return
zones
,
nil
}
func
(
util
*
CinderDiskUtil
)
CreateVolume
(
c
*
cinderVolumeProvisioner
)
(
volumeID
string
,
volumeSizeGB
int
,
volumeLabels
map
[
string
]
string
,
fstype
string
,
err
error
)
{
// CreateVolume uses the cloud provider entrypoint for creating a volume
func
(
util
*
DiskUtil
)
CreateVolume
(
c
*
cinderVolumeProvisioner
)
(
volumeID
string
,
volumeSizeGB
int
,
volumeLabels
map
[
string
]
string
,
fstype
string
,
err
error
)
{
cloud
,
err
:=
c
.
plugin
.
getCloudProvider
()
if
err
!=
nil
{
return
""
,
0
,
nil
,
""
,
err
...
...
@@ -247,10 +250,10 @@ func probeAttachedVolume() error {
}
func
scsiHostRescan
()
{
scsi
_p
ath
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
ioutil
.
ReadDir
(
scsi
_p
ath
);
err
==
nil
{
scsi
P
ath
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
ioutil
.
ReadDir
(
scsi
P
ath
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
name
:=
scsi
_p
ath
+
f
.
Name
()
+
"/scan"
name
:=
scsi
P
ath
+
f
.
Name
()
+
"/scan"
data
:=
[]
byte
(
"- - -"
)
ioutil
.
WriteFile
(
name
,
data
,
0666
)
}
...
...
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