From 6fa0edfbef4c51c5e1762d3a56d94a020d26d9fe Mon Sep 17 00:00:00 2001 From: Vysybyl Date: Wed, 2 Sep 2020 06:41:44 +0200 Subject: [PATCH] [gcp] Update config.py for safe dir creation (#9645) Co-authored-by: Richard Liaw --- python/ray/autoscaler/gcp/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/ray/autoscaler/gcp/config.py b/python/ray/autoscaler/gcp/config.py index 55870a699..277ebebac 100644 --- a/python/ray/autoscaler/gcp/config.py +++ b/python/ray/autoscaler/gcp/config.py @@ -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.