aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-07-01 08:59:18 +0100
committerChristopher Baines <mail@cbaines.net>2018-07-01 08:59:18 +0100
commit33572bb8ec8990b148aba7bbf23732c8f19bc21c (patch)
tree5d4d3d3796664270ec1bd805f37a96d8b7044182 /app
parent1e324dfdcc47f83ecc613ec8faaf9e378a808bfb (diff)
downloadgovuk-mini-environment-admin-33572bb8ec8990b148aba7bbf23732c8f19bc21c.tar
govuk-mini-environment-admin-33572bb8ec8990b148aba7bbf23732c8f19bc21c.tar.gz
Fix the CreateDataSnapshotJob
To better handle remote hosts.
Diffstat (limited to 'app')
-rw-r--r--app/jobs/govuk_guix/create_data_snapshot_job.rb23
-rw-r--r--app/models/backends/terraform_aws/backend_methods.rb1
2 files changed, 7 insertions, 17 deletions
diff --git a/app/jobs/govuk_guix/create_data_snapshot_job.rb b/app/jobs/govuk_guix/create_data_snapshot_job.rb
index 91f3904..d6345a0 100644
--- a/app/jobs/govuk_guix/create_data_snapshot_job.rb
+++ b/app/jobs/govuk_guix/create_data_snapshot_job.rb
@@ -24,20 +24,6 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
@retry_interval = 30
- def enqueue(options = {})
- backend_type = options[:backend_type]
- backend_id = options[:backend_id]
-
- remote_host = options[:run_remotely_on_host]
-
- if remote_host
- raise 'backend_type missing' unless backend_type
- raise 'backend_id missing' unless backend_id
- end
-
- super(options)
- end
-
def run(options = {})
data_snapshot_fields = {}
@@ -46,6 +32,8 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
if backend_type
backend = Backends.find_by_type_and_id(backend_type, backend_id)
data_snapshot_fields[:backend] = backend
+
+ remote_host = backend.build_remote_host
end
revision_id = options[:revision_id]
@@ -56,19 +44,22 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
end
data_snapshot_fields[:govuk_guix_revision] = revision
- remote_host = options[:run_remotely_on_host]
logger.info(self.class) do
'Creating new data snapshot'
end
if remote_host
+ # TODO: This doesn't use the private key specified by the
+ # backend, so it'll only work when the default SSH key has
+ # access to the remote host.
+
# Copy the revision to the remote host, to ensure it's available
# there
run_command(
'guix',
'copy',
- "--to=#{remote_host}",
+ "--to=#{remote_host.user_at_address}",
revision.store_path
)
end
diff --git a/app/models/backends/terraform_aws/backend_methods.rb b/app/models/backends/terraform_aws/backend_methods.rb
index f069d77..5ade46c 100644
--- a/app/models/backends/terraform_aws/backend_methods.rb
+++ b/app/models/backends/terraform_aws/backend_methods.rb
@@ -21,7 +21,6 @@
module Backends::TerraformAws::BackendMethods
def create_data_snapshot
GovukGuix::CreateDataSnapshotJob.enqueue(
- run_remotely_on_host: build_remote_host,
backend_type: self.class.name,
backend_id: id
)