mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: fix dormancy notifications (#14029)
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtime"
|
||||
"github.com/coder/coder/v2/coderd/dormancy"
|
||||
"github.com/coder/coder/v2/coderd/notifications"
|
||||
agpl "github.com/coder/coder/v2/coderd/schedule"
|
||||
"github.com/coder/coder/v2/coderd/tracing"
|
||||
@@ -205,18 +204,25 @@ func (s *EnterpriseTemplateScheduleStore) Set(ctx context.Context, db database.S
|
||||
return database.Template{}, err
|
||||
}
|
||||
|
||||
for _, workspace := range markedForDeletion {
|
||||
_, err = dormancy.NotifyWorkspaceMarkedForDeletion(
|
||||
for _, ws := range markedForDeletion {
|
||||
_, err = s.enqueuer.Enqueue(
|
||||
ctx,
|
||||
s.enqueuer,
|
||||
dormancy.WorkspaceMarkedForDeletionNotification{
|
||||
Workspace: workspace,
|
||||
Reason: "template updated to new dormancy policy",
|
||||
CreatedBy: "scheduletemplate",
|
||||
ws.OwnerID,
|
||||
notifications.TemplateWorkspaceMarkedForDeletion,
|
||||
map[string]string{
|
||||
"name": ws.Name,
|
||||
"reason": "an update to the template's dormancy",
|
||||
"timeTilDormant": opts.TimeTilDormantAutoDelete.String(),
|
||||
},
|
||||
"scheduletemplate",
|
||||
// Associate this notification with all the related entities.
|
||||
ws.ID,
|
||||
ws.OwnerID,
|
||||
ws.TemplateID,
|
||||
ws.OrganizationID,
|
||||
)
|
||||
if err != nil {
|
||||
s.logger.Warn(ctx, "failed to notify of workspace marked for deletion", slog.Error(err), slog.F("workspace_id", workspace.ID))
|
||||
s.logger.Warn(ctx, "failed to notify of workspace marked for deletion", slog.Error(err), slog.F("workspace_id", ws.ID))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user