-
Notifications
You must be signed in to change notification settings - Fork 159
Regional PD Implementation [Removing parameter "zone"] #84
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
Regional PD Implementation [Removing parameter "zone"] #84
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: davidz627 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
pkg/common/utils.go
Outdated
func SplitZoneNameId(id string) (string, string, error) { | ||
func VolumeIDToKey(id string) (*meta.Key, error) { | ||
splitId := strings.Split(id, "/") | ||
if len(splitId) != 6 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the total and each element index constants?
pkg/common/utils.go
Outdated
} | ||
} | ||
|
||
func NodeIDToZoneAndName(id string) (string, string, error) { | ||
splitId := strings.Split(id, "/") | ||
if len(splitId) != 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consts
pkg/common/utils.go
Outdated
return "", fmt.Errorf("no zones specified") | ||
} | ||
zone := zones[0] | ||
splitZone := strings.Split(zone, "-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment with the expected syntax
pkg/gce-pd-csi-driver/controller.go
Outdated
remainingZones := reqSet.Difference(prefSet) | ||
|
||
if remainingZones.Len() < remainingNumZones { | ||
return nil, fmt.Errorf("need %v zones in preferred and requisite topologies to satisfy, only have %v unique zones", numZones, reqSet.Union(prefSet).Len()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message could be simplified a little bit to say "need %v zones from topology, only got %v unique zones"
pkg/gce-pd-csi-driver/controller.go
Outdated
return nil, fmt.Errorf("failed to insert regional disk: %v", err) | ||
} | ||
|
||
glog.Infof("Completed creation of disk %v", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add log levels to all the Info statements
Just did a quick scan review. Will do more in-depth later. Nit: we're not actually deprecating 'zone', we're outright removing it |
/retest |
f8ba1c2
to
8cae16b
Compare
8cae16b
to
172c91c
Compare
@msau42 addressed comments :) |
pkg/common/utils.go
Outdated
} else if splitId[volIDToplogyKey] == "regions" { | ||
return meta.RegionalKey(splitId[volIDDiskNameValue], splitId[volIDToplogyValue]), nil | ||
} else { | ||
return nil, fmt.Errorf("could not get id components, expected either zones or regions, got: %v", splitId[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 => volIDTopologyKey
pkg/common/utils.go
Outdated
) | ||
|
||
const ( | ||
volIDFmt = "projects/%s/zones/%s/disks/{}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this used anywhere?
pkg/common/utils.go
Outdated
const ( | ||
volIDFmt = "projects/%s/zones/%s/disks/{}" | ||
|
||
volIDToplogyKey = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment above here with the syntax
@@ -31,14 +46,41 @@ func GbToBytes(Gb int64) int64 { | |||
return Gb * 1024 * 1024 * 1024 | |||
} | |||
|
|||
func SplitZoneNameId(id string) (string, string, error) { | |||
func VolumeIDToKey(id string) (*meta.Key, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit tests?
pkg/gce-pd-csi-driver/controller.go
Outdated
zone, err := getZoneFromSegment(prefTop[0].GetSegments()) | ||
// Add the remaining number of zones into the set | ||
// TODO: Maybe we should pick a random set to get | ||
nSlice, err := pickRandNFromSlice(remainingZones.List(), remainingNumZones) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we actually want the first zone to be random. But the second zone should always be +1 from the first (sorted)
return cloud.zone | ||
func (cloud *CloudProvider) GetDisk(ctx context.Context, key *meta.Key) (*CloudDisk, error) { | ||
switch key.Type() { | ||
case meta.Zonal: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having case statements for the two types of disks, I'm wondering if it would be simpler to define a generic Disk interface, and have a zonal implementation, and a regional implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are merits to both ways, although the current method I still like better for 3 reasons:
- This isn't just an interface for disks, there are some other "types" of calls as well that wouldn't cleanly fit in a disk interface and I would rather just maintain 1 interface for "cloud provider"
- Some calls are not different between regional/zonal, I believe in go since there is no inheritance we would just have to copy/paste that code if there were two types of disks
- It's already like this and would take some effort to change. Without a strong reason otherwise it would be better to spend that effort elsewhere.
d37ed65
to
b56cdaa
Compare
b56cdaa
to
6dd5ca7
Compare
/hold |
8f5ea6d
to
e6cce81
Compare
@msau42 addressed comments |
lgtm |
picking random zones just pick 1 zone randomly and the others are picked consecutively
e6cce81
to
2c284d4
Compare
/hold cancel |
/lgtm |
} | ||
|
||
glog.V(4).Infof("Completed creation of disk %v", name) | ||
disk, err := cloudProvider.GetDisk(ctx, meta.ZonalKey(name, diskZone)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now for each creation, there is an extra cloud provider GET API calls. Why not just use insertDisk which can return the disk object directly? In previous version, there is no GET call after the CREATE call, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insertDisk doesn't return a disk object AFAIK. It returns an operation which we can poll for completion of the disk create operation, but getting the disk itself will be a seperate operation still.
We required this change not strictly because of RePD but because we wanted to have volume ID
be the disk selfLink
of the form projects/{project}/zones|regions/{zone|region}/disks/{diskname}
and to get the self-link we need to get the disk
Fixes: #7
This is the full regional PD implementation.
BREAKING CHANGES:
{zone}/{nodeNameFromGCE}
projects/{project}/zones/{zone}/disks/{name}
or
projects/{project}/regions/{region}/disks/{name}
Also snuck in,
Fixes: #53
/assign @msau42
/assign @verult