-
Notifications
You must be signed in to change notification settings - Fork 888
chore: add workspace reached resource threshold notification #16250
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6c6240b
chore: add workspace reached resource threshold notification
DanielleMaywood b3081de
chore: split out into two notifications
DanielleMaywood a9c8676
chore: update golden files
DanielleMaywood 4c21ce7
Merge branch 'main' into dm-internal-247
DanielleMaywood 944fdb5
chore: rewrite ood notification
DanielleMaywood 6444176
chore: updaten golden file
DanielleMaywood bc87268
chore: silly me
DanielleMaywood d2265f6
chore: rename test
DanielleMaywood 4d38b1f
Merge branch 'main' into dm-internal-247
DanielleMaywood 9fd5d2b
chore: bump migration number, delete old files
DanielleMaywood 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
2 changes: 2 additions & 0 deletions
2
coderd/database/migrations/000289_oom_and_ood_notification.down.sql
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DELETE FROM notification_templates WHERE id = 'f047f6a3-5713-40f7-85aa-0394cce9fa3a'; | ||
DELETE FROM notification_templates WHERE id = 'a9d027b4-ac49-4fb1-9f6d-45af15f64e7a'; |
40 changes: 40 additions & 0 deletions
40
coderd/database/migrations/000289_oom_and_ood_notification.up.sql
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
INSERT INTO notification_templates | ||
(id, name, title_template, body_template, "group", actions) | ||
VALUES ( | ||
'a9d027b4-ac49-4fb1-9f6d-45af15f64e7a', | ||
'Workspace Out Of Memory', | ||
E'Your workspace "{{.Labels.workspace}}" is low on memory', | ||
E'Hi {{.UserName}},\n\n'|| | ||
E'Your workspace **{{.Labels.workspace}}** has reached the memory usage threshold set at **{{.Labels.threshold}}**.', | ||
'Workspace Events', | ||
'[ | ||
{ | ||
"label": "View workspace", | ||
"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}" | ||
} | ||
]'::jsonb | ||
); | ||
|
||
INSERT INTO notification_templates | ||
(id, name, title_template, body_template, "group", actions) | ||
VALUES ( | ||
'f047f6a3-5713-40f7-85aa-0394cce9fa3a', | ||
'Workspace Out Of Disk', | ||
E'Your workspace "{{.Labels.workspace}}" is low on volume space', | ||
E'Hi {{.UserName}},\n\n'|| | ||
E'{{ if eq (len .Data.volumes) 1 }}{{ $volume := index .Data.volumes 0 }}'|| | ||
E'Volume **`{{$volume.path}}`** is over {{$volume.threshold}} full in workspace **{{.Labels.workspace}}**.'|| | ||
E'{{ else }}'|| | ||
E'The following volumes are nearly full in workspace **{{.Labels.workspace}}**\n\n'|| | ||
E'{{ range $volume := .Data.volumes }}'|| | ||
E'- **`{{$volume.path}}`** is over {{$volume.threshold}} full\n'|| | ||
E'{{ end }}'|| | ||
E'{{ end }}', | ||
'Workspace Events', | ||
'[ | ||
{ | ||
"label": "View workspace", | ||
"url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}" | ||
} | ||
]'::jsonb | ||
); |
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
91 changes: 91 additions & 0 deletions
91
.../notifications/testdata/rendered-templates/smtp/TemplateWorkspaceOutOfDisk#01.html.golden
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
From: system@coder.com | ||
To: bobby@coder.com | ||
Subject: Your workspace "bobby-workspace" is low on volume space | ||
Message-Id: 02ee4935-73be-4fa1-a290-ff9999026b13@blush-whale-48 | ||
Date: Fri, 11 Oct 2024 09:03:06 +0000 | ||
Content-Type: multipart/alternative; boundary=bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
MIME-Version: 1.0 | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/plain; charset=UTF-8 | ||
|
||
Hi Bobby, | ||
|
||
The following volumes are nearly full in workspace bobby-workspace | ||
|
||
/home/coder is over 90% full | ||
/dev/coder is over 80% full | ||
/etc/coder is over 95% full | ||
|
||
|
||
View workspace: http://test.com/@bobby/bobby-workspace | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/html; charset=UTF-8 | ||
|
||
<!doctype html> | ||
<html lang=3D"en"> | ||
<head> | ||
<meta charset=3D"UTF-8" /> | ||
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale= | ||
=3D1.0" /> | ||
<title>Your workspace "bobby-workspace" is low on volume space</title> | ||
</head> | ||
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-= | ||
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel= | ||
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617= | ||
; background: #f8fafc;"> | ||
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde= | ||
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig= | ||
n: left; font-size: 14px; line-height: 1.5;"> | ||
<div style=3D"text-align: center;"> | ||
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod= | ||
er Logo" style=3D"height: 40px;" /> | ||
</div> | ||
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m= | ||
argin: 8px 0 32px; line-height: 1.5;"> | ||
Your workspace "bobby-workspace" is low on volume space | ||
</h1> | ||
<div style=3D"line-height: 1.5;"> | ||
<p>Hi Bobby,</p> | ||
|
||
<p>The following volumes are nearly full in workspace <strong>bobby-workspa= | ||
ce</strong></p> | ||
|
||
<ul> | ||
<li><strong><code>/home/coder</code></strong> is over 90% full<br> | ||
</li> | ||
<li><strong><code>/dev/coder</code></strong> is over 80% full<br> | ||
</li> | ||
<li><strong><code>/etc/coder</code></strong> is over 95% full<br> | ||
</li> | ||
</ul> | ||
</div> | ||
<div style=3D"text-align: center; margin-top: 32px;"> | ||
=20 | ||
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display= | ||
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa= | ||
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;"> | ||
View workspace | ||
</a> | ||
=20 | ||
</div> | ||
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz= | ||
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;"> | ||
<p>© 2024 Coder. All rights reserved - <a = | ||
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h= | ||
ttp://test.com</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo= | ||
r: #2563eb; text-decoration: none;">Click here to manage your notification = | ||
settings</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications?disabled=3Df04= | ||
7f6a3-5713-40f7-85aa-0394cce9fa3a" style=3D"color: #2563eb; text-decoration= | ||
: none;">Stop receiving emails like this</a></p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4-- |
78 changes: 78 additions & 0 deletions
78
coderd/notifications/testdata/rendered-templates/smtp/TemplateWorkspaceOutOfDisk.html.golden
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
From: system@coder.com | ||
To: bobby@coder.com | ||
Subject: Your workspace "bobby-workspace" is low on volume space | ||
Message-Id: 02ee4935-73be-4fa1-a290-ff9999026b13@blush-whale-48 | ||
Date: Fri, 11 Oct 2024 09:03:06 +0000 | ||
Content-Type: multipart/alternative; boundary=bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
MIME-Version: 1.0 | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/plain; charset=UTF-8 | ||
|
||
Hi Bobby, | ||
|
||
Volume /home/coder is over 90% full in workspace bobby-workspace. | ||
|
||
|
||
View workspace: http://test.com/@bobby/bobby-workspace | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/html; charset=UTF-8 | ||
|
||
<!doctype html> | ||
<html lang=3D"en"> | ||
<head> | ||
<meta charset=3D"UTF-8" /> | ||
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale= | ||
=3D1.0" /> | ||
<title>Your workspace "bobby-workspace" is low on volume space</title> | ||
</head> | ||
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-= | ||
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel= | ||
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617= | ||
; background: #f8fafc;"> | ||
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde= | ||
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig= | ||
n: left; font-size: 14px; line-height: 1.5;"> | ||
<div style=3D"text-align: center;"> | ||
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod= | ||
er Logo" style=3D"height: 40px;" /> | ||
</div> | ||
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m= | ||
argin: 8px 0 32px; line-height: 1.5;"> | ||
Your workspace "bobby-workspace" is low on volume space | ||
</h1> | ||
<div style=3D"line-height: 1.5;"> | ||
<p>Hi Bobby,</p> | ||
|
||
<p>Volume <strong><code>/home/coder</code></strong> is over 90% full in wor= | ||
kspace <strong>bobby-workspace</strong>.</p> | ||
</div> | ||
<div style=3D"text-align: center; margin-top: 32px;"> | ||
=20 | ||
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display= | ||
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa= | ||
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;"> | ||
View workspace | ||
</a> | ||
=20 | ||
</div> | ||
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz= | ||
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;"> | ||
<p>© 2024 Coder. All rights reserved - <a = | ||
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h= | ||
ttp://test.com</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo= | ||
r: #2563eb; text-decoration: none;">Click here to manage your notification = | ||
settings</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications?disabled=3Df04= | ||
7f6a3-5713-40f7-85aa-0394cce9fa3a" style=3D"color: #2563eb; text-decoration= | ||
: none;">Stop receiving emails like this</a></p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4-- |
79 changes: 79 additions & 0 deletions
79
...d/notifications/testdata/rendered-templates/smtp/TemplateWorkspaceOutOfMemory.html.golden
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
From: system@coder.com | ||
To: bobby@coder.com | ||
Subject: Your workspace "bobby-workspace" is low on memory | ||
Message-Id: 02ee4935-73be-4fa1-a290-ff9999026b13@blush-whale-48 | ||
Date: Fri, 11 Oct 2024 09:03:06 +0000 | ||
Content-Type: multipart/alternative; boundary=bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
MIME-Version: 1.0 | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/plain; charset=UTF-8 | ||
|
||
Hi Bobby, | ||
|
||
Your workspace bobby-workspace has reached the memory usage threshold set a= | ||
t 90%. | ||
|
||
|
||
View workspace: http://test.com/@bobby/bobby-workspace | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4 | ||
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/html; charset=UTF-8 | ||
|
||
<!doctype html> | ||
<html lang=3D"en"> | ||
<head> | ||
<meta charset=3D"UTF-8" /> | ||
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale= | ||
=3D1.0" /> | ||
<title>Your workspace "bobby-workspace" is low on memory</title> | ||
</head> | ||
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-= | ||
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel= | ||
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617= | ||
; background: #f8fafc;"> | ||
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde= | ||
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig= | ||
n: left; font-size: 14px; line-height: 1.5;"> | ||
<div style=3D"text-align: center;"> | ||
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod= | ||
er Logo" style=3D"height: 40px;" /> | ||
</div> | ||
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m= | ||
argin: 8px 0 32px; line-height: 1.5;"> | ||
Your workspace "bobby-workspace" is low on memory | ||
</h1> | ||
<div style=3D"line-height: 1.5;"> | ||
<p>Hi Bobby,</p> | ||
|
||
<p>Your workspace <strong>bobby-workspace</strong> has reached the memory u= | ||
sage threshold set at <strong>90%</strong>.</p> | ||
</div> | ||
<div style=3D"text-align: center; margin-top: 32px;"> | ||
=20 | ||
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display= | ||
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa= | ||
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;"> | ||
View workspace | ||
</a> | ||
=20 | ||
</div> | ||
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz= | ||
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;"> | ||
<p>© 2024 Coder. All rights reserved - <a = | ||
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h= | ||
ttp://test.com</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo= | ||
r: #2563eb; text-decoration: none;">Click here to manage your notification = | ||
settings</a></p> | ||
<p><a href=3D"http://test.com/settings/notifications?disabled=3Da9d= | ||
027b4-ac49-4fb1-9f6d-45af15f64e7a" style=3D"color: #2563eb; text-decoration= | ||
: none;">Stop receiving emails like this</a></p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4-- |
Oops, something went wrong.
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.
Nit: same test name twice.