Skip to content

Commit

Permalink
Taught unsafe-advisory-merge error to point out ALLOW-UNSAFE cfg.
Browse files Browse the repository at this point in the history
closes #8616
  • Loading branch information
ggainey committed May 18, 2021
1 parent 671bff8 commit 1e52fd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES/8616.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pointed advisory-merge-error message to the config-option that allows unsafe merges.
8 changes: 6 additions & 2 deletions pulp_rpm/app/advisory.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def _do_merge():
"but different and intersecting package lists, "
"and neither package list is a proper subset of the other. "
"At least one of the advisories is wrong. "
"Advisory id: {}"
"To allow this behavior, set "
"ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION = True (q.v.) "
"in your configuration. Advisory id: {}"
).format(previous_advisory.id)
)
elif previous_pkglist == added_pkglist:
Expand All @@ -206,7 +208,9 @@ def _do_merge():
"It is likely that they are from two different incompatible remote "
"repositories. E.g. RHELX-repo and RHELY-debuginfo repo. "
"Ensure that you are adding content for the compatible repositories. "
"Advisory id: {}"
"To allow this behavior, set "
"ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION = True (q.v.) "
"in your configuration. Advisory id: {}"
).format(previous_advisory.id)
)
elif not same_dates and pkgs_intersection:
Expand Down
1 change: 1 addition & 0 deletions pulp_rpm/tests/functional/api/test_advisory_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ def test_merging(self):
self.assertTrue(
"neither package list is a proper subset of the other" in str(ctx.exception)
)
self.assertTrue("ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION" in str(ctx.exception))

# Fourth upload, intersecting pkglists, expecting three pkgs
upload = self.do_test_json(advisory=self.CAMEL_BEAR_DOG_JSON, repository=self.repo)
Expand Down
13 changes: 8 additions & 5 deletions pulp_rpm/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,14 @@ def test_sync_advisory_diff_repo(self):

task_result = exc.exception.task.to_dict()
error_msg = (
"Incoming and existing advisories have the same id but different "
"timestamps and non-intersecting package lists. It is likely that they are from "
"two different incompatible remote repositories. E.g. RHELX-repo and "
"RHELY-debuginfo repo. Ensure that you are adding content for the compatible "
"repositories. Advisory id: {}".format(RPM_ADVISORY_TEST_ID)
"Incoming and existing advisories have the same id but "
"different timestamps and non-intersecting package lists. "
"It is likely that they are from two different incompatible remote "
"repositories. E.g. RHELX-repo and RHELY-debuginfo repo. "
"Ensure that you are adding content for the compatible repositories. "
"To allow this behavior, set "
"ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION = True (q.v.) "
"in your configuration. Advisory id: {}".format(RPM_ADVISORY_TEST_ID)
)
self.assertIn(error_msg, task_result["error"]["description"])

Expand Down

0 comments on commit 1e52fd9

Please sign in to comment.