-
Notifications
You must be signed in to change notification settings - Fork 952
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
Conversation
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
053251c
to
2aadf9f
Compare
…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.
c331dca
to
e51c8be
Compare
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
The CI will fail for this as there are test failures for insights.
mafredri
reviewed
May 28, 2025
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000331_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
- replace spaces with tabs. - remove _var suffixes. - check if provisioner job as a workspace build
mafredri
approved these changes
May 28, 2025
There was a problem hiding this 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!
coderd/database/migrations/000332_workspace_agent_name_unique_trigger.up.sql
Outdated
Show resolved
Hide resolved
coderd/database/migrations/000332_workspace_agent_name_unique_trigger.up.sql
Show resolved
Hide resolved
- add a comment on trigger - spaces to tabs
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.