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

fix(coderd): mark sub agent deletion via boolean instead of delete#18411

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mafredri wants to merge6 commits intomain
base:main
Choose a base branch
Loading
frommafredri/fix-subagent-deletion

Conversation

mafredri
Copy link
Member

@mafredrimafredri commentedJun 17, 2025
edited
Loading

Since deletion of data is uncommon in our database, the introduction of sub agents and their deletion introduced issues with foreign key assumptions incoder/internal#685. We could have only addressed the specific case by allowing cascade deletion of stats as well as handling in the stats collector, but it's unclear how many more such edge-cases we would've run into.

For this reason, we decided to mark the rows as deleted via boolean instead, and filter them out in all queries that seem relevant so that coderd doesn't see the deleted agents.

Testing is covered by updating the relevantagentapi tests as well as adding an antagonist deleted agent todbgen which automatically gets applied to all tests.

Fixescoder/internal#685

Note that there are some queries that readworkspace_agents that were not updated with deletion handling, but each one was analyzed and deemed unnecessary because of how they are used, doing so may introduce more harm than good. On that note, many of these queries can return results for non-latest builds which essentially means, "deleted" agents.

@mafredrimafredriforce-pushed themafredri/fix-subagent-deletion branch fromdb5700a to7d73585CompareJune 18, 2025 10:29

// Add a test antagonist. For every agent we add a deleted sub agent
// to discover cases where deletion should be handled.
subAgt,err:=db.InsertWorkspaceAgent(genCtx, database.InsertWorkspaceAgentParams{
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Review: This may be a bit unusual, but it already helped me catch an issue with theworkspace_prebuilds VIEW.

Ideally this potential cause would somehow be propagated to the user in case of test failure, but not sure how that could be done. I'll add a log entry to help with discovery.

Copy link
Member

Choose a reason for hiding this comment

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

I like this a lot! I do agree that it could get confusing to troubleshoot, but the log message in combination withdbtestutil.DumpOnFailure should help. You could also potentially set some relevant fields of the sub-agent so that its purpose is clear.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

How about this? 😆bc370a8 (#18411)

@mafredrimafredri marked this pull request as ready for reviewJune 18, 2025 12:06

Choose a reason for hiding this comment

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

🚫[linkspector]reported byreviewdog 🐶
Cannot reachhttps://splunk.com Status: null Navigation timeout of 30000 ms exceeded

categorized using any log management tool such as[Splunk](https://splunk.com).

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

I spot-checked the migrations and the updated views/triggers look OK to me.

Would like a second pair of eyes on this for approval in case there's something I missed.

mafredri reacted with heart emoji

// Add a test antagonist. For every agent we add a deleted sub agent
// to discover cases where deletion should be handled.
subAgt,err:=db.InsertWorkspaceAgent(genCtx, database.InsertWorkspaceAgentParams{
Copy link
Member

Choose a reason for hiding this comment

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

I like this a lot! I do agree that it could get confusing to troubleshoot, but the log message in combination withdbtestutil.DumpOnFailure should help. You could also potentially set some relevant fields of the sub-agent so that its purpose is clear.

Comment on lines +360 to +367
UPDATE
workspace_agents
SET
deleted= TRUE
WHERE
id= $1
AND parent_idIS NOT NULL
AND deleted= FALSE;
Copy link
Member

Choose a reason for hiding this comment

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

👍 literally impossible to delete a 'top-level' agent.

Copy link
Member

Choose a reason for hiding this comment

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

obligatory reminder to check migration number!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@johnstcnjohnstcnjohnstcn left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@EmyrkEmyrkAwaiting requested review from Emyrk

@SasSwartSasSwartAwaiting requested review from SasSwart

@DanielleMaywoodDanielleMaywoodAwaiting requested review from DanielleMaywood

At least 1 approving review is required to merge this pull request.

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Devcontainers: As a side-effect of deleting agents, it's possible for the stats collector to become sad
2 participants
@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp