Skip to content

chore(coderd/database): enforce agent name unique within workspace build #18052

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 13 commits into from
May 28, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented May 27, 2025

This PR creates a database trigger that runs on insert and update of the workspace_agents table. The trigger ensures that the agent name is unique within the context of the workspace build it is being inserted into.

@DanielleMaywood DanielleMaywood force-pushed the dm-workspace-agent-name-uniqueness branch from 053251c to 2aadf9f Compare May 27, 2025 14:19
@DanielleMaywood DanielleMaywood marked this pull request as ready for review May 27, 2025 14:20
@DanielleMaywood DanielleMaywood changed the title chore(coderd/database): create db trigger to enforce agent name is unique chore(coderd/database): enforce agent name unique within workspace resource May 27, 2025
…eness

This PR creates a new database trigger to ensure an inserted workspace
agent has a unique name within the scope of its workspace.
Child agents are a new concept so there are very little existing tests
for them. This means we can easily make the change for them without
having to update a mountain of tests. So they get a special case for
checking properly, whilst parent agents have less scrutiny due to the
vast number of tests that appear to not work properly.
@DanielleMaywood DanielleMaywood force-pushed the dm-workspace-agent-name-uniqueness branch from c331dca to e51c8be Compare May 27, 2025 15:00
The CI will fail for this as there are test failures for insights.
@DanielleMaywood DanielleMaywood changed the title chore(coderd/database): enforce agent name unique within workspace resource chore(coderd/database): enforce agent name unique within provisioner job May 27, 2025
@DanielleMaywood DanielleMaywood changed the title chore(coderd/database): enforce agent name unique within provisioner job chore(coderd/database): enforce agent name unique within workspace build May 28, 2025
@DanielleMaywood DanielleMaywood requested a review from mafredri May 28, 2025 12:26
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Minor suggestions but otherwise looking good, nice job!

- add a comment on trigger
- spaces to tabs
@DanielleMaywood DanielleMaywood merged commit 6e255c7 into main May 28, 2025
29 checks passed
@DanielleMaywood DanielleMaywood deleted the dm-workspace-agent-name-uniqueness branch May 28, 2025 13:21
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2025
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.

3 participants