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

feat(maestro): update error message not showing and on update sink no… #2712

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: 5 additions & 1 deletion maestro/deployment/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func (d *deploymentService) UpdateDeployment(ctx context.Context, deployment *De
if err != nil {
return err
}
err = d.maestroProducer.PublishSinkStatus(ctx, deployment.OwnerID, deployment.SinkID, "unknown", "")
if err != nil {
return err
}
d.logger.Info("updated deployment", zap.String("ownerID", updated.OwnerID),
zap.String("sinkID", updated.SinkID))
return nil
Expand Down Expand Up @@ -254,7 +258,7 @@ func (d *deploymentService) UpdateStatus(ctx context.Context, ownerID string, si
d.logger.Info("updated deployment status",
zap.String("ownerID", updated.OwnerID), zap.String("sinkID", updated.SinkID),
zap.String("status", updated.LastStatus), zap.String("errorMessage", updated.LastErrorMessage))
err = d.maestroProducer.PublishSinkStatus(ctx, updated.OwnerID, updated.SinkID, updated.LastStatus, "")
err = d.maestroProducer.PublishSinkStatus(ctx, updated.OwnerID, updated.SinkID, updated.LastStatus, errorMessage)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions sinks/postgres/sinks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,16 @@ func TestUpdateSinkState(t *testing.T) {

for desc, tc := range cases {
t.Run(desc, func(t *testing.T) {
ctx := context.WithValue(context.Background(), "test", desc)
err := sinkRepo.UpdateSinkState(context.Background(), tc.sinkID, tc.msg, tc.ownerID, tc.state)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", desc, tc.err, err))
// only validate success scenarios
if tc.err == nil {
got, err := sinkRepo.RetrieveById(ctx, sinkID)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", desc, tc.err, err))
assert.Equal(t, tc.state, got.State, fmt.Sprintf("%s: expected state %d got %d", desc, tc.state, got.State))
assert.Equal(t, tc.msg, got.Error, fmt.Sprintf("%s: expected msg %s got %s", desc, tc.msg, got.Error))
}
})
}

Expand Down
6 changes: 1 addition & 5 deletions sinks/sinks_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ func (svc sinkService) UpdateSink(ctx context.Context, token string, sink Sink)
defaultMetadata := make(types.Metadata, 1)
defaultMetadata["opentelemetry"] = "enabled"
sink.Config.Merge(defaultMetadata)
sink.State = Unknown
sink.Error = ""
if sink.Format == "yaml" {
configDataByte, err := yaml.Marshal(sink.Config)
if err != nil {
Expand Down Expand Up @@ -475,9 +473,7 @@ func (svc sinkService) ChangeSinkStateInternal(ctx context.Context, sinkID strin
}

func (svc sinkService) validateBackend(sink *Sink) (be backend.Backend, err error) {
if backend.HaveBackend(sink.Backend) {
sink.State = Unknown
} else {
if !backend.HaveBackend(sink.Backend) {
return nil, ErrInvalidBackend
}
sinkBe := backend.GetBackend(sink.Backend)
Expand Down
Loading