Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use web app user in logs and process management #208

Merged
merged 3 commits into from
Nov 7, 2024
Merged

Conversation

TinyMarsh
Copy link
Contributor

@TinyMarsh TinyMarsh commented Nov 5, 2024

Description

This PR adresses #111 by passing the web app username - from the request object available in views - to function signatures where the username is relevant to the function i.e. logs and process management.

Fixes #111

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass (eg. python -m pytest)
  • The documentation builds and looks OK (eg. python -m sphinx -b html docs docs/build)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 68.18182% with 7 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@ee2a2eb). Learn more about missing BASE report.

Files with missing lines Patch % Lines
process_manager/process_manager_interface.py 61.11% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #208   +/-   ##
=======================================
  Coverage        ?   82.00%           
=======================================
  Files           ?       31           
  Lines           ?      400           
  Branches        ?        0           
=======================================
  Hits            ?      328           
  Misses          ?       72           
  Partials        ?        0           

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

Copy link
Contributor

@cc-a cc-a left a comment

Choose a reason for hiding this comment

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

Looks good. One tiny tweak so that our dummy processes can keep running.

@@ -57,5 +57,5 @@ def form_valid(self, form: BootProcessForm) -> HttpResponse:
Returns:
A redirect to the index page.
"""
boot_process("root", form.cleaned_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comment on the boot_process function.



async def _boot_process(user: str, data: dict[str, str | int]) -> None:
pmd = get_process_manager_driver()
pmd = get_process_manager_driver(user)
async for item in pmd.dummy_boot(user=user, **data):
Copy link
Contributor

Choose a reason for hiding this comment

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

One catch is that for any of the dummy processes to run in our docker setup they need to be owned by root, i.e. the user argument to pmd.dummy_boot needs to be "root". This is something I need to document properly in #107. We still want the Django user to be named in the kafka messages however so let's move the hard coding of "root" into this function. The hard-coding is ok as this dummy boot function is only a nicety for development (something else we need to document).

Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

Keeping Chris comment aside, this looks good to me!

@TinyMarsh TinyMarsh requested a review from cc-a November 6, 2024 16:26
Copy link
Contributor

@AdrianDAlessandro AdrianDAlessandro left a comment

Choose a reason for hiding this comment

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

LGTM!

"""Get a ProcessManagerDriver instance."""
token = create_dummy_token_from_uname()
token = Token(token=f"{username}-token", user_name=username)
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this actually works with their authentication system

Copy link
Contributor

Choose a reason for hiding this comment

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

For the moment they're using a DummyAuthoriser that doesn't check the token.

Copy link
Contributor

@jamesturner246 jamesturner246 left a comment

Choose a reason for hiding this comment

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

Looking good 👍

@cc-a cc-a enabled auto-merge November 7, 2024 16:24
@cc-a cc-a merged commit 37e9449 into main Nov 7, 2024
4 checks passed
@cc-a cc-a deleted the web-app-username branch November 7, 2024 16:39
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.

Use logged in web app user in drunc auth token
6 participants