Skip to content

Commit 7ae4482

Browse files
authored
Clean removal of prometheus db files on shutdown (#2308)
* Cleanly remove metrics db files created by prometheus Until now, multiple workers were competing on deleting the files, and some were inevitably failing with "FileNotFound" errors. * Fix deprecated poetry usage in runtimes tox.ini
1 parent 2e866b1 commit 7ae4482

File tree

10 files changed

+18
-10
lines changed

10 files changed

+18
-10
lines changed

mlserver/metrics/prometheus.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ def configure_metrics(settings: Settings):
3131
values.ValueClass = values.get_value_class()
3232

3333

34+
async def try_remove(filename: str):
35+
try:
36+
await remove(filename)
37+
except FileNotFoundError:
38+
pass
39+
40+
3441
async def stop_metrics(settings: Settings, pid: int):
3542
if not settings.parallel_workers:
3643
return
3744

3845
mark_process_dead(pid)
3946
pattern = os.path.join(settings.metrics_dir, f"*_{pid}.db")
4047
matching_files = glob.glob(pattern)
41-
await asyncio.gather(*[remove(f) for f in matching_files])
48+
if len(matching_files) > 0:
49+
await asyncio.gather(*[try_remove(f) for f in matching_files])
4250

4351

4452
class PrometheusEndpoint:

runtimes/alibi-detect/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setenv =
66
TF_USE_LEGACY_KERAS = 1
77
allowlist_externals = poetry
88
commands_pre =
9-
poetry install --sync --no-root
9+
poetry sync --no-root
1010
poetry install -C {toxinidir}/../../
1111
commands =
1212
python -m pytest {posargs} -n auto \

runtimes/alibi-explain/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setenv =
66
TF_USE_LEGACY_KERAS = 1
77
allowlist_externals = poetry
88
commands_pre =
9-
poetry install --sync --no-root
9+
poetry sync --no-root
1010
poetry install -C {toxinidir}/../../
1111
commands =
1212
python -m pytest {posargs} -n auto \

runtimes/catboost/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/huggingface/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/lightgbm/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/mlflow/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/mllib/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/sklearn/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

runtimes/xgboost/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ isolated_build = true
44
[testenv]
55
allowlist_externals = poetry
66
commands_pre =
7-
poetry install --sync --no-root
7+
poetry sync --no-root
88
poetry install -C {toxinidir}/../../
99
commands =
1010
python -m pytest {posargs} -n auto \

0 commit comments

Comments
 (0)