Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add transaction for artifact delete #16506

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

wy65701436
Copy link
Contributor

Add transaction for artifact deletion, given API has the transaction when to call artifact controller but other object may not, for example jobservice job.
Here, force add the tx to ensure all the things can be rolled back.

Signed-off-by: Wang Yan wangyan@vmware.com

@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

Merging #16506 (00fc86f) into main (b5a05dd) will decrease coverage by 0.16%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16506      +/-   ##
==========================================
- Coverage   67.44%   67.28%   -0.17%     
==========================================
  Files         949      949              
  Lines       78812    78382     -430     
  Branches     2321     2321              
==========================================
- Hits        53158    52742     -416     
+ Misses      22105    22093      -12     
+ Partials     3549     3547       -2     
Flag Coverage Δ
unittests 67.28% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/controller/artifact/controller.go 64.28% <0.00%> (-0.43%) ⬇️
src/server/v2.0/restapi/embedded_spec.go 100.00% <0.00%> (ø)
src/core/label/manager.go 45.71% <0.00%> (+0.25%) ⬆️
src/jobservice/runner/redis.go 67.82% <0.00%> (+5.21%) ⬆️
...-nav/gc-page/gc/gc-history/gc-history.component.ts 60.37% <0.00%> (+9.43%) ⬆️

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -311,7 +311,12 @@ func (c *controller) Delete(ctx context.Context, id int64) error {
if err != nil {
return err
}
return c.deleteDeeply(ctx, id, true, len(accs) > 0)
if err := orm.WithTransaction(func(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

return orm.WithTransaction(func(ctx context.Context) error {
    return c.deleteDeeply(ctx, id, true, len(accs) > 0)
})(orm.SetTransactionOpNameToContext(ctx, "tx-delete-artifact-delete"))

Add transaction for artifact deletion, given API has the transaction when to call artifact controller but other object may not, for example jobservice job.
Here, force add the tx to ensure all the things can be rolled back.

Signed-off-by: Wang Yan <wangyan@vmware.com>
@wy65701436 wy65701436 merged commit ef991ae into goharbor:main Mar 11, 2022
sluetze pushed a commit to sluetze/harbor that referenced this pull request Oct 29, 2022
Add transaction for artifact deletion, given API has the transaction when to call artifact controller but other object may not, for example jobservice job.
Here, force add the tx to ensure all the things can be rolled back.

Signed-off-by: Wang Yan <wangyan@vmware.com>
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.

3 participants