From 49d8171a88f1de2aa30ba7eeb3b9ac0c4090c8c7 Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Thu, 25 Apr 2024 18:13:19 -0500 Subject: [PATCH] Set service account for VM from config --- config.rb | 5 +++-- lib/hosting/gcp_apis.rb | 5 +++-- spec/model/lantern/lantern_timeline_spec.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config.rb b/config.rb index 8bbcb280a..2f83e2c4d 100644 --- a/config.rb +++ b/config.rb @@ -136,11 +136,12 @@ def self.e2e_test? # Lantern override :lantern_top_domain, "db.lantern.dev", string override :lantern_dns_email, "varik@lantern.dev", string - override :lantern_backup_bucket, "lantern-wal-g-backups-dev" + override :lantern_backup_bucket, "walg-dev-backups" override :e2e_test, "0" # GCP - override :gcp_project_id, "ringed-griffin-394922", string + override :gcp_project_id, "lantern-development", string + override :gcp_compute_service_account, "339254316100-compute@developer.gserviceaccount.com", string optional :gcp_creds_gcr_b64, string optional :gcp_creds_logging_b64, string optional :gcp_creds_coredumps_b64, string diff --git a/lib/hosting/gcp_apis.rb b/lib/hosting/gcp_apis.rb index 0fd1e8c82..cbe4132aa 100644 --- a/lib/hosting/gcp_apis.rb +++ b/lib/hosting/gcp_apis.rb @@ -104,7 +104,7 @@ def create_vm(name, zone, image, ssh_key, user, machine_type, disk_size_gb, labe }, serviceAccounts: [ { - email: "511682212298-compute@developer.gserviceaccount.com", + email: Config.gcp_compute_service_account, scopes: [ "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", @@ -129,7 +129,8 @@ def create_vm(name, zone, image, ssh_key, user, machine_type, disk_size_gb, labe def get_vm(vm_name, zone) connection = Excon.new(@host[:connection_string], headers: @host[:headers]) - response = connection.get(path: "/compute/v1/projects/#{@project}/zones/#{zone}/instances/#{vm_name}", expects: 200) + response = connection.get(path: "/compute/v1/projects/#{@project}/zones/#{zone}/instances/#{vm_name}", expects: [200, 400, 404]) + Hosting::GcpApis.check_errors(response) JSON.parse(response.body) end diff --git a/spec/model/lantern/lantern_timeline_spec.rb b/spec/model/lantern/lantern_timeline_spec.rb index 3e46ea9c0..7a8f29978 100644 --- a/spec/model/lantern/lantern_timeline_spec.rb +++ b/spec/model/lantern/lantern_timeline_spec.rb @@ -16,7 +16,7 @@ expect(lantern_timeline).to receive(:gcp_creds_b64).and_return("test-creds") config = { gcp_creds_b64: "test-creds", - walg_gs_prefix: "gs://lantern-wal-g-backups-dev/pvr1mcnhzd8p0qwwa00tr5cvex" + walg_gs_prefix: "gs://walg-dev-backups/pvr1mcnhzd8p0qwwa00tr5cvex" } expect(lantern_timeline.generate_walg_config).to eq(config)