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

fix: delete app with hook reference relationship #2706

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bcs-services/bcs-bscp/cmd/data-service/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ func (s *Service) deleteAppRelatedResources(grpcKit *kit.Kit, req *pbds.DeleteAp
return err
}

// delete released hook
if err := s.dao.ReleasedHook().DeleteByAppIDWithTx(grpcKit, tx, req.Id, req.BizId); err != nil {
logs.Errorf("delete released hooks failed, err: %v, rid: %s", err, grpcKit.Rid)
return err
}

return nil
}

Expand Down
15 changes: 15 additions & 0 deletions bcs-services/bcs-bscp/pkg/dal/dao/released_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type ReleasedHook interface {
CreateWithTx(kit *kit.Kit, tx *gen.QueryTx, releasedHook *table.ReleasedHook) (uint32, error)
// ListAll list all released hooks in biz
ListAll(kit *kit.Kit, bizID uint32) ([]*table.ReleasedHook, error)
// DeleteByAppIDWithTx deletes the released hook by app id with transaction.
DeleteByAppIDWithTx(kit *kit.Kit, tx *gen.QueryTx, appID, bizID uint32) error
// DeleteByUniqueKeyWithTx deletes the released hook by unique key with transaction.
DeleteByUniqueKeyWithTx(kit *kit.Kit, tx *gen.QueryTx, rh *table.ReleasedHook) error
// DeleteByHookIDAndReleaseIDWithTx deletes the released hook by hook id and release id with transaction.
Expand Down Expand Up @@ -227,6 +229,19 @@ func (dao *releasedHookDao) ListAll(kit *kit.Kit, bizID uint32) ([]*table.Releas
return rhs, nil
}

// DeleteByAppIDWithTx deletes the released hook by app id with transaction.
func (dao *releasedHookDao) DeleteByAppIDWithTx(kit *kit.Kit, tx *gen.QueryTx, appID, bizID uint32) error {
if bizID == 0 {
return errf.New(errf.InvalidParameter, "bizID is 0")
}
if appID == 0 {
return errf.New(errf.InvalidParameter, "appID is 0")
}
m := tx.ReleasedHook
_, err := m.WithContext(kit.Ctx).Where(m.BizID.Eq(bizID), m.AppID.Eq(appID)).Delete()
return err
}

// DeleteByUniqueKeyWithTx deletes the released hook by unique key with transaction.
func (dao *releasedHookDao) DeleteByUniqueKeyWithTx(kit *kit.Kit, tx *gen.QueryTx, rh *table.ReleasedHook) error {
if rh == nil {
Expand Down
Loading