Skip to content

Commit

Permalink
Mount file rather than dir
Browse files Browse the repository at this point in the history
  • Loading branch information
vivian-rook committed Oct 23, 2023
1 parent 4116b89 commit 05a605a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
3 changes: 2 additions & 1 deletion helm-quarry/templates/web_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion helm-quarry/templates/worker_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
18 changes: 10 additions & 8 deletions quarry/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 6 additions & 11 deletions quarry/web/killer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
23 changes: 10 additions & 13 deletions quarry/web/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 05a605a

Please sign in to comment.