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

CVS/GCP: Trident fails for shared VPCs #529

Closed
okrause opened this issue Feb 12, 2021 · 1 comment
Closed

CVS/GCP: Trident fails for shared VPCs #529

okrause opened this issue Feb 12, 2021 · 1 comment

Comments

@okrause
Copy link
Contributor

okrause commented Feb 12, 2021

Describe the bug
Creating a PVC fails when using a shared-VPC on GCP. Please see details below.

Environment
Create two projects in GCP. Make one project into a host project by sharing its VPC to the other project (which becomes a service project). See https://cloud.google.com/vpc/docs/provisioning-shared-vpc

  • Trident version: 21.01.0
  • Trident installation flags used: standrad
  • Container runtime: [e.g. Docker 19.03.1-CE]
  • Kubernetes version: recent GKE
  • Kubernetes orchestrator: GKE
  • Kubernetes enabled feature gates: -
  • OS: Ubuntu
  • NetApp backend types: CVS for GCP
  • Other:

Root cause analysis and problem resolution
CVS API expect the service project number. This is build in gcp/api/gcp.go in makeURL:

func (d *Client) makeURL(resourcePath string) string {
	return fmt.Sprintf("%s/v2/projects/%s/locations/%s%s", d.config.APIURL, d.config.ProjectNumber,
		d.config.APIRegion, resourcePath)
}

The same project number is used to craft the network parameter:

gcpNetwork := fmt.Sprintf("projects/%s/global/networks/%s", d.Config.ProjectNumber, network)

gcpNetwork := fmt.Sprintf("projects/%s/global/networks/%s", d.Config.ProjectNumber, network)

This works fine in the standalone project case. For shared-VPCs, the network sting needs to include the host project number, not the service project number.

This is how this was solved for the CVS/GCP Terraform provider: https://github.com/NetApp/terraform-provider-netapp-gcp/blob/28a6f92d1eb5a2250a1398966bd6ed5eaf9a6be0/gcp/volume.go#L314

	var projectID string
	if request.SharedVpcProjectNumber != "" {
		projectID = request.SharedVpcProjectNumber
	} else {
		projectID = c.GetProjectID()
	}
	request.Network = fmt.Sprintf("projects/%s/global/networks/%s", projectID, request.Network)
@balaramesh
Copy link
Contributor

This has been fixed with e4b47c and will be available with Trident v21.04

@gnarl gnarl closed this as completed Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants