diff --git a/deploy-board/deploy_board/templates/deploys/deploy_progress.html b/deploy-board/deploy_board/templates/deploys/deploy_progress.html new file mode 100644 index 0000000000..6e1a681152 --- /dev/null +++ b/deploy-board/deploy_board/templates/deploys/deploy_progress.html @@ -0,0 +1,217 @@ +{% load utils %} +{% load static %} +{% with deploy=report.currentDeployStat.deploy build=report.currentDeployStat.build tag=report.currentDeployStat.buildTag %} + {% include "deploys/deploy_progress_summary.tmpl" %} + {% if report.showMode != "simple" %} +
+
+

Hosts

+ +
+
+ {% include "deploys/deploy_stage_summary.html" with report=report build=report.currentDeployStat.build show_stopping_hosts=show_stopping_hosts %} + {% if report.firstTimeAgentStats %} + + {% endif %} + {% if report.provisioningHosts %} +
+ +
+
+ {% for host in report.provisioningHosts %} + + {{ host.hostName }} + + + {% endfor %} +
+
+
+ {% endif %} + {% if report.missingHosts %} +
+ +
+
+ {% for host in report.missingHosts %} + + {{ host }} + + {% endfor %} +
+ {% endif %} +
+ {% for agentStat in report.agentStats %} + {% if report.account == primaryAccount %} + {% if not agentStat.agent.accountId or agentStat.agent.accountId == primaryAccount or agentStat.agent.accountId == "null" %} + + {% if report.showMode != "compact" %}{{ agentStat.agent.hostName }}{% endif %} + {% if report.showMode == "containerStatus" %} + {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} + {% else %} + + {% endif %} + {% endif %} + + {% elif report.account == subAccount %} + {% if agentStat.agent.accountId and agentStat.agent.accountId == subAccount %} + + {% if report.showMode != "compact" %}{{ agentStat.agent.hostName }}{% endif %} + {% if report.showMode == "containerStatus" %} + {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} + {% else %} + + {% endif %} + {% endif %} + + {% elif report.account == "others" %} + {% if agentStat.agent.accountId and agentStat.agent.accountId != subAccount and agentStat.agent.accountId != primaryAccount and agentStat.agent.accountId != "null" %} + + {% if report.showMode != "compact" %}{{ agentStat.agent.hostName }}{% endif %} + {% if report.showMode == "containerStatus" %} + {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} + {% else %} + + {% endif %} + {% endif %} + + {% elif report.account == "all" %} + + {% if report.showMode != "compact" %}{{ agentStat.agent.hostName }}{% endif %} + {% if report.showMode == "containerStatus" %} + {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} + {% else %} + + {% endif %} + + {% endif %} + {% endfor %} +
+
+
+
+
+ {% endif %} +{% endwith %} + diff --git a/deploy-board/deploy_board/templates/deploys/deploy_progress.tmpl b/deploy-board/deploy_board/templates/deploys/deploy_progress.tmpl deleted file mode 100644 index 5e67cc4742..0000000000 --- a/deploy-board/deploy_board/templates/deploys/deploy_progress.tmpl +++ /dev/null @@ -1,286 +0,0 @@ -{% load utils %} -{% load static %} -{% with deploy=report.currentDeployStat.deploy build=report.currentDeployStat.build tag=report.currentDeployStat.buildTag %} -{% include "deploys/deploy_progress_summary.tmpl" %} - -{% if report.showMode != "simple" %} -
-
-

Hosts

-
-
-
- {% for agentStat in report.agentStats %} - {% if report.account == primaryAccount %} - {% if not agentStat.agent.accountId or agentStat.agent.accountId == primaryAccount or agentStat.agent.accountId == "null" %} - - {% if report.showMode != "compact" %} - {{ agentStat.agent.hostName }} - {% endif %} - {% if report.showMode == "containerStatus" %} - {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} - {% else %} - - {% endif %} - {% endif %} - - {% elif report.account == subAccount %} - {% if agentStat.agent.accountId and agentStat.agent.accountId == subAccount %} - - {% if report.showMode != "compact" %} - {{ agentStat.agent.hostName }} - {% endif %} - {% if report.showMode == "containerStatus" %} - {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} - {% else %} - - {% endif %} - {% endif %} - - {% elif report.account == "others" %} - {% if agentStat.agent.accountId and agentStat.agent.accountId != subAccount and agentStat.agent.accountId != primaryAccount and agentStat.agent.accountId != "null" %} - - {% if report.showMode != "compact" %} - {{ agentStat.agent.hostName }} - {% endif %} - {% if report.showMode == "containerStatus" %} - {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} - {% else %} - - {% endif %} - {% endif %} - - {% elif report.account == "all" %} - - {% if report.showMode != "compact" %} - {{ agentStat.agent.hostName }} - {% endif %} - {% if report.showMode == "containerStatus" %} - {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} - {% else %} - - {% endif %} - - {% endif %} - {% endfor %} - -

- - Failed Hosts - - - All Details - - - Sub Account Hosts - -
-
-
-{% endif %} - -{% if report.firstTimeAgentStats %} -
- - - - - - -
- - New Hosts - - - - {% for agentStat in report.firstTimeAgentStats %} - - {% if report.showMode == "complete" %} - {{ agentStat.agent.hostName }} - {% endif %} - - {% if report.showMode == "containerStatus" %} - {% include "deploys/_container_status.html" with healthStatus=agentStat.agent.containerHealthStatus %} - {% endif %} - - {% endfor %} - - - - - {{ report.firstTimeAgentStats|length }} - - -
-
-{% endif %} - -
- - - - {% for key, value in report.currentDeployStat.stageDistMap.items %} - {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} - - {% endif %} - {% endfor %} - - - - - {% for key, value in report.currentDeployStat.stageDistMap.items %} - {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} - - {% endif %} - {% endfor %} - - - - {% for deployStat in report.deprecatedDeployStats %} - - - {% for key, value in deployStat.stageDistMap.items %} - {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} - - {% endif %} - {% endfor %} - - - {% endfor %} -
- - {{ key }} - - Total
- - Current({{ build.commitShort }}) - - - - - {{ value }} - - - - - {{ report.currentDeployStat.total }} - -
- - Previous({{ deployStat.build.commitShort }}) - - - - - {{ value }} - - - - - {{ deployStat.total }} - -
-
- -{% if report.provisioningHosts %} -
- - - - - - -
- - New Hosts - - - {% for host in report.provisioningHosts %} - - {{ host.hostName }} - - - {% endfor %} - - - {{ report.provisioningHosts | length }} - -
-
-{% endif %} - -{% if report.missingHosts %} -
- - - - - - -
- - Unknown Hosts - - - {% for host in report.missingHosts %} - - {{ host }} - - {% endfor %} - - - {{ report.missingHosts|length }} - -
-
-{% endif %} - -
- - Total Hosts: {{ report|reportTotal }} - -
-{% endwith %} - - diff --git a/deploy-board/deploy_board/templates/deploys/deploy_stage_summary.html b/deploy-board/deploy_board/templates/deploys/deploy_stage_summary.html new file mode 100644 index 0000000000..88d86bc896 --- /dev/null +++ b/deploy-board/deploy_board/templates/deploys/deploy_stage_summary.html @@ -0,0 +1,89 @@ +{% load utils %} +{% load static %} +
+ + + + + {% for key, value in report.currentDeployStat.stageDistMap.items %} + {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} + + {% endif %} + {% endfor %} + + + + + + + {% for key, value in report.currentDeployStat.stageDistMap.items %} + {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} + + {% endif %} + {% endfor %} + + + {% for deployStat in report.deprecatedDeployStats %} + + + {% for key, value in deployStat.stageDistMap.items %} + {% if display_stopping_hosts == "true" or key != "STOPPING" and key != "STOPPED" %} + + {% endif %} + {% endfor %} + + + + {% endfor %} +
+ + {{ key }} + + + + Total + +
+ + Current({{ build.commitShort }}) + + + + {{ value }} + + + + {{ report.currentDeployStat.total }} + +
+ + Previous({{ deployStat.build.commitShort }}) + + + + {{ value }} + + + + {{ deployStat.total }} + +
+
diff --git a/deploy-board/deploy_board/templates/environs/env_landing.html b/deploy-board/deploy_board/templates/environs/env_landing.html index f8b09ea53c..a627a072fe 100644 --- a/deploy-board/deploy_board/templates/environs/env_landing.html +++ b/deploy-board/deploy_board/templates/environs/env_landing.html @@ -295,7 +295,7 @@ Warning! {{ env.envName }}/{{ env.stageName }} is managed by Pindeploy. Deployments should be done from this pipeline. - Creating a deployment from other sources will disable PinDeploy management on the pipeline. + Creating a deployment from other sources will disable PinDeploy management on the pipeline. Only do so in case of emergency. {% endif %} @@ -513,7 +513,7 @@

- {% include "deploys/deploy_progress.tmpl" %} + {% include "deploys/deploy_progress.html" %}
{% include "deploys/deploy_add_ons.tmpl" %} diff --git a/deploy-board/deploy_board/webapp/env_views.py b/deploy-board/deploy_board/webapp/env_views.py index e09f787b88..ebeef6332a 100644 --- a/deploy-board/deploy_board/webapp/env_views.py +++ b/deploy-board/deploy_board/webapp/env_views.py @@ -248,7 +248,7 @@ def update_deploy_progress(request, name, stage): "accounts": accounts, } - html = render_to_string('deploys/deploy_progress.tmpl', context) + html = render_to_string('deploys/deploy_progress.html', context) response = HttpResponse(html) @@ -628,7 +628,7 @@ def _get_last_cluster_refresh_status(request, env): return replace_summaries["clusterRollingUpdateStatuses"][0] except: return None - + def _is_cluster_auto_refresh_enabled(request, env): try: cluster_name = get_cluster_name(request, env.get('envName'), env.get('stageName'), env=env) @@ -1140,9 +1140,9 @@ def remove_stage(request, name, stage): return response -def get_pipeline_url_from_build_info(build): +def get_pipeline_url_from_build_info(build): if build['publishInfo'] and re.findall("https://[\w\d\-\.]*/job/[\w\d\-\.]*/[\d]*(/)?", build['publishInfo']): - return re.sub("/[\d]*(/)?$", '', build['publishInfo']) + return re.sub("/[\d]*(/)?$", '', build['publishInfo']) if build['publishInfo'] and re.findall("https://[\w\d\-\.]*/job/[\w\d\-\.]*/?", build['publishInfo']): return build['publishInfo'] return False @@ -1154,18 +1154,18 @@ def get_builds(request, name, stage): if env_promote['type'] == 'AUTO' and env_promote['predStage'] and \ env_promote['predStage'] == environs_helper.BUILD_STAGE: show_lock = True - + if 'buildName' not in env and not env['buildName']: html = render_to_string('builds/simple_builds.tmpl', { "builds": [], - "env": env, + "env": env, "show_lock": show_lock, }) return HttpResponse(html) current_publish_date = 0 - build_deploy_pipeline_url = False - + build_deploy_pipeline_url = False + if 'deployId' in env and env['deployId']: deploy = deploys_helper.get(request, env['deployId']) build = builds_helper.get_build(request, deploy['buildId']) @@ -1196,7 +1196,7 @@ def get_builds(request, name, stage): html = render_to_string('builds/simple_builds.tmpl', { "builds": new_builds, "build_deploy_pipeline_url" : build_deploy_pipeline_url, - "current_publish_date": current_publish_date, + "current_publish_date": current_publish_date, "env": env, "show_lock": show_lock, }) diff --git a/deploy-board/tools/agent_simulator.py b/deploy-board/tools/agent_simulator.py index 4756cb833b..2bde03ab01 100644 --- a/deploy-board/tools/agent_simulator.py +++ b/deploy-board/tools/agent_simulator.py @@ -1,83 +1,80 @@ +#!/usr/bin/env python3 # Copyright 2016 Pinterest, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - # -*- coding: utf-8 -*- -''' Simulate l00 hosts to ping server constantly. If group name match the env + +""" Simulate l00 hosts to ping server constantly. If group name match the env capacity config and there is active deploy, it will simulate the full deploy cycle as well. -''' -import commons +""" +from commons import REQUEST +from deploy_board.webapp.helpers import systems_helper import argparse import time import threading states = {} -systems_helper = commons.get_system_helper() +HOST_COUNT = 100 -def ping(i, groups): - host = "host-888-%d" % i - ip = "%d.%d.%d.%d" % (i, i, i, i) +def ping(i: str, groups: list): + host = f"host-888-{i}" + ip = f"{i}.{i}.{i}.{i}" reports = {} while True: pingRequest = {} - pingRequest['hostId'] = host - pingRequest['hostName'] = host - pingRequest['hostIp'] = ip - pingRequest['groups'] = groups - pingRequest['reports'] = list(reports.values()) + pingRequest["hostId"] = host + pingRequest["hostName"] = host + pingRequest["hostIp"] = ip + pingRequest["groups"] = groups + pingRequest["reports"] = list(reports.values()) try: - pingResponse = systems_helper.ping(commons.REQUEST, pingRequest) + pingResponse = systems_helper.ping(REQUEST, pingRequest) except Exception as e: - print(e.message) + print(e) continue - if pingResponse.get('opCode') == 'NOOP': + if pingResponse.get("opCode") == "NOOP": continue - else: - print("%s :-> %s:%s" % (host, - pingResponse.get('opCode'), - pingResponse.get('deployGoal').get('deployStage'))) - goal = pingResponse.get('deployGoal') + print( + f"{host} :-> {pingResponse.get('opCode')}:{pingResponse.get('deployGoal').get('deployStage')}" + ) + goal = pingResponse.get("deployGoal") report = {} - report['envId'] = goal.get('envId') - report['deployId'] = goal.get('deployId') - report['agentStatus'] = 'SUCCEEDED' - report['deployStage'] = goal.get('deployStage') - reports[goal.get('envId')] = report + report["envId"] = goal.get("envId") + report["deployId"] = goal.get("deployId") + report["agentStatus"] = "SUCCEEDED" + report["deployStage"] = goal.get("deployStage") + reports[goal.get("envId")] = report -def main(): - parser = argparse.ArgumentParser(description='Simulate 100 hosts to ping server constantly') - parser.add_argument('-g', '--group', type=str, help='Group name', required=True) +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Simulate 100 hosts to ping server constantly" + ) + parser.add_argument("-g", "--group", type=str, help="Group name", required=True) args = parser.parse_args() groups = [args.group] - for i in range(100): - host = "host-sim-%d" % i - states[host] = False + for i in range(HOST_COUNT): + states[f"host-sim-{i}"] = False - for i in range(100): - t = threading.Thread(target=ping, args=(i, groups)) - t.daemon = True + for i in range(HOST_COUNT): + t = threading.Thread(target=ping, args=(i, groups), daemon=True) t.start() while True: time.sleep(5) continue - - -if __name__ == "__main__": - main()