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
d2ca5194
Unverified
Commit
d2ca5194
authored
Nov 29, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70432 from mvladev/fix-cloud-provider-aws
fix aws provider to handle only EBS volumes
parents
86d4d95e
fa80dd53
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
BUILD
pkg/cloudprovider/providers/aws/BUILD
+1
-0
aws.go
pkg/cloudprovider/providers/aws/aws.go
+5
-0
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+93
-0
No files found.
pkg/cloudprovider/providers/aws/BUILD
View file @
d2ca5194
...
@@ -78,6 +78,7 @@ go_test(
...
@@ -78,6 +78,7 @@ go_test(
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/kubelet/apis:go_default_library",
"//pkg/kubelet/apis:go_default_library",
"//pkg/volume:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
...
...
pkg/cloudprovider/providers/aws/aws.go
View file @
d2ca5194
...
@@ -2324,6 +2324,11 @@ func (c *Cloud) checkIfAvailable(disk *awsDisk, opName string, instance string)
...
@@ -2324,6 +2324,11 @@ func (c *Cloud) checkIfAvailable(disk *awsDisk, opName string, instance string)
// GetLabelsForVolume gets the volume labels for a volume
// GetLabelsForVolume gets the volume labels for a volume
func
(
c
*
Cloud
)
GetLabelsForVolume
(
ctx
context
.
Context
,
pv
*
v1
.
PersistentVolume
)
(
map
[
string
]
string
,
error
)
{
func
(
c
*
Cloud
)
GetLabelsForVolume
(
ctx
context
.
Context
,
pv
*
v1
.
PersistentVolume
)
(
map
[
string
]
string
,
error
)
{
// Ignore if not AWSElasticBlockStore.
if
pv
.
Spec
.
AWSElasticBlockStore
==
nil
{
return
nil
,
nil
}
// Ignore any volumes that are being provisioned
// Ignore any volumes that are being provisioned
if
pv
.
Spec
.
AWSElasticBlockStore
.
VolumeID
==
volume
.
ProvisionedVolumeName
{
if
pv
.
Spec
.
AWSElasticBlockStore
.
VolumeID
==
volume
.
ProvisionedVolumeName
{
return
nil
,
nil
return
nil
,
nil
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
d2ca5194
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
"k8s.io/kubernetes/pkg/volume"
)
)
const
TestClusterID
=
"clusterid.test"
const
TestClusterID
=
"clusterid.test"
...
@@ -912,6 +913,98 @@ func TestGetVolumeLabels(t *testing.T) {
...
@@ -912,6 +913,98 @@ func TestGetVolumeLabels(t *testing.T) {
awsServices
.
ec2
.
(
*
MockedFakeEC2
)
.
AssertExpectations
(
t
)
awsServices
.
ec2
.
(
*
MockedFakeEC2
)
.
AssertExpectations
(
t
)
}
}
func
TestGetLabelsForVolume
(
t
*
testing
.
T
)
{
defaultVolume
:=
EBSVolumeID
(
"vol-VolumeId"
)
.
awsString
()
tests
:=
[]
struct
{
name
string
pv
*
v1
.
PersistentVolume
expectedVolumeID
*
string
expectedEC2Volumes
[]
*
ec2
.
Volume
expectedLabels
map
[
string
]
string
expectedError
error
}{
{
"not an EBS volume"
,
&
v1
.
PersistentVolume
{
Spec
:
v1
.
PersistentVolumeSpec
{},
},
nil
,
nil
,
nil
,
nil
,
},
{
"volume which is being provisioned"
,
&
v1
.
PersistentVolume
{
Spec
:
v1
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
v1
.
PersistentVolumeSource
{
AWSElasticBlockStore
:
&
v1
.
AWSElasticBlockStoreVolumeSource
{
VolumeID
:
volume
.
ProvisionedVolumeName
,
},
},
},
},
nil
,
nil
,
nil
,
nil
,
},
{
"no volumes found"
,
&
v1
.
PersistentVolume
{
Spec
:
v1
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
v1
.
PersistentVolumeSource
{
AWSElasticBlockStore
:
&
v1
.
AWSElasticBlockStoreVolumeSource
{
VolumeID
:
"vol-VolumeId"
,
},
},
},
},
defaultVolume
,
nil
,
nil
,
fmt
.
Errorf
(
"no volumes found"
),
},
{
"correct labels for volume"
,
&
v1
.
PersistentVolume
{
Spec
:
v1
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
v1
.
PersistentVolumeSource
{
AWSElasticBlockStore
:
&
v1
.
AWSElasticBlockStoreVolumeSource
{
VolumeID
:
"vol-VolumeId"
,
},
},
},
},
defaultVolume
,
[]
*
ec2
.
Volume
{{
VolumeId
:
defaultVolume
,
AvailabilityZone
:
aws
.
String
(
"us-east-1a"
),
}},
map
[
string
]
string
{
kubeletapis
.
LabelZoneFailureDomain
:
"us-east-1a"
,
kubeletapis
.
LabelZoneRegion
:
"us-east-1"
,
},
nil
,
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
awsServices
:=
newMockedFakeAWSServices
(
TestClusterID
)
expectedVolumeRequest
:=
&
ec2
.
DescribeVolumesInput
{
VolumeIds
:
[]
*
string
{
test
.
expectedVolumeID
}}
awsServices
.
ec2
.
(
*
MockedFakeEC2
)
.
On
(
"DescribeVolumes"
,
expectedVolumeRequest
)
.
Return
(
test
.
expectedEC2Volumes
)
c
,
err
:=
newAWSCloud
(
CloudConfig
{},
awsServices
)
assert
.
Nil
(
t
,
err
,
"Error building aws cloud: %v"
,
err
)
l
,
err
:=
c
.
GetLabelsForVolume
(
context
.
TODO
(),
test
.
pv
)
assert
.
Equal
(
t
,
test
.
expectedLabels
,
l
)
assert
.
Equal
(
t
,
test
.
expectedError
,
err
)
})
}
}
func
TestDescribeLoadBalancerOnDelete
(
t
*
testing
.
T
)
{
func
TestDescribeLoadBalancerOnDelete
(
t
*
testing
.
T
)
{
awsServices
:=
newMockedFakeAWSServices
(
TestClusterID
)
awsServices
:=
newMockedFakeAWSServices
(
TestClusterID
)
c
,
_
:=
newAWSCloud
(
CloudConfig
{},
awsServices
)
c
,
_
:=
newAWSCloud
(
CloudConfig
{},
awsServices
)
...
...
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