Skip to content

Commit

Permalink
chore(model): fix deployment reconciliation (#459)
Browse files Browse the repository at this point in the history
Because

- avoid having false state in etcd

This commit

- fix marking model state as `STATE_ERROR` if model exist when creating
  • Loading branch information
heiruwu authored Nov 30, 2023
1 parent acc0eb0 commit 4c89fee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (s *service) TriggerUserModelTestMode(ctx context.Context, modelUID uuid.UU
func (s *service) CheckModel(ctx context.Context, modelUID uuid.UUID) (*modelPB.Model_State, error) {
inferenceModel, err := s.repository.GetInferenceEnsembleModel(modelUID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "ray model not found")
return nil, status.Errorf(codes.NotFound, "model not found")
}

inferenceModelName := inferenceModel.Name
Expand Down Expand Up @@ -381,7 +381,7 @@ func (s *service) TriggerUserModel(ctx context.Context, modelUID uuid.UUID, infe

inferenceModel, err := s.repository.GetInferenceEnsembleModel(modelUID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "triton model not found")
return nil, status.Errorf(codes.NotFound, "model not found")
}

inferenceModelName := inferenceModel.Name
Expand Down
11 changes: 10 additions & 1 deletion pkg/worker/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"go.temporal.io/sdk/activity"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/instill-ai/model-backend/config"
"github.com/instill-ai/model-backend/pkg/datamodel"
Expand Down Expand Up @@ -247,7 +249,14 @@ func (w *worker) CreateModelWorkflow(ctx workflow.Context, param *ModelParams) e
logger.Info("CreateModelWorkflow started")

if err := w.repository.CreateUserModel(param.Model); err != nil {
return err
if e, ok := status.FromError(err); ok {
if e.Code() != codes.AlreadyExists {
return err
} else {
logger.Info("Model already existed, CreateModelWorkflow completed")
return nil
}
}
}

logger.Info("CreateModelWorkflow completed")
Expand Down

0 comments on commit 4c89fee

Please sign in to comment.