- Notifications
You must be signed in to change notification settings - Fork1.1k
Description
I have searched for similar issues.
Secondary effect is log lines where the logging methods fail (i.e. WebHooks) causes a fair amount of noise/retries.
Description
When a template's dormancy settings are enabled or disabled, the system sends out "Workspace marked for deletion" notifications. These notifications are being sent for all dormant workspaces associated with the template, including those that have already been deleted. This results in users receiving a large volume of confusing and irrelevant notifications.
The root cause is that the database query responsible for identifying workspaces to update does not filter out workspaces that are already in a "deleted" state.
Steps to Reproduce
- Create a template.
- Create a workspace from this template.
- Delete the workspace.
- Enable or modify the "Time until dormant auto-deletion" setting on the template.
- Observe that a "Workspace marked for deletion" notification is sent for the already-deleted workspace.
Expected Behavior
When a template's dormancy settings are changed, notifications should only be sent for active, dormant workspaces that are affected by the change. No notifications should be sent for workspaces that have already been deleted.
Actual Behavior
Notifications are sent for all dormant workspaces associated with the template, including those that have already been deleted.
Affected Functions and Files for Review
Based on the analysis, the following files and functions are relevant to this issue and may need review:
coder/coderd/database/queries.sql.go:- The SQL query
updateWorkspacesDormantDeletingAtByTemplateIDis the primary source of the issue. It needs to be modified to filter out deleted workspaces by addingAND deleted = falseto theWHEREclause.
- The SQL query
coder/enterprise/coderd/schedule/template.go:- The
Setmethod inEnterpriseTemplateScheduleStorecalls the aforementioned database query and then enqueues the notifications. This is the high-level logic that orchestrates the faulty behavior.
- The
coder/coderd/autobuild/lifecycle_executor.go:- This file contains related logic for workspace lifecycle management and may be worth reviewing to ensure consistency.
coder/coderd/templates.goandcoder/coderd/workspaces.go:- These files handle API requests related to templates and workspaces and are part of the call chain.