From 75a0d016bae14de87d94c1b34b207dd156df5feb Mon Sep 17 00:00:00 2001 From: Ashley Jeffs Date: Mon, 4 Mar 2024 08:33:30 +0000 Subject: [PATCH] Prevent redundant bootstrap reattempts with studio sync --- internal/cli/studio/pull_runner.go | 8 ++++++-- internal/cli/studio/pull_runner_test.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/cli/studio/pull_runner.go b/internal/cli/studio/pull_runner.go index d394cb56a6..4baf2dfb11 100644 --- a/internal/cli/studio/pull_runner.go +++ b/internal/cli/studio/pull_runner.go @@ -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. diff --git a/internal/cli/studio/pull_runner_test.go b/internal/cli/studio/pull_runner_test.go index 64d2d575cf..bbd55782d1 100644 --- a/internal/cli/studio/pull_runner_test.go +++ b/internal/cli/studio/pull_runner_test.go @@ -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{ @@ -324,6 +333,7 @@ output: }), ) + pr.Sync(ctx) pr.Sync(ctx) assert.Eventually(t, func() bool {