Skip to content

feat: notify about manual failed builds #14419

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 16 commits into from
Aug 27, 2024
Merged

feat: notify about manual failed builds #14419

merged 16 commits into from
Aug 27, 2024

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Aug 23, 2024

Fixes: coder/internal#16

This PR modifies ProvisionerdServer to notify template admins about manual workspace build failures.

@mtojek mtojek self-assigned this Aug 23, 2024
@mtojek mtojek marked this pull request as ready for review August 26, 2024 13:14
Comment on lines +1851 to +1861
assert.Equal(t, notifEnq.Sent[0].UserID, templateAdmin.ID)
assert.Equal(t, notifEnq.Sent[0].TemplateID, notifications.TemplateWorkspaceManualBuildFailed)
assert.Contains(t, notifEnq.Sent[0].Targets, template.ID)
assert.Contains(t, notifEnq.Sent[0].Targets, workspace.ID)
assert.Contains(t, notifEnq.Sent[0].Targets, workspace.OrganizationID)
assert.Contains(t, notifEnq.Sent[0].Targets, user.ID)
assert.Equal(t, workspace.Name, notifEnq.Sent[0].Labels["name"])
assert.Equal(t, template.Name, notifEnq.Sent[0].Labels["template_name"])
assert.Equal(t, version.Name, notifEnq.Sent[0].Labels["template_version_name"])
assert.Equal(t, user.Username, notifEnq.Sent[0].Labels["initiator"])
assert.Equal(t, user.Username, notifEnq.Sent[0].Labels["workspace_owner_username"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these assertions could be passed into the previous table-based test "Workspace build failed"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a significant difference as here we expect notifications sent only to template admins, we don't care about workspace owners. I tried to squeeze this unit test as much as possible.

@@ -1150,15 +1130,43 @@ func (s *server) notifyWorkspaceManualBuildFailed(ctx context.Context, workspace
"template_version_name": templateVersion.Name,
"initiator": build.InitiatorByUsername,
"workspace_owner_username": workspaceOwner.Username,
"workspace_build_number": strconv.Itoa(int(build.BuildNumber)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including this will mean that deduplication won't be possible, just so you're aware.

@mtojek mtojek requested a review from johnstcn August 27, 2024 13:24
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mtojek mtojek enabled auto-merge (squash) August 27, 2024 14:27
@mtojek mtojek merged commit 47f2c7d into main Aug 27, 2024
30 checks passed
@mtojek mtojek deleted the 16-manual-build-failed branch August 27, 2024 14:35
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: template notifications
4 participants