redhat-cop / openshift-toolkit

A collection of code samples to help you get started with OpenShift
Apache License 2.0
232 stars 150 forks source link

Registry sync script does not work with web proxies #4

Closed etsauer closed 6 years ago

etsauer commented 7 years ago

When attempting to run this script via an http/s proxy, the script bombs at:

./docker-registry-sync.py --from=registry.access.redhat.com --to=10.138.211.99:5000 --file=./docker_tags.json --openshift-version=3.4
Traceback (most recent call last):
  File "./docker-registry-sync.py", line 159, in <module>
    get_latest_tag_from_api(retrieve_v_tags_from_redhat_list, latest_tag_list, failed_images)
  File "./docker-registry-sync.py", line 75, in get_latest_tag_from_api
    image_tag_dictionary = json.loads(redhat_registry.read())
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

According to http://stackoverflow.com/questions/3168171/how-can-i-open-a-website-with-urllib-via-proxy-in-python , urllib.urlopen() should use proxy environment variables it finds. However this doesn't seem to be the case as:

export http_proxy=blah
export https_proxy=blah

Doesn't appear to change the behavior.

@stratus-ss @redhat-cop/cant-contain-this

stratus-ss commented 7 years ago

This can be closed because PR https://github.com/redhat-cop/openshift-toolkit/pull/6 has been merged