2

I am writing files to Google app engine managed vm (flexible environment). I have deployed the code to cloud. The code opened the file and write it without show errors like permission errors. However, my another code trying to open the file failed with "No such file or directory".

I have printed the location directory, so I used ssh command, also cannot find the file inside managed vm. And I cannot find any documentation about writing files to local storage of managed VM.

So how to write it to managed vm? What is the default storage location? Why I cannot find the file?

Weiming
  • 37
  • 6
  • Could the file been written in a different instance which has since been destroyed? As a start i would write to `/tmp` which is usually writeable to all users. – konqi May 24 '16 at 13:53
  • I tried, cannot find the file there too. It is in the docker container – Weiming May 26 '16 at 05:58

1 Answers1

2

The reason you can't find the file inside the VM is because the VM is running a Docker container, and your app is actually inside that container. If you really wanted to, you could docker exec -it <container-name> -- /bin/bash to poke around inside the container and then you should see your file (use docker ps to find the container ID).

On App Engine flexible (new name for Managed VMs), your code could be scaled across many container so there's no promise that a file you write to one will be accessible later. You can get away with dealing with some writing to some /tmp files but not much more. You will be much better off writing any data to something like Cloud Datastore, Cloud SQL, Memcache, or Cloud Storage.

Bill Prin
  • 2,498
  • 1
  • 20
  • 27
  • Thanks for the reply. Do you have a way to use cloudstorage library instead of gcloud storage library to write file to Cloud Storage in Managed VM? – Weiming May 25 '16 at 23:48
  • Which cloudstorage library are you referring to? – Bill Prin May 26 '16 at 00:20
  • This one `git clone https://github.com/GoogleCloudPlatform/appengine-gcs-client.git`. There are tutorials about how to use `from gcloud import storage` in managed vm but not that lib. – Weiming May 26 '16 at 05:34
  • Haven't used it so I'm not sure. If it's not working as is, it might work if you change runtime: python to runtime:python-compat (runtime that's compatible with App Engine standard). But I would stick with gcloud-python as it's the way forward. – Bill Prin May 27 '16 at 20:33