Skip to content

Snapshots cannot be imported across projects #781

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

Closed
christian-roggia opened this issue May 19, 2021 · 1 comment · Fixed by #782
Closed

Snapshots cannot be imported across projects #781

christian-roggia opened this issue May 19, 2021 · 1 comment · Fixed by #782

Comments

@christian-roggia
Copy link
Contributor

christian-roggia commented May 19, 2021

This issue is related to the topic discussed here: #224.

According to the documentation, it should be possible to import pre-existing snapshots across projects: https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/docs/kubernetes/user-guides/snapshots.md

But this doesn't seem to be the case:

'Failed to check and update snapshot content: failed to list snapshot for content restored-snapshot-content: "can not find snapshot for snapshotID projects/PROJECT_ID/global/snapshots/SNAPSHOT_ID"'

My first guess was that the CSI driver did not have the right IAM permissions to list or get the snapshots.

I attempted to grant the following permissions:

    "compute.snapshots.list",
    "compute.snapshots.get",
    "compute.snapshots.useReadOnly",

to the following service accounts:

    "serviceAccount:[email protected]",
    "serviceAccount:[email protected]",
    "serviceAccount:service-PROJECT_NUMBER@container-engine-robot.iam.gserviceaccount.com",
    "serviceAccount:pdcsi-workload@PROJECT_ID.iam.gserviceaccount.com",

where

pdcsi-workload@PROJECT_ID.iam.gserviceaccount.com

is an identity workload with service account

PROJECT_ID.svc.id.goog[kube-system/pdcsi-node-sa]

with no success.


I am assuming that the CSI driver is not able to import snapshots from another project because of the way it was implemented.

If this was not the case and the CSI driver is supposed (and has been observed) to work cross-projects then any clue would be helpful to understand why it is failing to locate the snapshot in my case (is it because of IAM? did I misconfigure something? is my CSI driver version too old?).

Thank you!

@christian-roggia
Copy link
Contributor Author

christian-roggia commented May 19, 2021

I confirm that the project is currently hardcoded here:

https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/pkg/gce-cloud-provider/compute/gce-compute.go#L768..L777

and here:

https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/pkg/common/utils.go#L103...L113

the project is not passed from the full qualified snapshot path down to the Snapshots.Get(project, snapshotName) function.


This means that if I try to import the snapshot X from project FOO to project BAR with the FQN

projects/PROJECT_FOO/global/snapshots/SNAPSHOT_ID

it gets imported as

projects/PROJECT_BAR/global/snapshots/SNAPSHOT_ID

thus failing with a NOT FOUND error.

@christian-roggia christian-roggia changed the title Snapshots cannot be used imported projects Snapshots cannot be imported across projects May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant