-
Notifications
You must be signed in to change notification settings - Fork 1k
Add support for EBS CSI Driver #2677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9fa214c
Add support for EBS CSI Driver
cosimomeli e204b03
Merge branch 'master' into csi-compatibility
cosimomeli 8c60abc
Merge branch 'master' into csi-compatibility
cosimomeli 0ec0178
Merge branch 'master' into csi-compatibility
cosimomeli 105a1fe
Fix tests
cosimomeli fea733f
Merge branch 'master' into csi-compatibility
cosimomeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,3 +104,5 @@ e2e/tls | |
mocks | ||
|
||
ui/.npm/ | ||
|
||
.DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package volumes | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestGetProviderVolumeID(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
pv *v1.PersistentVolume | ||
expected string | ||
err error | ||
}{ | ||
{ | ||
name: "CSI volume handle", | ||
pv: &v1.PersistentVolume{ | ||
Spec: v1.PersistentVolumeSpec{ | ||
PersistentVolumeSource: v1.PersistentVolumeSource{ | ||
CSI: &v1.CSIPersistentVolumeSource{ | ||
VolumeHandle: "vol-075ddfc4a127d0bd5", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: "vol-075ddfc4a127d0bd5", | ||
err: nil, | ||
}, | ||
{ | ||
name: "AWS EBS volume handle", | ||
pv: &v1.PersistentVolume{ | ||
Spec: v1.PersistentVolumeSpec{ | ||
PersistentVolumeSource: v1.PersistentVolumeSource{ | ||
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{ | ||
VolumeID: "aws://eu-central-1a/vol-075ddfc4a127d0bd4", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: "vol-075ddfc4a127d0bd4", | ||
err: nil, | ||
}, | ||
{ | ||
name: "Empty volume handle", | ||
pv: &v1.PersistentVolume{ | ||
Spec: v1.PersistentVolumeSpec{}, | ||
}, | ||
expected: "", | ||
err: fmt.Errorf("got empty volume id for volume %v", &v1.PersistentVolume{}), | ||
}, | ||
} | ||
|
||
resizer := EBSVolumeResizer{} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
volumeID, err := resizer.GetProviderVolumeID(tt.pv) | ||
if volumeID != tt.expected || (err != nil && err.Error() != tt.err.Error()) { | ||
t.Errorf("expected %v, got %v, expected err %v, got %v", tt.expected, volumeID, tt.err, err) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestVolumeBelongsToProvider(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
pv *v1.PersistentVolume | ||
expected bool | ||
}{ | ||
{ | ||
name: "CSI volume handle", | ||
pv: &v1.PersistentVolume{ | ||
Spec: v1.PersistentVolumeSpec{ | ||
PersistentVolumeSource: v1.PersistentVolumeSource{ | ||
CSI: &v1.CSIPersistentVolumeSource{ | ||
Driver: "ebs.csi.aws.com", | ||
VolumeHandle: "vol-075ddfc4a127d0bd5", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "AWS EBS volume handle", | ||
pv: &v1.PersistentVolume{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Annotations: map[string]string { | ||
"pv.kubernetes.io/provisioned-by": "kubernetes.io/aws-ebs", | ||
}, | ||
}, | ||
Spec: v1.PersistentVolumeSpec{ | ||
PersistentVolumeSource: v1.PersistentVolumeSource{ | ||
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{ | ||
VolumeID: "aws://eu-central-1a/vol-075ddfc4a127d0bd4", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "Empty volume source", | ||
pv: &v1.PersistentVolume{ | ||
Spec: v1.PersistentVolumeSpec{}, | ||
}, | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
resizer := EBSVolumeResizer{} | ||
isProvider := resizer.VolumeBelongsToProvider(tt.pv) | ||
if isProvider != tt.expected { | ||
t.Errorf("expected %v, got %v", tt.expected, isProvider) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.