Skip to content

Commit

Permalink
Revert "Updates to support other cluster/group name formats (#1544)"
Browse files Browse the repository at this point in the history
This reverts commit 204b72f.
  • Loading branch information
Rodshell Fleurinord committed Mar 29, 2024
1 parent e41d5f2 commit 9d66824
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</a>
</div>
<div class="row">
<a href="/groups/{{ cluster_name }}/scaling_activities/" target="_blank"
<a href="/groups/{{ env_name }}-{{ env_stage }}/scaling_activities/" target="_blank"
type="button" class="btn btn-default btn-block">
<span class="glyphicon glyphicon-list"></span> Show Replacement Activities
</a>
Expand Down Expand Up @@ -143,7 +143,7 @@
<span style="color:red;"><b>may need to be refreshed</b></span>
<span class="glyphicon glyphicon-warning-sign"></span>
<span>(This <i>suggestion</i> is based on the last time cluster configuration was changed/updated vs. the last time cluster refresh was started and its status. It may be <i>inaccurate</i>
in case where the last configuration change was <i>not</i> related to host/instance configurations. In this case, if the cluster is indeed up to date, refreshing (skip matching) it
in case where the last configuration change was <i>not</i> related to host/instance configurations. In this case, if the cluster is indeed up to date, refreshing (skip matching) it
will result in a no-op, and it will complete after few seconds. And the cluster will be up to date.)
</span>
{% endif %}
Expand Down Expand Up @@ -183,7 +183,7 @@
else {
checkpointPercentagesElement.setCustomValidity('');
}

const checkpointPercentages = checkpointPercentagesElement.value.split(',').reduce( (acc, p) => acc.concat(+p), []);

for (let i = 0; i < checkpointPercentages.length - 1; i++) {
Expand Down Expand Up @@ -333,21 +333,21 @@
<span class="fa fa-bell"></span> Checkpoint percentages:
</label>
<input type="text" id="checkpointPercentages" name="checkpointPercentages" maxlength="200" value={% if auto_refresh_config.config.checkpointPercentages %}{{ auto_refresh_config.config.checkpointPercentages|join:"," }}{% endif %}>

<label for="checkpointDelay" data-toggle="tooltip" title="Delay in seconds between checkpoints">
<span class="fa fa-clock-o"></span> Checkpoint delay (seconds):
</label>
<input type="number" id="checkpointDelay" name="checkpointDelay" min="0" value={% if auto_refresh_config.config.checkpointDelay %}{{ auto_refresh_config.config.checkpointDelay }}{% endif %}>
</div>

<div style="padding-top: 20px;">
<label class="switch" data-toggle="tooltip" title="Skip replacing instances that already use the latest launch template." >
Skip matching launch template
<input type="checkbox" id="skipMatching" name="skipMatching" {% if auto_refresh_config.config.skipMatching %} checked {% endif %}>
<div class="slider round"></div>
</label>
</div>

<div style="padding-top: 20px;">
<label class="switch" data-toggle="tooltip" title="Whether to replace instances that are protected from autoscaling.">
Replace protected instances
Expand Down Expand Up @@ -388,7 +388,7 @@
Update
</button>
</div>

{% csrf_token %}
</form>

Expand All @@ -403,7 +403,7 @@
else {
updateClusterAutoRefreshConfigBtnElement.disabled = false
}
</script>
</script>
</div>
{% else %}
<div class="container-fluid">
Expand Down Expand Up @@ -468,21 +468,21 @@
<span class="fa fa-bell"></span> Checkpoint percentages:
</label>
<input type="text" id="checkpointPercentages" name="checkpointPercentages" maxlength="200" placeholder="e.g. 25, 50, 100">

<label for="checkpointDelay" data-toggle="tooltip" title="Delay in seconds between checkpoints">
<span class="fa fa-clock-o"></span> Checkpoint delay (seconds):
</label>
<input type="number" id="checkpointDelay" name="checkpointDelay" min="0" value="3600">
</div>

<div style="padding-top: 20px;">
<label class="switch" data-toggle="tooltip" title="Skip replacing instances that already use the latest launch template." >
Skip matching launch template
<input type="checkbox" id="skipMatching" name="skipMatching" checked>
<div class="slider round"></div>
</label>
</div>

<div style="padding-top: 20px;">
<label class="switch" data-toggle="tooltip" title="Whether to replace instances that are protected from autoscaling.">
Replace protected instances
Expand All @@ -500,7 +500,7 @@
<span class="glyphicon glyphicon-refresh"></span> Start
</button>
</div>

{% csrf_token %}
</form>

Expand Down Expand Up @@ -610,7 +610,7 @@
</table>
</div>
</div>
</div>
</div>
{% endif %}

{% endblock %}
2 changes: 1 addition & 1 deletion deploy-board/deploy_board/templates/configs/capacity.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4 class="panel-title pull-left">Capacity</h4>
<side-button styleclass="fa fa-gears" text="Cluster Configuration" href="/env/{{ env.envName }}/{{ env.stageName }}/config/cluster/config/" title="Go to the cluster configuration page"></side-button>
</div>
<div v-if="!noCluster" class="row">
<side-button styleclass="fa fa-cloud" text="Autoscaling Settings" href="/groups/{{ env.clusterName }}/config" title="Advanced auto scaling configuration page"></side-button>
<side-button styleclass="fa fa-cloud" text="Autoscaling Settings" href="/groups/{{ env.envName }}-{{ env.stageName }}/config" title="Advanced auto scaling configuration page"></side-button>
</div>
<div v-if="showAddExistingCapacity" class="row">
<side-button styleclass="fa fa-plus" text="Add Existing Capacity" href="/env/{{ env.envName }}/{{ env.stageName }}/config/capacity?addexisting" title="Add Existing Capacity"></side-button>
Expand Down
2 changes: 1 addition & 1 deletion deploy-board/deploy_board/templates/configs/capacity.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var groups = rootVue.$refs.groupsinput.tags;
var image = info.basic_cluster_info ? info.basic_cluster_info.base_image_info : null;
if(hasCMPCluster && image && image.abstract_name && image.abstract_name.startsWith('cmp_base')) {
var defaultClusterASGGroupName = '{{ cluster_name }}';
var defaultClusterASGGroupName = '{{ env.envName }}-{{ env.stageName }}';
if(groups.indexOf(defaultClusterASGGroupName) < 0) {
groups.push(defaultClusterASGGroupName);
}
Expand Down
4 changes: 2 additions & 2 deletions deploy-board/deploy_board/templates/environs/env_landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h4 class="panel-title pull-left">{{title}}</h4>
</div>
{% if hasGroups %}
<div v-if="showCluster" class="row">
<side-button styleclass="fa fa-expand" v-bind:text="autoScalingSettingsText" href="/groups/{{ env.clusterName }}/config" title="Configure autoscaling group"></side-button>
<side-button styleclass="fa fa-expand" v-bind:text="autoScalingSettingsText" href="/groups/{{ env.envName }}-{{ env.stageName }}/config" title="Configure autoscaling group"></side-button>
</div>
{% endif %}
{% if hasCluster %}
Expand Down Expand Up @@ -313,7 +313,7 @@ <h4 class="modal-title">Resume Confirm</h4>
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Info!</strong> {{ cluster_refresh_suggestion_for_golden_ami }}
Click <a href="/env/{{ env.envName }}/{{ env.stageName }}/base_images/" target="_blank">here</a> for image update history.
Click <a href="/groups/{{ env.clusterName }}/host-ami-dist/" target="_blank">here</a> to see AMI(s) used by hosts.
Click <a href="/groups/{{ env.envName }}-{{ env.stageName }}/host-ami-dist/" target="_blank">here</a> to see AMI(s) used by hosts.
Click <a href="/env/{{ env.envName }}/{{ env.stageName }}/cluster_replacements/" target="_blank">here</a> to replace the cluster.
</div>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions deploy-board/deploy_board/templates/host_side_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h4 class="modal-title">Host Termination Confirm</h4>
try {
result = await $.ajax({
type: 'GET',
url: `/groups/{{ group_name }}/hosts`,
url: `/groups/{{env_name}}-{{stage_name}}/hosts`,
dataType: "json",
beforeSend: function(xhr, settings) {
var csrftoken = getCookie('csrftoken');
Expand All @@ -72,7 +72,7 @@ <h4 class="modal-title">Host Termination Confirm</h4>
terminatingHostCount = data;
if (terminatingHostCount >= `{{termination_limit}}`) {
$('#terminationWarning').show();
}
}
});
}
});
Expand Down
40 changes: 11 additions & 29 deletions deploy-board/deploy_board/webapp/cluster_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def post(self, request, name, stage):
class ClusterConfigurationView(View):
def get(self, request, name, stage):

current_cluster = get_current_cluster(request, name, stage)
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
host_types = hosttypes_helper.get_by_arch(
request, current_cluster['archName'])
current_image = baseimages_helper.get_by_id(
Expand Down Expand Up @@ -305,7 +306,8 @@ def post(self, request, name, stage):
cluster_info = json.loads(request.body)
log.info("Update Cluster Configuration with {}", cluster_info)

current_cluster = get_current_cluster(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
log.info("getting current Cluster Configuration is {}", current_cluster)
if 'configs' in current_cluster and 'configs' in cluster_info:
for field in TELETRAAN_CLUSTER_READONLY_FIELDS:
Expand Down Expand Up @@ -334,7 +336,7 @@ def post(self, request, name, stage):
log.info("Update Cluster Capacity with data {}".format(request.body))
try:
settings = json.loads(request.body)
cluster_name = get_cluster_name(request, name, stage)
cluster_name = '{}-{}'.format(name, stage)
log.info("Update cluster {0} with {1}".format(
cluster_name, settings))
minSize = int(settings['minsize'])
Expand Down Expand Up @@ -903,7 +905,7 @@ def clone_cluster(request, src_name, src_stage):
dest_name = params.get('new_environment', src_name)
dest_stage = params.get('new_stage', src_stage + '_clone')

src_cluster_name = get_cluster_name(request, src_name, src_stage)
src_cluster_name = '{}-{}'.format(src_name, src_stage)
dest_cluster_name = '{}-{}'.format(dest_name, dest_stage)

# 0. teletraan service get src env buildName
Expand Down Expand Up @@ -1076,7 +1078,7 @@ def enable_cluster_replacement(request, name, stage):

def gen_cluster_replacement_view(request, name, stage):
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = get_cluster_name(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
get_cluster_replacement_body = {
"clusterName": cluster_name
}
Expand All @@ -1103,7 +1105,7 @@ def gen_cluster_replacement_view(request, name, stage):

def gen_auto_cluster_refresh_view(request, name, stage):
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = get_cluster_name(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
get_cluster_replacement_body = {
"clusterName": cluster_name
}
Expand Down Expand Up @@ -1185,7 +1187,7 @@ def sanitize_slack_email_input(input):

def get_cluster_replacement_details(request, name, stage, replacement_id):
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = get_cluster_name(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
get_cluster_replacement_details_body = {
"clusterName": cluster_name,
"replacementIds": [replacement_id]
Expand Down Expand Up @@ -1427,7 +1429,7 @@ class ClusterHistoriesView(View):
def get(self, request, name, stage):
env = environs_helper.get_env_by_stage(request, name, stage)

cluster_name = get_cluster_name(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
page_index = request.GET.get('index')
page_size = request.GET.get('size')
histories = clusters_helper.get_cluster_replacement_histories(
Expand All @@ -1454,7 +1456,7 @@ class ClusterBaseImageHistoryView(View):

def get(self, request, name, stage):
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = get_cluster_name(request, name, stage, env=env)
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
current_image = baseimages_helper.get_by_id(request, current_cluster['baseImageId'])
golden_image = baseimages_helper.get_current_golden_image(
Expand All @@ -1472,23 +1474,3 @@ def get(self, request, name, stage):
}

return render(request, 'clusters/base_image_history.html', data)

def get_cluster_name(request, name, stage, env=None):
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
if current_cluster is None:
if env is None:
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = env.get("clusterName")
return cluster_name

def get_current_cluster(request, name, stage, env=None):
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
if current_cluster is None:
if env is None:
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = env.get("clusterName")
current_cluster = clusters_helper.get_cluster(request, cluster_name)
return current_cluster

27 changes: 4 additions & 23 deletions deploy-board/deploy_board/webapp/env_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from collections import Counter
from .helpers import builds_helper, environs_helper, agents_helper, ratings_helper, deploys_helper, \
systems_helper, environ_hosts_helper, clusters_helper, tags_helper, baseimages_helper, schedules_helper, placements_helper, hosttypes_helper, \
accounts_helper, autoscaling_groups_helper
accounts_helper
from .templatetags import utils
from .helpers.exceptions import TeletraanException
import math
Expand Down Expand Up @@ -581,7 +581,7 @@ def get(self, request, name, stage=None):

def _gen_message_for_refreshing_cluster(request, last_cluster_refresh_status, latest_succeeded_base_image_update_event, env):
try:
group_name = get_group_name(request, env.get('envName'), env.get('stageName'), env=env)
group_name = '{}-{}'.format(env["envName"], env["stageName"])
host_ami_dist = requests.post(url = CMDB_API_HOST+"/v2/query", json={
"query": "tags.Autoscaling:{} AND state:running".format(group_name),
"fields": "cloud.aws.imageId"
Expand Down Expand Up @@ -610,9 +610,8 @@ def _gen_message_for_refreshing_cluster(request, last_cluster_refresh_status, la

def _getLastClusterRefreshStatus(request, env):
try:
cluster_name = get_cluster_name(request, env.get('envName'), env.get('stageName'), env=env)
replace_summaries = clusters_helper.get_cluster_replacement_status(
request, data={"clusterName": cluster_name})
request, data={"clusterName": '{}-{}'.format(env["envName"], env["stageName"])})

if len(replace_summaries["clusterRollingUpdateStatuses"]) == 0:
return None
Expand Down Expand Up @@ -780,7 +779,7 @@ def _gen_deploy_summary(request, deploys, for_env=None):
deploy_accounts = [create_legacy_ui_account(account) for account in get_accounts(report)]
elif account:
deploy_accounts = [account]

summary = {}
summary['deploy'] = deploy
summary['env'] = env
Expand Down Expand Up @@ -1953,21 +1952,3 @@ def override_session(request, name, stage):
session_num = request.GET.get('session_num')
schedules_helper.override_session(request, name, stage, session_num)
return HttpResponse(json.dumps(''))

def get_cluster_name(request, name, stage, env=None):
cluster_name = '{}-{}'.format(name, stage)
current_cluster = clusters_helper.get_cluster(request, cluster_name)
if current_cluster is None:
if env is None:
env = environs_helper.get_env_by_stage(request, name, stage)
cluster_name = env.get("clusterName")
return cluster_name

def get_group_name(request, name, stage, env=None):
group_name = '{}-{}'.format(name, stage)
current_group = autoscaling_groups_helper.get_group_info(request, group_name)
if current_group is None:
if env is None:
env = environs_helper.get_env_by_stage(request, name, stage)
group_name = env.get("groupName")
return group_name

0 comments on commit 9d66824

Please sign in to comment.