Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Fix race condition in pushing / pulling volume to local registry
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
  • Loading branch information
gtardif committed Jan 13, 2023
1 parent 2fcef84 commit bcc3991
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vm/internal/handler/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,13 @@ func TestPullVolume(t *testing.T) {
return err
}

t.Log("image pushed successfully")
return nil
})
if err != nil {
t.Fatal(err)
}

// The sleep is to ensure the image is present in the registry after the `ImagePush` operation.
time.Sleep(3 * time.Second)

_, err = cli.ImageRemove(context.Background(), imageID, types.ImageRemoveOptions{
Force: true,
})
Expand All @@ -169,8 +167,11 @@ func TestPullVolume(t *testing.T) {
t.Fatal(err)
}

// Pull volume from registry
err = h.PullVolume(c)
// Ths is to ensure the image is present in the registry after the `ImagePush` operation, might take a bit of time.
err = retry(10, 1*time.Second, func() error {
// Pull volume from registry
return h.PullVolume(c)
})

require.NoError(t, err)
require.Equal(t, http.StatusCreated, rec.Code)
Expand Down

0 comments on commit bcc3991

Please sign in to comment.