Project

Profile

Help

Issue #2071

closed

Creating yum distributor without https, http keys in config crashes

Added by rmcgover almost 8 years ago. Updated almost 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Master
Platform Release:
2.11.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

Description

If I try to create a repository with yum distributor like this:

curl -k -u admin:admin -d '{"importer_type_id": "yum_importer", "importer_config": {}, "id": "my-test-repo", "distributors": [{"distributor_id": "yum_distributor", "distributor_type_id": "yum_distributor", "distributor_config": {"checksum_type": "sha1", "relative_rpm_path": "Packages", "relative_url": "content/my-test-repo"}, "auto_publish": false}]}' -v https://172.17.0.5:443/pulp/api/v2/repositories/

Pulp will respond with a 500 Internal Server Error with backtrace like this:

pulp.server.webservices.middleware.exception:ERROR: (903-15616)   File "/home/vagrant/devel/pulp/server/pulp/server/controllers/repository.py", line 425, in create_repo
pulp.server.webservices.middleware.exception:ERROR: (903-15616)     dist_controller.add_distributor(repo_id, type_id, plugin_config, auto_publish, dist_id)
pulp.server.webservices.middleware.exception:ERROR: (903-15616)   File "/home/vagrant/devel/pulp/server/pulp/server/controllers/distributor.py", line 67, in add_distributor
pulp.server.webservices.middleware.exception:ERROR: (903-15616)     result = distributor_instance.validate_config(transfer_repo, call_config, config_conduit)
pulp.server.webservices.middleware.exception:ERROR: (903-15616)   File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/distributors/yum/distributor.py", line 85, in validate_config
pulp.server.webservices.middleware.exception:ERROR: (903-15616)     return configuration.validate_config(repo, config, config_conduit)
pulp.server.webservices.middleware.exception:ERROR: (903-15616)   File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/distributors/yum/configuration.py", line 92, in validate_config
pulp.server.webservices.middleware.exception:ERROR: (903-15616)     if config['https'] is False and config['http'] is False:
pulp.server.webservices.middleware.exception:ERROR: (903-15616) KeyError: 'https'

I think there are two problems here:

1. If http, https are meant to be mandatory config keys in the request, then the server should provide a meaningful error message when they're not provided, rather than giving a 500 response.

2. It seems like these weren't mandatory in the request prior to commit 23d9c0934bac so this was probably an unintentional API break. We have scripts against our pulp server which expect to be able to create yum repos without providing http, https in the config (and we use yum_distributor.json on the server to control the config of these keys).

Tested with pulp f903da544d6713d782cd8d5de94ae4af5a2cba4b, pulp_rpm 7f43d66a0bd082aa43878c1e655a94cca18ff5fd.

Also available in: Atom PDF