fix(cubemaster): clean job rows after snapshot delete#559
Conversation
2c77322 to
879453f
Compare
PR #559 Review: fix(cubemaster): clean job rows after snapshot deleteOverviewThis PR correctly fixes a bug where deleted snapshots reappeared in ListTemplates due to orphan template_image_job rows creating fallback entries. The fix replaces the old updateTemplateImageJob (set job row to READY) with runTemplateJobCleanup (DELETE job rows) and returns a terminal READY view from cloneTemplateImageJobInfo instead of re-querying deleted rows. The changes are well-scoped, the root-cause analysis in the PR description is accurate, and the test suite covers the new behavior effectively. After reviewing across code quality, performance, test coverage, security, and documentation dimensions, I found a few areas worth addressing: Notable Findings1. Retry-failure returns success silently - snapshot_ops.go:730-738 2. Empty-slice inconsistency in cloneTemplateImageJobInfo - job_dto.go:60 3. Missing doc on terminalSnapshotDeleteJobInfo - snapshot_ops.go:694 Overall AssessmentThe fix is correct and well-implemented. The clone-and-stamp pattern in executeSnapshotDeleteJob is the right approach - it avoids a DB ound-trip for a record that has just been deleted. The test coverage is comprehensive for the PR scope, and the performance impact is positive (fewer DB calls per delete operation). None of the findings above are blocking; they are refinements for production robustness and maintainability. |
879453f to
8530777
Compare
da06591 to
a72e918
Compare
bb29ce1 to
52de0c7
Compare
52de0c7 to
82c25af
Compare
82c25af to
f960975
Compare
f9e1be3 to
5b0d15a
Compare
5b0d15a to
7ea0c4f
Compare
7ea0c4f to
085b5f1
Compare
Snapshot delete removed template_definition but left template_image_job rows, so ListTemplates still surfaced deleted snapshots via orphan job fallback. Mirror template delete by calling runTemplateJobCleanup after metadata cleanup, and return a terminal READY job view without re-querying deleted rows. Signed-off-by: xiaojunxiang <xiaojunxiang@kingsoft.com>
085b5f1 to
5a8e857
Compare
…ud#559) Snapshot delete removed template_definition but left template_image_job rows, so ListTemplates still surfaced deleted snapshots via orphan job fallback. Mirror template delete by calling runTemplateJobCleanup after metadata cleanup, and return a terminal READY job view without re-querying deleted rows. Signed-off-by: xiaojunxiang <xiaojunxiang@kingsoft.com>
Summary
Fixes a bug where deleted snapshots still appeared in template list APIs until a second delete.
After the first
DELETE /templates/{snapshotID}:GET /templatesandcubemastercli tpl lsstill listed the deleted snapshotRoot cause
Snapshot delete (
runSnapshotDeleteJob) removedtemplate_definitionmetadata but did not remove relatedtemplate_image_jobrows.ListTemplatesappends orphan job records when no definition exists:So the deleted snapshot was resurrected in list responses via job fallback entries.
On the second delete,
has_snapshotreturned false (definition gone, job fallback has noKind), routing the request through template delete (cleanupTemplateJobs) instead of snapshot delete.Fix
cleanupTemplateJobsafter successful snapshot metadata cleanup, matching template delete behaviorexecuteSnapshotDeleteJobwithout re-querying job rows that were just deletedDeploy And Verify