Skip to content

Commit

Permalink
First pass at removing deprecated "insecure_registry" from clients
Browse files Browse the repository at this point in the history
  • Loading branch information
sychan committed Oct 31, 2018
1 parent 6bba7ff commit 93b579e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
13 changes: 3 additions & 10 deletions lib/biokbase/catalog/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,8 @@ def __init__(self, config):
self.docker_registry_host = config['docker-registry-host']
print('Docker registry host config = '+ self.docker_registry_host)

self.docker_push_allow_insecure = None # none should just set this to default?
if 'docker-push-allow-insecure' in config:
print('Docker docker-push-allow-insecure = '+ config['docker-push-allow-insecure'])
if config['docker-push-allow-insecure'].strip() == "1": # pragma: no cover
self.docker_push_allow_insecure = True;
print('WARNING!! - Docker push is set to allow insecure connections. This should never be on in production.')

print('WARNING!! Docker docker-push-allow-insecure found in configuration. This is no longer supported - use --insecure-registry on dockerd')

if 'ref-data-base' not in config: # pragma: no cover
raise ValueError('"ref-data-base" config variable must be defined to start a CatalogController!')
Expand Down Expand Up @@ -181,7 +176,7 @@ def register_repo(self, params, username, token):
# first set the dev current_release timestamp

t = threading.Thread(target=_start_registration, args=(params,registration_id,timestamp,username,self.is_admin(username),token,self.db, self.temp_dir, self.docker_base_url,
self.docker_registry_host, self.docker_push_allow_insecure, self.nms_url, self.nms_token, module_details, self.ref_data_base, self.kbase_endpoint,
self.docker_registry_host, self.nms_url, self.nms_token, module_details, self.ref_data_base, self.kbase_endpoint,
prev_dev_version))
t.start()

Expand Down Expand Up @@ -1492,10 +1487,8 @@ def get_secure_config_params(self, username, params):

# NOT PART OF CLASS CATALOG!!
def _start_registration(params,registration_id, timestamp,username,is_admin,token, db, temp_dir, docker_base_url, docker_registry_host,
docker_push_allow_insecure,
nms_url, nms_admin_token, module_details, ref_data_base, kbase_endpoint, prev_dev_version):
registrar = Registrar(params, registration_id, timestamp, username, is_admin,token, db, temp_dir, docker_base_url, docker_registry_host,
docker_push_allow_insecure,
registrar = Registrar(params, registration_id, timestamp, username, is_admin,token, db, temp_dir, docker_base_url, docker_registry_host,
nms_url, nms_admin_token, module_details, ref_data_base, kbase_endpoint, prev_dev_version)
registrar.start_registration()

9 changes: 2 additions & 7 deletions lib/biokbase/catalog/registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Registrar:
# params is passed in from the controller, should be the same as passed into the spec
# db is a reference to the Catalog DB interface (usually a MongoCatalogDBI instance)
def __init__(self, params, registration_id, timestamp, username, is_admin,token, db, temp_dir, docker_base_url,
docker_registry_host, docker_push_allow_insecure, nms_url, nms_admin_token, module_details,
docker_registry_host, nms_url, nms_admin_token, module_details,
ref_data_base, kbase_endpoint, prev_dev_version):
self.db = db
self.params = params
Expand All @@ -42,7 +42,6 @@ def __init__(self, params, registration_id, timestamp, username, is_admin,token,
self.temp_dir = temp_dir
self.docker_base_url = docker_base_url
self.docker_registry_host = docker_registry_host
self.docker_push_allow_insecure = docker_push_allow_insecure

self.nms_url = nms_url

Expand Down Expand Up @@ -564,11 +563,7 @@ def push_docker_image(self, docker_client, image_name):
#self.log(str(response_stream))

# to do: examine stream to determine success/failure of build
if self.docker_push_allow_insecure:
print("Docker push: insecure_registry: "+ str(self.docker_push_allow_insecure))
else:
print("Docker push: insecure_registry: None")
for lines in docker_client.push(image, tag=tag, stream=True, insecure_registry = self.docker_push_allow_insecure):
for lines in docker_client.push(image, tag=tag, stream=True):
for line in lines.strip().splitlines():
# example line:
#'{"status":"Pushing","progressDetail":{"current":32,"total":32},"progress":"[==================================================\\u003e] 32 B/32 B","id":"da200da4256c"}'
Expand Down
1 change: 0 additions & 1 deletion test/catalog_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def _setup_config(self):
'temp-dir':self.scratch_dir,
'docker-base-url':self.test_cfg['docker-base-url'],
'docker-registry-host':self.test_cfg['docker-registry-host'],
'docker-push-allow-insecure':self.test_cfg['docker-push-allow-insecure'],
'nms-url':self.test_cfg['nms-url'],
'nms-admin-user':self.test_cfg.get('nms-admin-user', ''),
'nms-admin-psswd':self.test_cfg.get('nms-admin-psswd', ''),
Expand Down
3 changes: 0 additions & 3 deletions test/test.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ mongodb-database = catalog-test
# Path to docker socket/host - you can leave this blank if you have the appropriate docker env variables defined
docker-base-url = unix://var/run/docker.sock

# temporary fix for travis- no longer needed
docker-push-allow-insecure = 0

# Narrative Method Store configuration. Please provide a token.
# If both are provided, the token is used.
nms-url = http://localhost:7125
Expand Down

0 comments on commit 93b579e

Please sign in to comment.