Skip to content

fix(project): add transactional plugin deletion lifecycle hook - #9091

Open
muzamilkm wants to merge 1 commit into
apache:mainfrom
muzamilkm:fix/project-deletion-hook
Open

fix(project): add transactional plugin deletion lifecycle hook#9091
muzamilkm wants to merge 1 commit into
apache:mainfrom
muzamilkm:fix/project-deletion-hook

Conversation

@muzamilkm

@muzamilkm muzamilkm commented Sep 1, 2026

Copy link
Copy Markdown

Summary

DELETE /projects/:projectName deletes core project state directly, but plugins had no deletion lifecycle extension point. A plugin that persists state tied to a DevLake project therefore had no way to validate or clean up that state when deletion went through the core API.

This PR:

  • adds an optional plugin.ProjectDeleteHook alongside the existing project-related plugin contracts
  • invokes implementing plugins through plugin.TraversalPlugin before core project deletion
  • runs plugin cleanup, blueprint cleanup and core project cleanup inside the same database transaction
  • adds BlueprintManager.DeleteBlueprintInTransaction so blueprint cleanup can participate in the caller's transaction while preserving the existing DeleteBlueprint(id) entry point
  • safely handles projects without an associated blueprint during the unfinished-pipeline check
  • adds regression coverage for optional hook dispatch, hook vetoes, rollback and successful single-transaction deletion

Existing plugins do not need to implement ProjectDeleteHook unless they persist state whose lifecycle is tied to a DevLake project.

Does this close any open issues?

Closes #9081

Screenshots

N/A

Other Information

Backwards compatibility

ProjectService remains unchanged and still only requires RenameProject(...).

ProjectDeleteHook is a separate optional plugin interface, so existing plugins and existing ProjectService implementations remain source-compatible.

The existing BlueprintManager.DeleteBlueprint(id) entry point is preserved. DeleteBlueprintInTransaction only provides a transaction-aware path for callers that already own a transaction.

There are no schema, migration, HTTP API, Config UI or Grafana changes in this PR.

Validation

From backend/:

go test ./core/plugin/... -count=1
go test ./helpers/pluginhelper/services/... -count=1
go test ./server/services/... -count=1

go vet ./core/plugin/... ./helpers/pluginhelper/services/... ./server/services/...

gofmt -w core/plugin/plugin_blueprint.go \
  helpers/pluginhelper/services/blueprint_helper.go \
  helpers/pluginhelper/services/blueprint_helper_test.go \
  server/services/project.go \
  server/services/project_test.go

git diff --check devlakeupstream/main...HEAD

All of the above pass locally.

The new hook contract is documented in core/plugin. No user-facing documentation changes are required.

@muzamilkm
muzamilkm force-pushed the fix/project-deletion-hook branch 3 times, most recently from f63766d to 71f6365 Compare September 1, 2026 19:18
…e#9081)

Project deletion deletes core DevLake records directly without exposing
a lifecycle hook for plugins that maintain project-scoped state.
While project renames provide a lifecycle extension through
ProjectService.RenameProject, there was no equivalent hook for project
deletion.

This commit:
- Introduces optional plugin.ProjectDeleteHook in core/plugin
- Traverses registered plugins via plugin.TraversalPlugin during DeleteProject
- Executes hooks, blueprint cleanup, and project deletion inside a single transaction
- Provides BlueprintManager.DeleteBlueprintInTransaction to participate in caller transaction
- Adds comprehensive unit tests covering hook dispatch, veto rollback, and atomic deletion

Closes apache#9081

Signed-off-by: Muzamil Kaleem <113013457+muzamilkm@users.noreply.github.com>
@muzamilkm
muzamilkm force-pushed the fix/project-deletion-hook branch from 71f6365 to c00fdf7 Compare September 1, 2026 19:33
@muzamilkm muzamilkm changed the title Fix/project deletion hook fix(project): add transactional plugin deletion lifecycle hook Sep 1, 2026
@muzamilkm
muzamilkm marked this pull request as ready for review September 1, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][DevLake] Project deletion lifecycle lacks extension hook for plugin-owned state

1 participant