-
Notifications
You must be signed in to change notification settings - Fork 391
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
fix: audit log integrations for versioned environments #4876
Conversation
… versions being published
…dd better integration with object type
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Docker builds report
|
Uffizzi Ephemeral Environment Deploying☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/4876 ⚙️ Updating now by workflow run 12184720423. What is Uffizzi? Learn more! |
@@ -61,6 +61,7 @@ def signal_wrapper(sender, instance, **kwargs): | |||
RelatedObjectType.FEATURE.name, | |||
RelatedObjectType.FEATURE_STATE.name, | |||
RelatedObjectType.SEGMENT.name, | |||
RelatedObjectType.EF_VERSION.name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially the only thing that needed to change to fix the issue. The rest of the changes are related to the tests, improving the integration for EF versions, or refactoring.
grafana_config = GrafanaProjectConfiguration(base_url="test.com", api_key="test") | ||
project.grafana_config = grafana_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having added the logic to prevent the postpone decorator from spawning unmanaged threads we need to move this here to prevent the generation of the audit log record itself from triggering an external request to Grafana (or Dynatrace as the case may be below).
mocker.patch( | ||
"integrations.dynatrace.dynatrace.get_audited_instance_from_audit_log_record", | ||
return_value=related_object, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love having to introduce a mock here, but this test is all a little bit superficial anyway. I'd rather replace all of these parameterised tests with more end-to-end style tests like the new one I added for EF version here.
api/util/util.py
Outdated
t = Thread(target=function, args=args, kwargs=kwargs) | ||
t.daemon = True | ||
t.start() | ||
if settings.ENABLE_POSTPONE_DECORATOR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somewhat ugly, and I'd rather remove the postpone
decorator entirely to rely instead upon the run_in_thread
method exposed by registered tasks. But, I'd still then want to be able to disable the threading in a test environment because it's all a bit difficult to test anyway (and it's how we sometimes end up with errors in the logs, but not in the tests).
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4876 +/- ##
=======================================
Coverage 97.38% 97.38%
=======================================
Files 1189 1189
Lines 41420 41453 +33
=======================================
+ Hits 40338 40371 +33
Misses 1082 1082 ☔ View full report in Codecov by Sentry. |
…sioning # Conflicts: # api/app/settings/test.py
Changes
Fixes audit log based integrations when running in a versioned environment.
How did you test this code?
Updated existing tests.