Skip to content

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

Merged
merged 4 commits into from
Aug 14, 2018

Conversation

davidz627
Copy link
Contributor

@davidz627 davidz627 commented Aug 8, 2018

Fixes: #7

This is the full regional PD implementation.

BREAKING CHANGES:

  • It includes REMOVAL of the parameter "zone"
  • It ADDS the parameter "replication-type"
  • NodeID format has been changed to: {zone}/{nodeNameFromGCE}
  • VolumeID format has been changed to fully qualified format:
    projects/{project}/zones/{zone}/disks/{name}
    or
    projects/{project}/regions/{region}/disks/{name}

Also snuck in,
Fixes: #53

/assign @msau42
/assign @verult

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 8, 2018
func SplitZoneNameId(id string) (string, string, error) {
func VolumeIDToKey(id string) (*meta.Key, error) {
splitId := strings.Split(id, "/")
if len(splitId) != 6 {
Copy link
Contributor

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?

}
}

func NodeIDToZoneAndName(id string) (string, string, error) {
splitId := strings.Split(id, "/")
if len(splitId) != 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consts

return "", fmt.Errorf("no zones specified")
}
zone := zones[0]
splitZone := strings.Split(zone, "-")
Copy link
Contributor

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

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())
Copy link
Contributor

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"

return nil, fmt.Errorf("failed to insert regional disk: %v", err)
}

glog.Infof("Completed creation of disk %v", name)
Copy link
Contributor

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

@msau42
Copy link
Contributor

msau42 commented Aug 8, 2018

Just did a quick scan review. Will do more in-depth later.

Nit: we're not actually deprecating 'zone', we're outright removing it

@davidz627 davidz627 changed the title Regional PD Implementation [Deprecating parameter "zone"] Regional PD Implementation [Removing parameter "zone"] Aug 8, 2018
@davidz627
Copy link
Contributor Author

/retest

@davidz627 davidz627 force-pushed the feature/RePDNoParams branch 7 times, most recently from f8ba1c2 to 8cae16b Compare August 9, 2018 20:27
@davidz627 davidz627 force-pushed the feature/RePDNoParams branch from 8cae16b to 172c91c Compare August 13, 2018 20:54
@davidz627
Copy link
Contributor Author

davidz627 commented Aug 13, 2018

@msau42 addressed comments :)
still can't figure out this e2e test failure :(

} 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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 => volIDTopologyKey

)

const (
volIDFmt = "projects/%s/zones/%s/disks/{}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used anywhere?

const (
volIDFmt = "projects/%s/zones/%s/disks/{}"

volIDToplogyKey = 2
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit tests?

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)
Copy link
Contributor

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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:

  1. 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"
  2. 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
  3. 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.

@davidz627 davidz627 force-pushed the feature/RePDNoParams branch 4 times, most recently from d37ed65 to b56cdaa Compare August 14, 2018 17:26
@davidz627 davidz627 force-pushed the feature/RePDNoParams branch from b56cdaa to 6dd5ca7 Compare August 14, 2018 17:29
@davidz627
Copy link
Contributor Author

/hold
Will squash commits before merging

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 14, 2018
@davidz627 davidz627 force-pushed the feature/RePDNoParams branch from 8f5ea6d to e6cce81 Compare August 14, 2018 21:18
@davidz627
Copy link
Contributor Author

@msau42 addressed comments

@msau42
Copy link
Contributor

msau42 commented Aug 14, 2018

lgtm

picking random zones just pick 1 zone randomly and the others are picked
consecutively
@davidz627 davidz627 force-pushed the feature/RePDNoParams branch from e6cce81 to 2c284d4 Compare August 14, 2018 23:18
@davidz627
Copy link
Contributor Author

/hold cancel
@msau42 for lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 14, 2018
@msau42
Copy link
Contributor

msau42 commented Aug 14, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2018
@k8s-ci-robot k8s-ci-robot merged commit 29bb01d into kubernetes-sigs:master Aug 14, 2018
@davidz627 davidz627 deleted the feature/RePDNoParams branch August 14, 2018 23:29
}

glog.V(4).Infof("Completed creation of disk %v", name)
disk, err := cloudProvider.GetDisk(ctx, meta.ZonalKey(name, diskZone))
Copy link
Contributor

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?

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants