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
67e1f2c0
Commit
67e1f2c0
authored
Apr 05, 2017
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add e2e tests for storageclass
This reverts commit
22352d28
and makes gce.GetDiskByNameUnknownZone a public GCE cloud provider method.
parent
8667d7c4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
gce_disks.go
pkg/cloudprovider/providers/gce/gce_disks.go
+13
-11
volume_provisioning.go
test/e2e/volume_provisioning.go
+0
-0
No files found.
pkg/cloudprovider/providers/gce/gce_disks.go
View file @
67e1f2c0
...
...
@@ -77,10 +77,11 @@ type Disks interface {
// GCECloud implements Disks.
var
_
Disks
=
(
*
GCECloud
)(
nil
)
type
gce
Disk
struct
{
type
GCE
Disk
struct
{
Zone
string
Name
string
Kind
string
Type
string
}
func
(
gce
*
GCECloud
)
AttachDisk
(
diskName
string
,
nodeName
types
.
NodeName
,
readOnly
bool
)
error
{
...
...
@@ -259,7 +260,7 @@ func (gce *GCECloud) DeleteDisk(diskToDelete string) error {
// If zone is specified, the volume will only be found in the specified zone,
// otherwise all managed zones will be searched.
func
(
gce
*
GCECloud
)
GetAutoLabelsForPD
(
name
string
,
zone
string
)
(
map
[
string
]
string
,
error
)
{
var
disk
*
gce
Disk
var
disk
*
GCE
Disk
var
err
error
if
zone
==
""
{
// We would like as far as possible to avoid this case,
...
...
@@ -268,7 +269,7 @@ func (gce *GCECloud) GetAutoLabelsForPD(name string, zone string) (map[string]st
// by name, so we have to continue to support that.
// However, wherever possible the zone should be passed (and it is passed
// for most cases that we can control, e.g. dynamic volume provisioning)
disk
,
err
=
gce
.
g
etDiskByNameUnknownZone
(
name
)
disk
,
err
=
gce
.
G
etDiskByNameUnknownZone
(
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -300,16 +301,17 @@ func (gce *GCECloud) GetAutoLabelsForPD(name string, zone string) (map[string]st
return
labels
,
nil
}
// Returns a
gce
Disk for the disk, if it is found in the specified zone.
// Returns a
GCE
Disk for the disk, if it is found in the specified zone.
// If not found, returns (nil, nil)
func
(
gce
*
GCECloud
)
findDiskByName
(
diskName
string
,
zone
string
)
(
*
gce
Disk
,
error
)
{
func
(
gce
*
GCECloud
)
findDiskByName
(
diskName
string
,
zone
string
)
(
*
GCE
Disk
,
error
)
{
dc
:=
contextWithNamespace
(
diskName
,
"gce_list_disk"
)
disk
,
err
:=
gce
.
service
.
Disks
.
Get
(
gce
.
projectID
,
zone
,
diskName
)
.
Context
(
dc
)
.
Do
()
if
err
==
nil
{
d
:=
&
gce
Disk
{
d
:=
&
GCE
Disk
{
Zone
:
lastComponent
(
disk
.
Zone
),
Name
:
disk
.
Name
,
Kind
:
disk
.
Kind
,
Type
:
disk
.
Type
,
}
return
d
,
nil
}
...
...
@@ -320,7 +322,7 @@ func (gce *GCECloud) findDiskByName(diskName string, zone string) (*gceDisk, err
}
// Like findDiskByName, but returns an error if the disk is not found
func
(
gce
*
GCECloud
)
getDiskByName
(
diskName
string
,
zone
string
)
(
*
gce
Disk
,
error
)
{
func
(
gce
*
GCECloud
)
getDiskByName
(
diskName
string
,
zone
string
)
(
*
GCE
Disk
,
error
)
{
disk
,
err
:=
gce
.
findDiskByName
(
diskName
,
zone
)
if
disk
==
nil
&&
err
==
nil
{
return
nil
,
fmt
.
Errorf
(
"GCE persistent disk not found: diskName=%q zone=%q"
,
diskName
,
zone
)
...
...
@@ -331,7 +333,7 @@ func (gce *GCECloud) getDiskByName(diskName string, zone string) (*gceDisk, erro
// Scans all managed zones to return the GCE PD
// Prefer getDiskByName, if the zone can be established
// Return cloudprovider.DiskNotFound if the given disk cannot be found in any zone
func
(
gce
*
GCECloud
)
getDiskByNameUnknownZone
(
diskName
string
)
(
*
gce
Disk
,
error
)
{
func
(
gce
*
GCECloud
)
GetDiskByNameUnknownZone
(
diskName
string
)
(
*
GCE
Disk
,
error
)
{
// Note: this is the gotcha right now with GCE PD support:
// disk names are not unique per-region.
// (I can create two volumes with name "myvol" in e.g. us-central1-b & us-central1-f)
...
...
@@ -342,7 +344,7 @@ func (gce *GCECloud) getDiskByNameUnknownZone(diskName string) (*gceDisk, error)
// admission control, but that might be a little weird (values changing
// on create)
var
found
*
gce
Disk
var
found
*
GCE
Disk
for
_
,
zone
:=
range
gce
.
managedZones
{
disk
,
err
:=
gce
.
findDiskByName
(
diskName
,
zone
)
if
err
!=
nil
{
...
...
@@ -383,7 +385,7 @@ func (gce *GCECloud) encodeDiskTags(tags map[string]string) (string, error) {
}
func
(
gce
*
GCECloud
)
doDeleteDisk
(
diskToDelete
string
)
error
{
disk
,
err
:=
gce
.
g
etDiskByNameUnknownZone
(
diskToDelete
)
disk
,
err
:=
gce
.
G
etDiskByNameUnknownZone
(
diskToDelete
)
if
err
!=
nil
{
return
err
}
...
...
@@ -398,7 +400,7 @@ func (gce *GCECloud) doDeleteDisk(diskToDelete string) error {
}
// Converts a Disk resource to an AttachedDisk resource.
func
(
gce
*
GCECloud
)
convertDiskToAttachedDisk
(
disk
*
gce
Disk
,
readWrite
string
)
*
compute
.
AttachedDisk
{
func
(
gce
*
GCECloud
)
convertDiskToAttachedDisk
(
disk
*
GCE
Disk
,
readWrite
string
)
*
compute
.
AttachedDisk
{
return
&
compute
.
AttachedDisk
{
DeviceName
:
disk
.
Name
,
Kind
:
disk
.
Kind
,
...
...
test/e2e/volume_provisioning.go
View file @
67e1f2c0
This diff is collapsed.
Click to expand it.
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