Skip to content

Commit

Permalink
Prevent redundant bootstrap reattempts with studio sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail authored and lucasoares committed Mar 8, 2024
1 parent cac92c0 commit 75a0d01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/cli/studio/pull_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,12 @@ func (r *PullRunner) Sync(ctx context.Context) {

if r.confReader == nil {
// We haven't bootstrapped yet, likely due to a bad config on
// our first attempt. The latest sync may have fixed the issue
// so we can potentially try again.
// our first and latest attempt. The latest sync may have fixed the
// issue so we can potentially try again but it's only worth it if there
// was a diff in the configs available compared to the last attempt.
if diff == nil {
return
}

if isDisabled {
// Except the deployment is disabled now, so don't.
Expand Down
10 changes: 10 additions & 0 deletions internal/cli/studio/pull_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ output:
path: $DIR/outa.jsonl
`))
}),
expectedRequest("/api/v1/node/session/foosession/deployment/depaid/sync", func(t *testing.T, w http.ResponseWriter, r *http.Request) {
require.Equal(t, "POST", r.Method)
jsonRequestSupersetMatch(t, r, obj{
"name": "foobarnode",
"main_config": obj{"name": "maina.yaml", "modified": 1001.0},
"run_error": "failed bootstrap config read: maina.yaml: (5,1) unable to infer input type from candidates: [blahbluh]",
})
jsonResponse(t, w, obj{})
}),
expectedRequest("/api/v1/node/session/foosession/deployment/depaid/sync", func(t *testing.T, w http.ResponseWriter, r *http.Request) {
require.Equal(t, "POST", r.Method)
jsonRequestSupersetMatch(t, r, obj{
Expand Down Expand Up @@ -324,6 +333,7 @@ output:
}),
)

pr.Sync(ctx)
pr.Sync(ctx)

assert.Eventually(t, func() bool {
Expand Down

0 comments on commit 75a0d01

Please sign in to comment.