[gcp] Update config.py for safe dir creation (#9645)

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
Vysybyl 2020-09-02 06:41:44 +02:00 committed by GitHub
parent b04222dbd9
commit 6fa0edfbef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -309,6 +309,10 @@ def _configure_key_pair(config, compute):
_create_project_ssh_key_pair(project, public_key, ssh_user,
compute)
# Create the directory if it doesn't exists
private_key_dir = os.path.dirname(private_key_path)
os.makedirs(private_key_dir, exist_ok=True)
# We need to make sure to _create_ the file with the right
# permissions. In order to do that we need to change the default
# os.open behavior to include the mode we want.