Skip to content

Comments

fix: prometheus multproc dir permissions error#118

Closed
matthewelwell wants to merge 19 commits intomainfrom
fix/os-dir-permissions
Closed

fix: prometheus multproc dir permissions error#118
matthewelwell wants to merge 19 commits intomainfrom
fix/os-dir-permissions

Conversation

@matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Nov 7, 2025

See CI failures / conversations in this PR in the core repository for more information on why this is necessary.

Further context can also be found here.

@matthewelwell matthewelwell requested a review from a team as a code owner November 7, 2025 18:35
@matthewelwell matthewelwell requested review from gagantrivedi and removed request for a team November 7, 2025 18:35
@matthewelwell matthewelwell marked this pull request as draft November 7, 2025 18:35
@matthewelwell matthewelwell removed the request for review from gagantrivedi November 7, 2025 18:36
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.59%. Comparing base (4897567) to head (6e741bc).

Files with missing lines Patch % Lines
src/common/prometheus/multiprocessing.py 88.23% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (92.85%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
- Coverage   94.63%   94.59%   -0.05%     
==========================================
  Files          77       78       +1     
  Lines        2459     2477      +18     
==========================================
+ Hits         2327     2343      +16     
- Misses        132      134       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matthewelwell matthewelwell changed the title fix: force directory permissions fix: prometheus multproc dir permissions error Nov 10, 2025
}

timer.labels(**labels) # type: ignore[no-untyped-call]
timer.labels(**labels)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know why mypy pulled me up on this in this PR given that I've not touched this file, or any related code...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that this code can't live in utils itself, but see comment in __init__.py for reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the more logical answer here would be to move Histogram out of utils and keep this function in there?

Comment on lines -1 to +16
from common.prometheus.utils import Histogram
from typing import Any

__all__ = ("Histogram",)
_utils = ("Histogram",)


def __getattr__(name: str) -> Any:
"""
Since utils imports django.conf.settings, we lazy load any objects that
we want to import to prevent django.core.exceptions.ImproperlyConfigured
due to settings not being configured.
"""
if name in _utils:
from common.prometheus import utils

return getattr(utils, name)
raise AttributeError(name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty ugly, but might actually save us pain in the future, as well as fixing the pain I experienced. There are a couple of alternatives:

  1. In utils.py, use a factory instead of subclassing Histogram, and perform a local import of django.conf.settings
  2. Take a slightly different approach and just split up the logical pieces of prepare_prom_multiproc_dir into generic functions where necessary like clear_sub_dirs(dir: str), and just call it step by step in ensure_cli_env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented option 2 in #120

@matthewelwell matthewelwell requested a review from khvn26 November 10, 2025 19:26
@matthewelwell matthewelwell marked this pull request as ready for review November 10, 2025 19:40
@matthewelwell
Copy link
Contributor Author

Superseded by #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants