This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send regular GPU utilization report with CronJob (#5281)
- Loading branch information
Showing
19 changed files
with
406 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -199,6 +199,9 @@ authentication: | |
# smtp-from: [email protected] | ||
# smtp-auth-username: [email protected] | ||
# smtp-auth-password: password-for-alert-sender | ||
# cluster-utilization: # cluster-utilization is a k8s CronJob which reports the GPU utilization of the cluster | ||
# # for schedule syntex, refer to https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax | ||
# schedule: "0 0 * * *" # daily report at UTC 00:00 | ||
# customized-routes: | ||
# routes: | ||
# - receiver: pai-email-admin-user-and-stop-job | ||
|
This file contains 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 |
---|---|---|
|
@@ -84,6 +84,9 @@ rest-server: | |
# smtp-from: [email protected] | ||
# smtp-auth-username: [email protected] | ||
# smtp-auth-password: password-for-alert-sender | ||
# cluster-utilization: # cluster-utilization is a k8s CronJob which reports the GPU utilization of the cluster | ||
# # for schedule syntex, refer to https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax | ||
# schedule: "0 0 * * *" # daily report at UTC 00:00 | ||
# customized-routes: | ||
# routes: | ||
# - receiver: pai-email-admin-user-and-stop-job | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -117,6 +117,9 @@ rest-server: | |
# smtp-from: [email protected] | ||
# smtp-auth-username: [email protected] | ||
# smtp-auth-password: password-for-alert-sender | ||
# cluster-utilization: # cluster-utilization is a k8s CronJob which reports the GPU utilization of the cluster | ||
# # for schedule syntex, refer to https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax | ||
# schedule: "0 0 * * *" # daily report at UTC 00:00 | ||
# customized-routes: | ||
# routes: | ||
# - receiver: pai-email-admin-user-and-stop-job | ||
|
24 changes: 24 additions & 0 deletions
24
src/alert-manager/build/cluster-utilization.common.dockerfile
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# All rights reserved. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
# to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING | ||
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
FROM python:3.7 | ||
|
||
COPY ./src/cluster-utilization . | ||
|
||
RUN pip3 install -r requirements.txt | ||
|
||
ENTRYPOINT ["python3", "send_alert.py"] |
This file contains 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 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 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
44 changes: 44 additions & 0 deletions
44
src/alert-manager/deploy/alert-manager-cronjob.yaml.template
This file contains 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# All rights reserved. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
# to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING | ||
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: cluster-utilization | ||
spec: | ||
schedule: "{{ cluster_cfg["alert-manager"]["cluster-utilization"]["schedule"] }}" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: cluster-utilization | ||
image: {{ cluster_cfg['cluster']['docker-registry']['prefix'] }}cluster-utilization:{{ cluster_cfg['cluster']['docker-registry']['tag'] }} | ||
imagePullPolicy: Always | ||
env: | ||
- name: PAI_URI | ||
{%- if "ssl" in cluster_cfg["pylon"] and cluster_cfg["pylon"]["ssl"] %} | ||
value: "{{ cluster_cfg['pylon']['uri-https']}}" | ||
{%- else %} | ||
value: "{{ cluster_cfg['pylon']['uri']}}" | ||
{%- endif %} | ||
- name: PAI_BEARER_TOKEN | ||
value: {{ cluster_cfg["alert-manager"]["alert-handler"]["pai-bearer-token"] }} | ||
imagePullSecrets: | ||
- name: {{ cluster_cfg["cluster"]["docker-registry"]["secret-name"] }} | ||
restartPolicy: OnFailure |
84 changes: 84 additions & 0 deletions
84
src/alert-manager/deploy/alert-templates/cluster-usage/html.ejs
This file contains 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<!DOCTYPE html | ||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"> | ||
|
||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<title> | ||
<%= cluster_id %>: Cluster GPU utilization for One Week | ||
</title> | ||
</head> | ||
|
||
<body itemscope="" itemtype="http://schema.org/EmailMessage" | ||
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; height: 100%; line-height: 1.6em; width: 100% !important; background-color: #f6f6f6; margin: 0; padding: 0;"> | ||
<h3 style="text-align:center">Cluster GPU utilization for One Week</h3> | ||
<table style="font-size: 16px; width: 100%; margin: 0;"> | ||
<% alerts.filter( element=> typeof element.labels.cluster_usage !== 'undefined').forEach(function(alert){ %> | ||
<tr> | ||
<th>Cluster GPU utilization</th> | ||
<td> | ||
<%= alert.labels.cluster_usage %> | ||
</td> | ||
</tr> | ||
<% }); %> | ||
</table> | ||
<br /> | ||
<br /> | ||
<h3 style="text-align:center">User GPU Utilization for One Week</h3> | ||
<table style="font-size: 16px; width: 100%;margin: 0;text-align:center;"> | ||
<tr> | ||
<th>User name</th> | ||
<th>GPU utilization</th> | ||
</tr> | ||
<% alerts.filter( element=> typeof element.labels.user_name !== 'undefined' && typeof element.labels.user_usage !== | ||
'undefined').forEach(function(alert){ %> | ||
<tr> | ||
<td> | ||
<%= alert.labels.user_name %> | ||
</td> | ||
<td> | ||
<%= alert.labels.user_usage %> | ||
</td> | ||
</tr> | ||
<% }); %> | ||
</table> | ||
<br /> | ||
<br /> | ||
<h3 style="text-align:center">Job GPU Utilization for One Week</h3> | ||
<table style="font-size: 16px; width: 100%; margin: 0; text-align:center;"> | ||
<tr> | ||
<th>Job name</th> | ||
<th>GPU utilization</th> | ||
<th>Job duration</th> | ||
<th>Job start time</th> | ||
<th>Job status</th> | ||
<th>GPU number</th> | ||
</tr> | ||
<% alerts.filter( element=> typeof element.labels.job_name !== 'undefined' && typeof element.labels.job_usage !== | ||
'undefined').forEach(function(alert){ %> | ||
<tr> | ||
<td> | ||
<%= alert.labels.job_name %> | ||
</td> | ||
<td> | ||
<%= alert.labels.job_usage %> | ||
</td> | ||
<td> | ||
<%= alert.labels.job_duration %> | ||
</td> | ||
<td> | ||
<%= alert.labels.job_start_time %> | ||
</td> | ||
<td> | ||
<%= alert.labels.job_status %> | ||
</td> | ||
<td> | ||
<%= alert.labels.job_gpu_number %> | ||
</td> | ||
</tr> | ||
<% }); %> | ||
</table> | ||
</body> | ||
|
||
</html> |
1 change: 1 addition & 0 deletions
1
src/alert-manager/deploy/alert-templates/cluster-usage/subject.ejs
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= cluster_id %>: Cluster GPU Utilization for One Week |
This file contains 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 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 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
Empty file.
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[SETTINGS] | ||
|
||
max-line-length=140 | ||
|
||
disable = | ||
missing-docstring, | ||
invalid-name, | ||
cell-var-from-loop, | ||
undefined-loop-variable, |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==2.23.0 |
Oops, something went wrong.