diff options
author | Christopher Baines <mail@cbaines.net> | 2018-06-03 17:04:02 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2018-06-03 17:04:02 +0100 |
commit | c2b37bc08fa61c8d7ca4ce4965c21039b993e757 (patch) | |
tree | 23b5d2f048c6ed4e713d9281b78e5e2e7b45784f /app/jobs | |
parent | babfdfcb17908f61f931b8f44b97622948be602a (diff) | |
download | govuk-mini-environment-admin-c2b37bc08fa61c8d7ca4ce4965c21039b993e757.tar govuk-mini-environment-admin-c2b37bc08fa61c8d7ca4ce4965c21039b993e757.tar.gz |
Test and fix data snapshot creation for the AWS backend
Diffstat (limited to 'app/jobs')
-rw-r--r-- | app/jobs/govuk_guix/create_data_snapshot_job.rb | 12 | ||||
-rw-r--r-- | app/jobs/govuk_guix/job.rb | 6 |
2 files changed, 8 insertions, 10 deletions
diff --git a/app/jobs/govuk_guix/create_data_snapshot_job.rb b/app/jobs/govuk_guix/create_data_snapshot_job.rb index d2a757d..f2075c7 100644 --- a/app/jobs/govuk_guix/create_data_snapshot_job.rb +++ b/app/jobs/govuk_guix/create_data_snapshot_job.rb @@ -43,7 +43,7 @@ class GovukGuix::CreateDataSnapshotJob < GovukGuix::Job backend_type = options[:backend_type] backend_id = options[:backend_id] if backend_type - backend = Backend.find_by_type_and_id(backend_type, backend_id) + backend = Backends.find_by_type_and_id(backend_type, backend_id) data_snapshot_fields[:backend] = backend end @@ -62,8 +62,6 @@ class GovukGuix::CreateDataSnapshotJob < GovukGuix::Job end if remote_host - ssh_command = ['ssh', remote_host] - # Copy the revision to the remote host, to ensure it's available # there run_command( @@ -72,17 +70,15 @@ class GovukGuix::CreateDataSnapshotJob < GovukGuix::Job "--to=#{remote_host}", revision.store_path ) - else - ssh_command = [] end output = run_command( - *ssh_command, "#{revision.store_path}/bin/govuk", 'data', 'build-snapshot', # TODO: Just use a couple of small databases for initial testing - *%w(content-tagger contacts-admin) + *%w(content-tagger contacts-admin), + run_remotely_on_host: remote_host ) build_output = output.last.strip @@ -94,8 +90,6 @@ class GovukGuix::CreateDataSnapshotJob < GovukGuix::Job from_remote_host: remote_host ) - puts data_snapshot_fields.keys - GovukGuix::DataSnapshot.create!(data_snapshot_fields) end end diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb index a48ce02..f296edf 100644 --- a/app/jobs/govuk_guix/job.rb +++ b/app/jobs/govuk_guix/job.rb @@ -68,7 +68,11 @@ class GovukGuix::Job < Que::Job stdout_str, status = Open3.capture2(*command) - puts "STATUS: #{status}" + unless status.exitstatus == 0 + logger.error(self.class) { "failed, exit status #{exit_status}" } + + raise "Running #{command.join(' ')} failed:\n\n#{output.join}\n" + end stdout_str else |