Skip to content

Commit

Permalink
fix: don't overwrite exp status after app running stage executes
Browse files Browse the repository at this point in the history
  • Loading branch information
activeshadow committed Jul 5, 2023
1 parent 7294d4b commit 3641854
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/go/api/scorch/scorchexe/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func Execute(ctx context.Context, exp *types.Experiment, run int) error {
errors = multierror.Append(errors, fmt.Errorf("running Scorch for experiment %s: %w", exp.Metadata.Name, err))
}

exp.Reload() // reload experiment from store in case status was updated during run

exp.Status.SetAppRunning("scorch", false)
exp.Status.SetAppStatus("scorch", nil)

Expand Down
4 changes: 3 additions & 1 deletion src/go/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ func ApplyApps(ctx context.Context, exp *types.Experiment, opts ...Option) error
err = a.Running(ctx, exp)
if err != nil {
pubsub.Publish("trigger-app", Publication{Experiment: exp.Spec.ExperimentName(), App: app.Name(), State: "error", Error: err})
} else {
pubsub.Publish("trigger-app", Publication{Experiment: exp.Spec.ExperimentName(), App: app.Name(), State: "success"})
}

pubsub.Publish("trigger-app", Publication{Experiment: exp.Spec.ExperimentName(), App: app.Name(), State: "success"})
exp.Reload() // reload experiment from store in case status was updated during run

exp.Status.SetAppRunning(app.Name(), false)

Expand Down
22 changes: 22 additions & 0 deletions src/go/types/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ func NewExperiment(md store.ConfigMetadata) *Experiment {
}
}

func (this *Experiment) Reload() error {
c, err := store.NewConfig("experiment/" + this.Metadata.Name)
if err != nil {
return fmt.Errorf("getting experiment: %w", err)
}

if err := store.Get(c); err != nil {
return fmt.Errorf("getting experiment %s from store: %w", this.Metadata.Name, err)
}

exp, err := DecodeExperimentFromConfig(*c)
if err != nil {
return fmt.Errorf("decoding experiment %s: %w", this.Metadata.Name, err)
}

this.Metadata = exp.Metadata
this.Spec = exp.Spec
this.Status = exp.Status

return nil
}

func (this Experiment) WriteToStore(statusOnly bool) error {
name := this.Metadata.Name

Expand Down

0 comments on commit 3641854

Please sign in to comment.