diff --git a/app/lib/katello/util/cdn_var_substitutor.rb b/app/lib/katello/util/cdn_var_substitutor.rb index 617c3fb8018..ba46a564762 100644 --- a/app/lib/katello/util/cdn_var_substitutor.rb +++ b/app/lib/katello/util/cdn_var_substitutor.rb @@ -68,7 +68,9 @@ def find_substitutions(paths_with_substitutions) futures.each do |future| resolved << future.value - Rails.logger.error("Failed at scanning for repository: #{future.reason}") if future.rejected? + if future.rejected? + fail Errors::CdnSubstitutionError, "Failed at scanning for repository: #{future.reason}" + end end end diff --git a/test/actions/katello/repository_set_test.rb b/test/actions/katello/repository_set_test.rb index cb7bc6b3400..707caf6f92e 100644 --- a/test/actions/katello/repository_set_test.rb +++ b/test/actions/katello/repository_set_test.rb @@ -125,6 +125,23 @@ class ScanCdnTest < TestBase assert_equal action.output[:results].first[:enabled], true end + it 'raises CdnSubstitutionError when substitute_vars fails' do + planned_action = plan_action action, product, content.id + + error_message = "Failed at scanning for repository: Connection refused - connect(2) for \"cdn.redhat.com\" port 443" + + Katello::Util::CdnVarSubstitutor.any_instance.stubs(:substitute_vars).raises(Katello::Errors::CdnSubstitutionError, error_message) + + assert_raises_with_message Katello::Errors::CdnSubstitutionError, error_message do + run_action planned_action do |run_action| + substitutor = stub(:cdn_var_substitutor) + substitutor.stubs(:substitute_vars).raises(Katello::Errors::CdnSubstitutionError, error_message) + run_action.stubs(content: content) + run_action.stubs(cdn_var_substitutor: substitutor) + end + end + end + def simulate_run planned_action = plan_action action, product, content.id diff --git a/test/lib/util/cdn_var_subsitutor_test.rb b/test/lib/util/cdn_var_subsitutor_test.rb index 5b5d2126836..e92c8d50afc 100644 --- a/test/lib/util/cdn_var_subsitutor_test.rb +++ b/test/lib/util/cdn_var_subsitutor_test.rb @@ -116,6 +116,18 @@ def check_validating_subscriptions(content, substitutions, error_message) cdn_var.validate_substitutions(content, substitutions) end end + + def test_substitute_vars_raises_error + cdn_var = CdnVarSubstitutor.new(@resource) + + path = '/content/dist/rhel/server/5/$releasever/$basearch/os' + + cdn_var.stubs(:resolve_path).raises(StandardError.new("Connection refused - connect(2) for \"cdn.redhat.com\" port 443")) + + assert_raises(Errors::CdnSubstitutionError, "Failed at scanning for repository: Connection refused - connect(2) for \"cdn.redhat.com\" port 443") do + cdn_var.substitute_vars(path) + end + end end end end diff --git a/webpack/redux/actions/RedHatRepositories/repositorySetRepositories.js b/webpack/redux/actions/RedHatRepositories/repositorySetRepositories.js index de11fda4ddc..b16aee6fe7e 100644 --- a/webpack/redux/actions/RedHatRepositories/repositorySetRepositories.js +++ b/webpack/redux/actions/RedHatRepositories/repositorySetRepositories.js @@ -68,13 +68,8 @@ const loadRepositorySetRepos = (contentId, productId) => async (dispatch) => { productId, results: data.results, }); - } catch (response) { - const error = response && response.data && response.data.error; - return dispatch({ - type: REPOSITORY_SET_REPOSITORIES_FAILURE, - contentId, - error, - }); + } catch (error) { + return dispatch(apiError(REPOSITORY_SET_REPOSITORIES_FAILURE, error, contentId)); } }; diff --git a/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js b/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js index 7c8068c588b..0630da21172 100644 --- a/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js +++ b/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js @@ -81,7 +81,7 @@ export default (state = initialState, action) => { }); case REPOSITORY_SET_REPOSITORIES_FAILURE: - return state.set(action.contentId, { + return state.set(action.payload.contentId, { loading: false, repositories: [], error: action.error,