diff --git a/pkg/service/cluster.go b/pkg/service/cluster.go index e15fcac..6cecaa8 100644 --- a/pkg/service/cluster.go +++ b/pkg/service/cluster.go @@ -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{ diff --git a/pkg/service/group.go b/pkg/service/group.go index 157a7ad..c1a1da9 100644 --- a/pkg/service/group.go +++ b/pkg/service/group.go @@ -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 } diff --git a/pkg/service/role.go b/pkg/service/role.go index 2fa2751..56572e6 100644 --- a/pkg/service/role.go +++ b/pkg/service/role.go @@ -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 } diff --git a/pkg/service/user.go b/pkg/service/user.go index bf62087..1b1e1e0 100644 --- a/pkg/service/user.go +++ b/pkg/service/user.go @@ -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 }