Capsule sync not working with 'RestClient::BadRequest 400 Bad Request ' error

Solution Verified - Updated

Environment

Satellite 6
Capsule 6

Issue

Satellite server:
Task 'Actions::Katello::CapsuleContent::Sync' failed and stopped with 'RestClient::BadRequest 400 Bad Request' error.

Capsule server:
'/var/log/messages' generated following error log.

2020-10-07T11:50:17.302649+00:00 capsule.example.com pulp: pulp.plugins.pulp_rpm.plugins.distributors.yum.configuration:ERROR: Relative URL [ORG/Library/CV_NAME/content/dist/rhel/server/7/7.6/x86_64/sap-hana/os] for repository [CV_NAME-a47e37c1-2b1b-4768-b081-9dd69d9d8263] conflicts with existing relative URL [ORG/Library/CV_NAME/content/dist/rhel/server/7/7.6/x86_64/sap-hana/os] for repository [CV_NAME-85f50a09-8209-4381-8915-2e80f4733732]

Resolution

  • Install the pulp-admin tool on both Satellite and Capsule; for detailed instruction, please follow this link.

  • On Satellite create the list of repos and save to file

# pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2)
# curl -ks -u admin:$pulpAdminPassword https://$(hostname -f)/pulp/api/v2/repositories/ | python -m json.tool | grep '"id"' | cut -d\" -f4 > satellite.pulp.repos.txt
  • Copy the output file to the Capsule server.

  • On Capsule:

# pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2)
# curl -ks -u admin:$pulpAdminPassword https://$(hostname -f)/pulp/api/v2/repositories/ | python -m json.tool | grep '"id"' | cut -d\" -f4 > capsule.pulp.repos.txt

# for i in $(cat capsule.pulp.repos.txt); do
  if [ $(grep -c "^${i}$" satellite.pulp.repos.txt) -eq 0 ]; then
    echo "deleting repo ID ${i}"
    curl -ks -u admin:$pulpAdminPassword -X DELETE https://$(hostname -f)/pulp/api/v2/repositories/${i}/
  fi
 done
  • Wait for pulp to finish all delete tasks

  • Publish a new version of the views and sync with Capsule

For more KB articles/solutions related to Red Hat Satellite 6.x Capsule Sync Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Capsule Sync Issues

Root Cause

The currently-synced repository caused a conflict with a newer repository that was trying to be synced.

Diagnostic Steps

  • On Capsule, the server checks the '/var/log/messages' log for conflict ID.
    # more /var/log/messages | grep -i 'conflict'

  • On Satellite, take a fresh export result and look for statuses of 'Actions::Katello::CapsuleContent::Sync' tasks.
    # foreman-rake foreman_tasks:export_tasks TASK_SEARCH='' TASK_DAYS=5

SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.