- Notifications
You must be signed in to change notification settings - Fork1k
feat: notify owner about failed autobuild#13891
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
450db4d
feat: notify owner about failed autobuild
mtojek422fe8b
fix: migrate down
mtojek8970be7
unit test
mtojek3ace8c6
fix
mtojek1001bc1
fix template title
mtojek881dc5e
fix: initiator
mtojek1852953
WIP
mtojek42a1c69
fix: test self-initiated
mtojeke6a5aef
fix: build reason
mtojeka4a5511
fix: copy-paste
mtojek660c2d6
fix: test build reason
mtojek68ae258
render template
mtojek3dd09d2
One more test
mtojekFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
fix: initiator
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit881dc5e7ff8c6b72003fd91fc9aeb1ab153f29b4
There are no files selected for viewing
17 changes: 12 additions & 5 deletionscoderd/provisionerdserver/provisionerdserver.go
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 |
---|---|---|
@@ -1549,6 +1549,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) | ||
func (s *server) notifyWorkspaceDeleted(ctx context.Context, workspace database.Workspace, build database.WorkspaceBuild) { | ||
var reason string | ||
initiator := build.InitiatorByUsername | ||
if build.Reason.Valid() { | ||
switch build.Reason { | ||
case database.BuildReasonInitiator: | ||
@@ -1560,6 +1561,7 @@ func (s *server) notifyWorkspaceDeleted(ctx context.Context, workspace database. | ||
reason = "initiated by user" | ||
case database.BuildReasonAutodelete: | ||
reason = "autodeleted due to dormancy" | ||
initiator = "" | ||
default: | ||
reason = string(build.Reason) | ||
} | ||
@@ -1569,12 +1571,17 @@ func (s *server) notifyWorkspaceDeleted(ctx context.Context, workspace database. | ||
slog.F("reason", reason), slog.F("workspace_id", workspace.ID), slog.F("build_id", build.ID)) | ||
} | ||
labels := map[string]string{ | ||
"name": workspace.Name, | ||
"reason": reason, | ||
} | ||
if initiator != "" { | ||
labels["initiator"] = initiator | ||
} | ||
mtojek marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if _, err := s.NotificationEnqueuer.Enqueue(ctx, workspace.OwnerID, notifications.TemplateWorkspaceDeleted, | ||
labels, "provisionerdserver", | ||
// Associate this notification with all the related entities. | ||
workspace.ID, workspace.OwnerID, workspace.TemplateID, workspace.OrganizationID, | ||
); err != nil { | ||
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.