-
Notifications
You must be signed in to change notification settings - Fork 246
Make it possible to disable paging for check_autoscaler_max_instances (or any other specific alert generated by Paasta.) #4108
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
Draft
EvanKrall
wants to merge
4
commits into
master
Choose a base branch
from
u/krall/check_specific_overrides
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6afa4fe
Update .tox/py38-linux references to .tox/py310-linux since we upgrad…
EvanKrall 83fd129
Add check_overrides to monitoring.yaml / monitoring section in eks.ya…
EvanKrall 2dbaa2b
Improve tip from check_autoscaler_max_instances. Make sure that the s…
EvanKrall cd3dc5e
wip
EvanKrall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,11 @@ async def check_max_instances( | |
| instance_type_class: Type[KubernetesDeploymentConfig], | ||
| system_paasta_config: SystemPaastaConfig, | ||
| dry_run: bool = False, | ||
| ): | ||
| ) -> None: | ||
| page_default = ( | ||
| system_paasta_config.get_check_autoscaler_max_instances_page_default() | ||
| ) | ||
|
|
||
| kube_client = KubeClient() | ||
| for service in list_services(soa_dir=soa_dir): | ||
| service_config = PaastaServiceConfigLoader(service=service, soa_dir=soa_dir) | ||
|
|
@@ -86,6 +90,10 @@ async def check_max_instances( | |
| ) | ||
| continue | ||
|
|
||
| max_instances_suggestion = "" | ||
| alert_threshold_suggestion = "" | ||
| disable_paging_suggestion = "" | ||
|
Comment on lines
+93
to
+95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it'd be nice to refactor things to not need to ""-init these, but it's not a big deal imo |
||
|
|
||
| if ( | ||
| autoscaling_status["min_instances"] | ||
| == autoscaling_status["max_instances"] | ||
|
|
@@ -99,6 +107,11 @@ async def check_max_instances( | |
| autoscaling_status["desired_replicas"] | ||
| >= autoscaling_status["max_instances"] | ||
| ): | ||
| max_instances_suggestion = f"\nYou may want to bump max_instances to at least {autoscaling_status['desired_replicas']}." | ||
| alert_threshold_suggestion = ( | ||
| "\nTo make this alert quieter, adjust" | ||
| " autoscaling.metrics_providers[n].max_instances_alert_threshold in yelpsoa-configs." | ||
| ) | ||
|
|
||
| metrics_provider_configs = job_config.get_autoscaling_params()[ | ||
| "metrics_providers" | ||
|
|
@@ -164,20 +177,38 @@ async def check_max_instances( | |
| output = f"{service}.{instance} is below max_instances." | ||
|
|
||
| monitoring_overrides = job_config.get_monitoring() | ||
| monitoring_overrides.update( | ||
| { | ||
| "page": False, # TODO: remove this line once this alert has been deployed for a little while. | ||
| "runbook": "y/check-autoscaler-max-instances", | ||
| "realert_every": 60, # The check runs once a minute, so this would realert every hour. | ||
| "tip": ( | ||
| "The autoscaler wants to scale up to handle additional load" | ||
| " because your service is overloaded, but cannot scale any" | ||
| " higher because of max_instances. You may want to bump" | ||
| " max_instances. To make this alert quieter, adjust" | ||
| " autoscaling.metrics_providers[n].max_instances_alert_threshold in yelpsoa-configs." | ||
| ), | ||
| } | ||
|
|
||
| disable_paging_suggestion = "\n".join( | ||
| [ | ||
| "", | ||
| "To disable/enable paging, set", | ||
| "", | ||
| f"{instance}:", | ||
| f" ...", | ||
| f" monitoring:" f" check_overrides:", | ||
| f" check_autoscaler_max_instances.{service}.{instance}:" | ||
| f" page: false # or true to enable", | ||
| "", | ||
| f"in eks-{cluster}.yaml.", | ||
| ] | ||
| ) | ||
|
|
||
| monitoring_defaults = { | ||
| "page": page_default, # This will be re-overridden in send_event if the user has specified it in check_overrides. | ||
| "runbook": "y/check-autoscaler-max-instances", | ||
| "realert_every": 60, # The check runs once a minute, so this would realert every hour. | ||
| "tip": ( | ||
| "The autoscaler wants to scale up to handle additional load" | ||
| " because your service is overloaded, but cannot scale any" | ||
| " higher because of max_instances." | ||
| f"{max_instances_suggestion}" | ||
| f"{alert_threshold_suggestion}" | ||
| f"{disable_paging_suggestion}" | ||
| ), | ||
| } | ||
| monitoring_overrides = ( | ||
| monitoring_defaults | monitoring_overrides | ||
| ) # combine, with preference to overrides | ||
| send_event( | ||
| service, | ||
| check_name=f"check_autoscaler_max_instances.{service}.{instance}", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,37 @@ def _load_sensu_team_data(): | |
| return team_data | ||
|
|
||
|
|
||
| def get_check_specific_overrides(overrides, check_name): | ||
|
||
| """ | ||
| Given a monitoring dict like: | ||
| { | ||
| "team": "myteam", | ||
| "check_every": "1m", | ||
| "check_overrides": { | ||
| "check_autoscaler_max_instances": { | ||
| "team": "otherteam", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| and a check_name of "check_autoscaler_max_instances", this function will | ||
| return | ||
|
|
||
| { | ||
| "team": "otherteam", | ||
| "check_every": "1m", | ||
| } | ||
|
|
||
| This allows you to override settings for specific checks, rather than for all checks for a service. | ||
| """ | ||
| check_overrides = overrides.get("check_overrides", {}) | ||
| check_specific_overrides = check_overrides.get(check_name, {}) | ||
| combined = overrides.copy() | ||
| combined.update(check_specific_overrides) | ||
| combined.pop("check_overrides", None) | ||
| return combined | ||
|
|
||
|
|
||
| def send_event( | ||
| service, | ||
| check_name, | ||
|
|
@@ -228,6 +259,9 @@ def send_event( | |
| :param system_paasta_config: A SystemPaastaConfig object representing the system | ||
| :param dry_run: Print the Sensu event instead of emitting it | ||
| """ | ||
|
|
||
| overrides = get_check_specific_overrides(overrides, check_name) | ||
|
|
||
| # This function assumes the input is a string like "mumble.main" | ||
| team = get_team(overrides, service, soa_dir) | ||
| if not team: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
might be nice to have a central location with all the possible checks somewhere