From c2b37bc08fa61c8d7ca4ce4965c21039b993e757 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 3 Jun 2018 17:04:02 +0100 Subject: Test and fix data snapshot creation for the AWS backend --- app/jobs/govuk_guix/create_data_snapshot_job.rb | 12 +++--------- 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 -- cgit v1.2.3