You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deleted userdata owned by a deleted account remains linked with the template #9477
Deleted userdata owned by a deleted account remains linked with the template. In UI it produces a 404 error. During VM deployment with the linked template it return error like, UserData linked to the template CentOS 5.6(64-bit) no GUI (XenServer) is not found
STEPS TO REPRODUCE
1. As the admin, create a new user account
2. As the new user, register a userdata
3. As the admin, link the userdata to a template
4. As the admin, delete the new user
5. Observer userdata remains linked to the template
deleted-userdata.mp4
EXPECTED RESULTS
Maybe either an error while deleting the user account or the userdata that gets deleted is unlinked from the template
Regarding the fix, I think we should allow linking of the userdata to the template only if both are created by that user.
If we have to go with the fix of restricting the deletion of the user just because he/she created a userdata and linked to a template.
Regarding the fix, I think we should allow linking of the userdata to the template only if both are created by that user. If we have to go with the fix of restricting the deletion of the user just because he/she created a userdata and linked to a template.
@harikrishna-patnala , that doesn't sound right. Let's discuss the scenarios, as the one described by @shwstppr is certainly not the only one that pertains to this linkage of resources:
an account-user created a userdata entry
another account-user created a template
now several things may happen
the first user does the linking, or the second
the first user get deleted, or the second
the template gets deleted (while VMs are still running) though I am not sure of the latests guards against that.
on the one hand, removing the link might be resulting in unexpected behaviour of the VMs/template. On the other hand, a delete with cleanup should work on the account (and thus the user).
@DaanHoogland I don't think so, I think with the current state users may think the user data will still be applied but it wouldn't as its removed during the user removal.
Edit: after quick sync with @DaanHoogland we have defined to mark the user_data_id field and policy for each template as NULL and log the number of updated templates during the user data deletion within the account removal operation
When a user account is deleted, its userdata is removed from the DB, but the user_data_id foreign key on vm_template is not nulled out. This leaves templates pointing to a deleted/non-existent userdata record, causing 404 errors in the UI and deployment failures. A PR (#11595) is already in flight with the agreed fix of setting user_data_id = NULL on affected templates during user deletion.
📊 Assessment
Dimension
Value
Reasoning
Type
type:bug
Data-integrity defect — dangling FK after account deletion
Component
component:management-server
Server-side account removal logic
Severity
Severity:Minor
Causes errors only when deploying from affected templates; workaround exists (re-link or remove userdata)
Root cause confirmed, fix agreed in comments: null user_data_id + user_data_policy on vm_template rows during userdata removal in account cleanup
🔗 Similar issues
No distinct duplicate found; the original discussion and fix are tracked within this issue and PR #11595.
💡 Notes and suggestions
Fix location: AccountManagerImpl / UserDataServiceImpl — during deleteUserData invoked by account cleanup, add a step to UPDATE vm_template SET user_data_id = NULL, user_data_policy = NULL WHERE user_data_id = ?.
Also verify listUserDatas API and template-link logic to prevent cross-account linkage that could cause similar orphaning.
Activity
shwstppr commentedon Aug 1, 2024
@harikrishna-patnala any thoughts on this
harikrishna-patnala commentedon Aug 8, 2024
Yes @shwstppr seems like a valid issue.
Regarding the fix, I think we should allow linking of the userdata to the template only if both are created by that user.
If we have to go with the fix of restricting the deletion of the user just because he/she created a userdata and linked to a template.
DaanHoogland commentedon Aug 12, 2024
@harikrishna-patnala , that doesn't sound right. Let's discuss the scenarios, as the one described by @shwstppr is certainly not the only one that pertains to this linkage of resources:
on the one hand, removing the link might be resulting in unexpected behaviour of the VMs/template. On the other hand, a delete with cleanup should work on the account (and thus the user).
16 remaining items
nvazquez commentedon Jan 15, 2026
@DaanHoogland I don't think so, I think with the current state users may think the user data will still be applied but it wouldn't as its removed during the user removal.
Edit: after quick sync with @DaanHoogland we have defined to mark the user_data_id field and policy for each template as NULL and log the number of updated templates during the user data deletion within the account removal operation
nvazquez commentedon Jan 15, 2026
Hi @DaanHoogland @shwstppr @harikrishna-patnala I have created the PR #12439, can you please review?
nvazquez commentedon Jan 20, 2026
@DaanHoogland @shwstppr as discussed I have closed my PR #12439 in favour of #11595
github-actions commentedon Jul 1, 2026
🎯 Triage report
When a user account is deleted, its userdata is removed from the DB, but the
user_data_idforeign key onvm_templateis not nulled out. This leaves templates pointing to a deleted/non-existent userdata record, causing 404 errors in the UI and deployment failures. A PR (#11595) is already in flight with the agreed fix of settinguser_data_id = NULLon affected templates during user deletion.📊 Assessment
user_data_id+user_data_policyonvm_templaterows during userdata removal in account cleanup🔗 Similar issues
No distinct duplicate found; the original discussion and fix are tracked within this issue and PR #11595.
💡 Notes and suggestions
AccountManagerImpl/UserDataServiceImpl— duringdeleteUserDatainvoked by account cleanup, add a step toUPDATE vm_template SET user_data_id = NULL, user_data_policy = NULL WHERE user_data_id = ?.listUserDatasAPI and template-link logic to prevent cross-account linkage that could cause similar orphaning.Add this agentic workflows to your repo
To install this agentic workflow, run