From 05a605aedbcb1f85668805201d5bb2ba5fe51134 Mon Sep 17 00:00:00 2001 From: Vivian Rook Date: Mon, 23 Oct 2023 09:24:02 -0400 Subject: [PATCH] Mount file rather than dir --- helm-quarry/templates/web_deployment.yaml | 3 ++- helm-quarry/templates/worker_deployment.yaml | 3 ++- quarry/web/app.py | 18 ++++++++------- quarry/web/killer.py | 17 +++++---------- quarry/web/worker.py | 23 +++++++++----------- 5 files changed, 30 insertions(+), 34 deletions(-) diff --git a/helm-quarry/templates/web_deployment.yaml b/helm-quarry/templates/web_deployment.yaml index b03a7a5..780071c 100644 --- a/helm-quarry/templates/web_deployment.yaml +++ b/helm-quarry/templates/web_deployment.yaml @@ -24,7 +24,8 @@ spec: - mountPath: "/results" name: results - name: config - mountPath: /config/ + mountPath: /app/quarry/config.yaml + subPath: config.yaml resources: requests: memory: {{ .Values.web.memory }} diff --git a/helm-quarry/templates/worker_deployment.yaml b/helm-quarry/templates/worker_deployment.yaml index 9d9155b..f2c7e40 100644 --- a/helm-quarry/templates/worker_deployment.yaml +++ b/helm-quarry/templates/worker_deployment.yaml @@ -24,7 +24,8 @@ spec: - mountPath: "/results" name: results - name: config - mountPath: /config/ + mountPath: /app/quarry/config.yaml + subPath: config.yaml resources: requests: memory: {{ .Values.worker.memory }} diff --git a/quarry/web/app.py b/quarry/web/app.py index fbd69e0..db64c93 100644 --- a/quarry/web/app.py +++ b/quarry/web/app.py @@ -24,14 +24,16 @@ def get_config(): conf = {} - if os.path.isfile("/config/config.yaml"): - # k8s - config_path = "/config/config.yaml" - elif os.path.isfile("../config.yaml"): - # VM - config_path = "../config.yaml" - - conf.update(yaml.safe_load(open(os.path.join(__dir__, config_path)))) + conf.update( + yaml.safe_load(open(os.path.join(__dir__, "../default_config.yaml"))) + ) + try: + conf.update( + yaml.safe_load(open(os.path.join(__dir__, "../config.yaml"))) + ) + except IOError: + # Is ok if we can't load config.yaml + pass return conf diff --git a/quarry/web/killer.py b/quarry/web/killer.py index 54137c7..248879a 100755 --- a/quarry/web/killer.py +++ b/quarry/web/killer.py @@ -6,17 +6,12 @@ from connections import Connections __dir__ = os.path.dirname(__file__) -if os.path.isfile("/config/config.yaml"): - # k8s - config_path = "/config/config.yaml" -elif os.path.isfile("../config.yaml"): - # VM - config_path = "../config.yaml" -else: - # test - config_path = "../default_config.yaml" - -config = yaml.safe_load(open(os.path.join(__dir__, config_path))) +config = yaml.safe_load(open(os.path.join(__dir__, "../default_config.yaml"))) +try: + config.update(yaml.safe_load(open(os.path.join(__dir__, "../config.yaml")))) +except IOError: + # is ok if we do not have config.yaml + pass logging.basicConfig( filename=config["KILLER_LOG_PATH"], diff --git a/quarry/web/worker.py b/quarry/web/worker.py index 66e9f16..871384e 100644 --- a/quarry/web/worker.py +++ b/quarry/web/worker.py @@ -22,19 +22,16 @@ celery_log = get_task_logger(__name__) celery = Celery("quarry.web.worker") - -if os.path.isfile("/config/config.yaml"): - # k8s - config_path = "/config/config.yaml" -elif os.path.isfile("../config.yaml"): - # VM - config_path = "../config.yaml" -else: - # for pytest - config_path = "../default_config.yaml" - -celery.conf.update(yaml.safe_load(open(os.path.join(__dir__, config_path)))) - +celery.conf.update( + yaml.safe_load(open(os.path.join(__dir__, "../default_config.yaml"))) +) +try: + celery.conf.update( + yaml.safe_load(open(os.path.join(__dir__, "../config.yaml"))) + ) +except IOError: + # Is ok if we can not load config.yaml + pass conn = None