Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a34d59

Browse files
committed
chore(coderd/notifications): avoid generating warning logs for trivial enqueue failures
1 parentf5fac29 commit3a34d59

File tree

7 files changed

+15
-9
lines changed

7 files changed

+15
-9
lines changed

‎coderd/agentapi/resources_monitoring.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (a *ResourcesMonitoringAPI) monitorMemory(ctx context.Context, datapoints [
161161
workspace.OwnerID,
162162
workspace.OrganizationID,
163163
)
164-
iferr!=nil {
164+
iferr!=nil&&notifications.IsSeriousEnqueueError(err){
165165
returnxerrors.Errorf("notify workspace OOM: %w",err)
166166
}
167167

@@ -254,7 +254,7 @@ func (a *ResourcesMonitoringAPI) monitorVolumes(ctx context.Context, datapoints
254254
workspace.ID,
255255
workspace.OwnerID,
256256
workspace.OrganizationID,
257-
);err!=nil {
257+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
258258
returnxerrors.Errorf("notify workspace OOD: %w",err)
259259
}
260260

‎coderd/notifications/enqueuer.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ var (
2626
ErrDuplicate=xerrors.New("duplicate notification")
2727
)
2828

29+
// IsSeriousEnqueueError filters out trivial errors which can be ignored by
30+
// most callers of Enqueue.
31+
funcIsSeriousEnqueueError(errerror)bool {
32+
return!xerrors.Is(err,ErrCannotEnqueueDisabledNotification)&&!xerrors.Is(err,ErrDuplicate)
33+
}
34+
2935
typeInvalidDefaultNotificationMethodErrorstruct {
3036
Methodstring
3137
}

‎coderd/notifications/reports/generator.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func reportFailedWorkspaceBuilds(ctx context.Context, logger slog.Logger, db dat
205205
reportData,
206206
"report_generator",
207207
slice.Unique(targets)...,
208-
);err!=nil {
208+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
209209
logger.Warn(ctx,"failed to send a report with failed workspace builds",slog.Error(err))
210210
}
211211
}

‎coderd/users.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,15 +951,15 @@ func (api *API) notifyUserStatusChanged(ctx context.Context, actingUserName stri
951951
if_,err:=api.NotificationsEnqueuer.EnqueueWithData(dbauthz.AsNotifier(ctx),u.ID,adminTemplateID,
952952
labels,data,"api-put-user-status",
953953
targetUser.ID,
954-
);err!=nil {
954+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
955955
api.Logger.Warn(ctx,"unable to notify about changed user's status",slog.F("affected_user",targetUser.Username),slog.Error(err))
956956
}
957957
}
958958
// nolint:gocritic // Need notifier actor to enqueue notifications
959959
if_,err:=api.NotificationsEnqueuer.EnqueueWithData(dbauthz.AsNotifier(ctx),targetUser.ID,personalTemplateID,
960960
labels,data,"api-put-user-status",
961961
targetUser.ID,
962-
);err!=nil {
962+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
963963
api.Logger.Warn(ctx,"unable to notify user about status change of their account",slog.F("affected_user",targetUser.Username),slog.Error(err))
964964
}
965965
returnnil
@@ -1518,7 +1518,7 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
15181518
},
15191519
"api-users-create",
15201520
user.ID,
1521-
);err!=nil {
1521+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
15221522
api.Logger.Warn(ctx,"unable to notify about created user",slog.F("created_user",user.Username),slog.Error(err))
15231523
}
15241524
}

‎coderd/workspacebuilds.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func (api *API) notifyWorkspaceUpdated(
605605
"api-workspaces-updated",
606606
// Associate this notification with all the related entities
607607
workspace.ID,workspace.OwnerID,workspace.TemplateID,workspace.OrganizationID,
608-
);err!=nil {
608+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
609609
log.Warn(ctx,"failed to notify of workspace update",slog.Error(err))
610610
}
611611
}

‎coderd/workspaces.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ func (api *API) notifyWorkspaceCreated(
974974
"api-workspaces-create",
975975
// Associate this notification with all the related entities
976976
workspace.ID,workspace.OwnerID,workspace.TemplateID,workspace.OrganizationID,
977-
);err!=nil {
977+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
978978
log.Warn(ctx,"failed to notify of workspace creation",slog.Error(err))
979979
}
980980
}

‎enterprise/coderd/prebuilds/reconcile.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ func (c *StoreReconciler) trackResourceReplacement(ctx context.Context, workspac
903903
},"prebuilds_reconciler",
904904
// Associate this notification with all the related entities.
905905
workspace.ID,workspace.OwnerID,workspace.TemplateID,templateVersion.ID,prebuildPreset.ID,workspace.OrganizationID,
906-
);err!=nil {
906+
);err!=nil&&notifications.IsSeriousEnqueueError(err){
907907
notifErr=errors.Join(xerrors.Errorf("send notification to %q: %w",templateAdmin.ID.String(),err))
908908
continue
909909
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp