mirror of
https://github.com/paralus/paralus.git
synced 2026-05-06 08:26:53 +00:00
Rollback and log when commit fails
This commit is contained in:
@@ -292,7 +292,8 @@ func (es *clusterService) Create(ctx context.Context, cluster *infrav3.Cluster)
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
|
||||
ev := event.Resource{
|
||||
|
||||
@@ -316,7 +316,8 @@ func (s *groupService) Create(ctx context.Context, group *userv3.Group) (*userv3
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return group, nil
|
||||
}
|
||||
@@ -450,7 +451,8 @@ func (s *groupService) Update(ctx context.Context, group *userv3.Group) (*userv3
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
|
||||
// update spec and status
|
||||
@@ -499,7 +501,8 @@ func (s *groupService) Delete(ctx context.Context, group *userv3.Group) (*userv3
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return group, nil
|
||||
}
|
||||
|
||||
@@ -177,7 +177,8 @@ func (s *roleService) Create(ctx context.Context, role *rolev3.Role) (*rolev3.Ro
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return role, nil
|
||||
|
||||
@@ -279,7 +280,8 @@ func (s *roleService) Update(ctx context.Context, role *rolev3.Role) (*rolev3.Ro
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return role, nil
|
||||
}
|
||||
@@ -320,7 +322,8 @@ func (s *roleService) Delete(ctx context.Context, role *rolev3.Role) (*rolev3.Ro
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return role, nil
|
||||
}
|
||||
|
||||
@@ -277,7 +277,8 @@ func (s *userService) Create(ctx context.Context, user *userv3.User) (*userv3.Us
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
|
||||
rl, err := s.ap.GetRecoveryLink(ctx, id)
|
||||
@@ -430,7 +431,8 @@ func (s *userService) Update(ctx context.Context, user *userv3.User) (*userv3.Us
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
@@ -473,7 +475,8 @@ func (s *userService) Delete(ctx context.Context, user *userv3.User) (*userrpcv3
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Println("unable to commit changes", err)
|
||||
tx.Rollback()
|
||||
_log.Warn("unable to commit changes", err)
|
||||
}
|
||||
return &userrpcv3.DeleteUserResponse{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user