-
Notifications
You must be signed in to change notification settings - Fork 296
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
[WIP] Set team on Alert Group based on route #3459 #5320
base: dev
Are you sure you want to change the base?
Conversation
|
6238c72
to
03c29f8
Compare
|
||
alert_group_2 = make_alert_group(alert_receive_channel_2) | ||
make_alert(alert_group=alert_group_2, raw_request_data=alert_raw_request_data) | ||
alert_group_0 = Alert.create( |
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 had to switch to Alert.create
here so that the team gets assigned correctly and as expected for the test to work.
@@ -31,6 +31,13 @@ | |||
from apps.alerts.models import AlertReceiveChannel | |||
from apps.user_management.models import Organization | |||
|
|||
def _get_teams_for_cache(organization): |
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.
A helper that provides list of teams + the no_team team
if integration_response_time_metrics: | ||
integration_response_time_metrics["team_name"] = team_data["team_name"] | ||
|
||
cache.set(metric_alert_groups_total_key, metric_alert_groups_total, timeout=metrics_cache_timeout) | ||
cache.set(metric_alert_groups_response_time_key, metric_alert_groups_response_time, timeout=metrics_cache_timeout) | ||
|
||
|
||
def metrics_update_alert_groups_state_cache(states_diff: dict, organization_id: int): | ||
def metrics_update_alert_groups_state_cache(states_diff: dict, organization: "Organization"): |
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.
moved to passing organization through so we can iterate over the teams easier
@@ -58,7 +58,7 @@ def test_calculate_and_cache_metrics_task( | |||
metric_alert_groups_response_time_key = get_metric_alert_groups_response_time_key(organization.id) | |||
|
|||
expected_result_metric_alert_groups_total = { | |||
alert_receive_channel_1.id: { | |||
(alert_receive_channel_1.id, "no_team"): { |
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.
Since moving to an index of channel + team many of the tests needed updating to reflect this
monkeypatch.setattr(cache, "get", metrics_cache) | ||
|
||
# check cache update on update integration's team | ||
alert_receive_channel.team = team | ||
# alert_receive_channel.team = team |
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 think this test is really needed or valid any more as we'll have a metric per integration per team so updating the team on a alert_receive_channel shouldn't really do anything.
@property | ||
def available_teams_lookup_args(self): | ||
|
||
def available_teams_lookup_args_with_field(self, field=TEAM_LOOKUP): |
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 wasn't sure the best way to approach this. When calculating the allowed teams in the alertgroup filter we need to both access the filters for the team
and teams
so being able to move this to a method was the easiest approach I could think of.
@@ -1540,7 +1540,7 @@ export interface components { | |||
readonly status: number; | |||
/** @description Generate a link for AlertGroup to declare Grafana Incident by click */ | |||
readonly declare_incident_link: string; | |||
team: string | null; | |||
teams: components['schemas']['FastTeam'][]; |
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 was manually added as the autogeneration for me seemed to change a lot!
293e5e3
to
3a30cee
Compare
3a30cee
to
fec671b
Compare
What this PR does
Which issue(s) this PR closes
Related to [issue link here]
Checklist
pr:no public docs
PR label added if not required)release:
). These labels dictate how your PR willshow up in the autogenerated release notes.