Skip to content

Commit

Permalink
Fixes #27070 - Proxy feature detection in backup
Browse files Browse the repository at this point in the history
This patch fixes backups failing due to error
on Foreman proxy feature detection. The features were detected
in a phase when proxy service is down and the call failed.
The features in proxy are now cached and the cache is populated
when the proxy is up.

As a bonus we have new procedure printing the features:
$ foreman-maintain advanced produre run foreman-proxy-features
mbacovsky authored and kgaikwad committed Jun 19, 2019
1 parent a018d10 commit 8a29785
Showing 3 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion definitions/features/foreman_proxy.rb
Original file line number Diff line number Diff line change
@@ -33,7 +33,14 @@ def services

def features
# TODO: handle failures
run_curl_cmd("#{curl_cmd}/features").result
@features ||= run_curl_cmd("#{curl_cmd}/features").result
@features = [] if @features.is_a?(String)
@features
end

def refresh_features
@features = nil
features
end

def internal?
14 changes: 14 additions & 0 deletions definitions/procedures/foreman_proxy/features.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Procedures::ForemanProxy
class Features < ForemanMaintain::Procedure
metadata do
param :load_only, 'Do not print the features', :default => false
description 'Detect features available in the local proxy'
for_feature :foreman_proxy
end

def run
features = feature(:foreman_proxy).refresh_features
puts features.join(', ') unless @load_only
end
end
end
2 changes: 2 additions & 0 deletions definitions/scenarios/backup.rb
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@ def check_valid_startegy

def add_offline_backup_steps
include_dumps if include_db_dumps?
add_step_with_context(Procedures::ForemanProxy::Features, :load_only => true)
add_steps_with_context(
find_procedures(:maintenance_mode_on),
Procedures::Service::Stop,
@@ -157,6 +158,7 @@ def include_dumps
# rubocop:disable Metrics/MethodLength
def add_snapshot_backup_steps
include_dumps if include_db_dumps?
add_step_with_context(Procedures::ForemanProxy::Features, :load_only => true)
add_steps_with_context(
Procedures::Backup::Snapshot::PrepareMount,
find_procedures(:maintenance_mode_on),

0 comments on commit 8a29785

Please sign in to comment.