Skip to content
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

Fix restoring GCP regional disks #1200

Merged
merged 1 commit into from
Feb 12, 2019
Merged

Fix restoring GCP regional disks #1200

merged 1 commit into from
Feb 12, 2019

Conversation

nrb
Copy link
Contributor

@nrb nrb commented Feb 7, 2019

To create a regional disk, the URLs for the zones in which the disk is
replicated must be provided to the GCP API.

Fixes #1183

Signed-off-by: Nolan Brubaker brubakern@vmware.com

@nrb nrb added the Bug label Feb 7, 2019
@nrb nrb requested review from carlisia and skriss February 7, 2019 19:26
if err != nil {
return "", err
}
disk.ReplicaZones = createZoneURLs(b.project, volumeAZ)
Copy link
Contributor

@skriss skriss Feb 11, 2019

Choose a reason for hiding this comment

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

I think there may be an option to not hardcode the URL template -- you should be able to do something like:

zone, err := b.gce.Zones.Get("<project>", "zone>").Do()
// TODO handle error
url := zone.SelfLink

The url value looks like it will be a relative one, e.g. /projects/<proj>/... -- but I think based on other API documentation that this should be an acceptable value for ReplicaZones. If this works, I think it's probably preferable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, thanks. I think I'd prefer that to a templated URL, too. Will give it a test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure that the relative URL will be accepted, but 🤞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works!

% k get pv -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolume
    labels:
      failure-domain.beta.kubernetes.io/region: us-west1
      failure-domain.beta.kubernetes.io/zone: us-west1-b__us-west1-c
      velero-restore: nginx-regional-20190211133203
      velero.io/backup-name: nginx-regional
      velero.io/restore-name: nginx-regional-20190211133203

I'll look around how to make the unit testing work with this client call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, though I didn't mock out the client seeing as none of the rest of that logic is mocked currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think it's OK for now given precedent. Is this otherwise good to go? I'll do a quick test on it as well - got any sample YAMLs I could use?

@skriss skriss added this to the v0.11.0 milestone Feb 11, 2019
Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

I had to change 2 things to get this to work:

  • underscore issue (see below comment)
  • add 'compute.zones.get' permission to the IAM role

I think adding the latter as a requirement is fine, but we'll need to update docs and make sure we call it out in the changelog.

pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
// in the failure-domain tag.
// For example
// Cluster nodes in us-central1-c, us-central1-f
// Storage class zones us-central1-a, us-central1-f, us-east1-a, us-east1-d
// The failure-domain tag would be: us-central1-a__us-central1-f
func parseRegion(volumeAZ string) (string, error) {
func parseZone(volumeAZ string) (string, error) {
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 this was called parseRegion because it returns a region name (e.g. us-west1), not a zone name. Maybe we just call it getRegion?

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 took it back to parseRegion - I had misunderstood it on reading, and thought it was getting a zone, not a region, but you're correct.

pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
@nrb
Copy link
Contributor Author

nrb commented Feb 12, 2019

Fixes and docs pushed. Will squash if they look good.

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Couple cosmetic comments, otherwise LGTM. Feel free to squash as part of addressing. Gonna do a quick re-test now.

pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
pkg/cloudprovider/gcp/block_store_test.go Outdated Show resolved Hide resolved
@skriss
Copy link
Contributor

skriss commented Feb 12, 2019

retest looks good

Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

LGTM 👍

pkg/cloudprovider/gcp/block_store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM, pls squash

To create a regional disk, the URLs for the zones in which the disk is
replicated must be provided to the GCP API.

Fixes vmware-tanzu#1183

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
@skriss skriss merged commit e1d4143 into vmware-tanzu:master Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants