Skip to content

Conversation

ibetitsmike
Copy link
Contributor

This PR refactors the CompleteJob function to use database transactions more consistently for better atomicity guarantees. The large function was broken down into three specialized handlers:

  • completeTemplateImportJob
  • completeWorkspaceBuildJob
  • completeTemplateDryRunJob

Each handler now uses the Database.InTx wrapper to ensure all database operations for a job completion are performed within a single transaction, preventing partial updates in case of failures.

Added comprehensive tests for transaction behavior for each job type.

Fixes #17694

🤖 Generated with Claude Code

This commit refactors the CompleteJob function in provisionerdserver.go to
use database transactions more consistently for better atomicity guarantees.
The large function was broken down into three specialized handlers:

- completeTemplateImportJob
- completeWorkspaceBuildJob
- completeTemplateDryRunJob

Each handler now uses the Database.InTx wrapper to ensure all database
operations for a job completion are performed within a single transaction,
preventing partial updates in case of failures.

Added comprehensive tests for transaction behavior for each job type.

Fixes #17694

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Since this is just a refactor, I found these diffs easier to grok.
The only diff is in workspace build, the insertion of timings was moved

Template import: https://www.diffchecker.com/ugtjYQgz/
Workspace build: https://www.diffchecker.com/KuvTwAPu/
DryRun: https://www.diffchecker.com/MxShZo2U/

@ibetitsmike ibetitsmike merged commit b7462fb into main May 21, 2025
31 checks passed
@ibetitsmike ibetitsmike deleted the mike/claude-attempts-17694 branch May 21, 2025 14:48
@github-actions github-actions bot locked and limited conversation to collaborators May 21, 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.

Provisioner CompleteJob should do all db operations in a transaction
2 participants