From 93b579e960afe319cdd40e6c0857414a982825c6 Mon Sep 17 00:00:00 2001 From: Steve Chan Date: Wed, 31 Oct 2018 11:44:23 -0700 Subject: [PATCH] First pass at removing deprecated "insecure_registry" from clients --- lib/biokbase/catalog/controller.py | 13 +++---------- lib/biokbase/catalog/registrar.py | 9 ++------- test/catalog_test_util.py | 1 - test/test.cfg.example | 3 --- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index 180d107..7f63477 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -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!') @@ -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() @@ -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() diff --git a/lib/biokbase/catalog/registrar.py b/lib/biokbase/catalog/registrar.py index c4e810f..e96d6ba 100644 --- a/lib/biokbase/catalog/registrar.py +++ b/lib/biokbase/catalog/registrar.py @@ -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 @@ -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 @@ -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"}' diff --git a/test/catalog_test_util.py b/test/catalog_test_util.py index 986db74..a79be3d 100644 --- a/test/catalog_test_util.py +++ b/test/catalog_test_util.py @@ -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', ''), diff --git a/test/test.cfg.example b/test/test.cfg.example index 6cc9cfb..a08e84f 100644 --- a/test/test.cfg.example +++ b/test/test.cfg.example @@ -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