简体   繁体   中英

How to save files from R Studio-server on GCE VM to a Google Cloud Bucket? Possible settings issue

I have a VM on GCE with R Studio-server installed. I have mounted a bucket form google cloud in my VM such that I am able to access and load my data in R. My goal is to be able to to save output back in this bucket. How can I do so? When I tried to save data using the R function saveRDS() I got the following error message:

Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'remote/processed_input_reproduction/file.rds', probable reason 'Permission denied'

Investigating the problem, I got to this link . One of the suggestions in it is: "It is possible that the GCE instance is not running with scope "storage-full" configured. For example: If you have created GCE instance with default Cloud API access scopes, it set the GCE instance storage access scope to read only. In that case, you can change the access scope of the instance for Storage to "Full"" . This had also been suggested to me in another question I asked recently. However, when I changed the storage's scope to full, I was unable to connect again to my VM instance. Changing storage's scope back to read only solved the issue. How can I avoid this issue when setting storage's scope to full? How can I write files from R Studio-server back to my mounted bucket?

About the issue, when scope was set as full I would get the following error message (see bottom for it) by running gcloud compute ssh my-project --project=roberto --zone=us-west1-b --troubleshoot :

Starting ssh troubleshooting for instance https://compute.googleapis.com/compute/v1/projects/roberto/zones/us-west1-b/instances/my-project in zone us-west1-b
Start time: 2023-01-30 19:56:09.194370

---- Checking network connectivity ----
The Network Management API is needed to check the VM's network connectivity.

Is it OK to enable it and check the VM's network connectivity? (Y/n)?  Y

Enabling service [networkmanagement.googleapis.com] on project [emlab-gcp]...
 Operation "operations/acat.p2-458956698118-ed65bbb9-e27f-45f4-a929-6020411326dc" finished successfully.
 Your source IP address is 72.xxx.xx.xx

 Network Connectivity Test Result: REACHABLE

 To view complete details of this test, see https://console.cloud.google.com/net-intelligence/connectivity/tests/details/ssh-troubleshoot-7meui?project=roberto

Help for connectivity tests:
https://cloud.google.com/network-intelligence-center/docs/connectivity-tests/concepts/overview

---- Checking user permissions ----
User permissions: 0 issue(s) found.

---- Checking VPC settings ----
VPC settings: 0 issue(s) found.

---- Checking VM status ----
The Monitoring API is needed to check the VM's Status.

Is it OK to enable it and check the VM's Status? (Y/n)?  Y

Enabling service [monitoring.googleapis.com] on project [roberto]...
VM status: 0 issue(s) found.

---- Checking VM boot status ----
VM boot: 1 issue(s) found.

The VM may not be running. The serial console logs show the VM has been unable to complete the boot process. Check your serial console logs to see if the VM has been dropped into an "emergency shell" or has reached "Emergency Mode". If that is the case, try restarting the VM to see if the problem is reproducible.

Hi RobertoAS instead of changing the scopes there is another way you can use gcsfuse library for mounting the storage bucket to your compute engine and while mounting it, mount it to the user directory or give necessary permission to the service which is running the R studio-server. Follow this doc for mounting your cloud storage bucket using gcsfuse go through this document . This worked for me and I hope this will solve your issue as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM