Skip to content

Commit

Permalink
Prevent status from being overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCao committed Aug 13, 2024
1 parent 1699e04 commit 9c09f68
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/service/controller_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ func (s *ControllerService) Register(ctx context.Context, req *pb.RegisterReques
}
}

if err := s.Update(ctx, exporter); err != nil {
logger.Error(err, "unable to update exporter", "exporter", exporter)
return nil, status.Errorf(codes.Internal, "unable to update exporter: %s", err)
}

exporter.Status.Conditions = []metav1.Condition{{
Type: "Available",
Status: "True",
Expand All @@ -224,11 +229,6 @@ func (s *ControllerService) Register(ctx context.Context, req *pb.RegisterReques
exporter.Status.Uuid = req.Uuid
exporter.Status.Devices = devices

if err := s.Update(ctx, exporter); err != nil {
logger.Error(err, "unable to update exporter", "exporter", exporter)
return nil, status.Errorf(codes.Internal, "unable to update exporter: %s", err)
}

if err := s.Status().Update(ctx, exporter); err != nil {
logger.Error(err, "unable to update exporter status", "exporter", exporter)
return nil, status.Errorf(codes.Internal, "unable to update exporter status: %s", err)
Expand Down

0 comments on commit 9c09f68

Please sign in to comment.