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

Prevent alarm created without scaling policy #1448

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions deploy-board/deploy_board/templates/groups/asg_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
{% include "groups/group_side_panel.html" %}
</div>


{% endblock %}

{% block new-builds-panel %}
Expand All @@ -26,7 +25,14 @@

{% block main %}


{% if storage %}
{% for message in storage %}
<div class="alert alert-warning" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Warning!</strong> {{ message | safe}}
</div>
{% endfor %}
{% endif %}
knguyen100000010 marked this conversation as resolved.
Show resolved Hide resolved

{% if not is_cmp %}
<div id="launchConfigPid" class="panel panel-default">
Expand Down
9 changes: 9 additions & 0 deletions deploy-board/deploy_board/webapp/group_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from django.template.loader import render_to_string
from django.http import HttpResponse
from django.contrib import messages
from django.contrib.messages import get_messages
import json
import logging
import traceback
Expand Down Expand Up @@ -735,6 +736,13 @@
alarm_info["metricSource"] = params["awsMetrics"]
alarm_info["groupName"] = group_name

if len(alarm_info["scalingPolicies"]) == 0:

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
# Technically, an alarm can be created without an action (e.g. scaling policy)
# However, in the current context, an alarm must have an associated scaling policy.
# In this case, there is no scaling policy, so refuse to create new alarm.
messages.add_message(request, messages.ERROR, 'Alarm could not be created because there was no {} policy.'.format(policy_type))
return redirect("/groups/{}/config/".format(group_name))

autoscaling_groups_helper.add_alarm(request, group_name, [alarm_info])

return redirect("/groups/{}/config/".format(group_name))
Expand Down Expand Up @@ -1121,6 +1129,7 @@
"pas_config": pas_config,
"is_cmp": is_cmp,
"disallow_autoscaling": _disallow_autoscaling(curr_image),
"storage": get_messages(request)
})


Expand Down
Loading