Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed Oct 12, 2023
1 parent 990e5aa commit 7a95c9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions internal/mode/static/nginx/runtime/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,7 @@ func (c *verifyClient) waitForCorrectVersion(
return fmt.Errorf(noNewWorkersErrFmt, expectedVersion, err)
}

if err := wait.PollUntilContextCancel(
ctx,
25*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
version, err := c.getConfigVersion()
return version == expectedVersion, err
}); err != nil {
if err := c.ensureConfigVersion(ctx, expectedVersion); err != nil {
if errors.Is(err, context.DeadlineExceeded) {
err = fmt.Errorf(
"config version check didn't return expected version %d within the deadline",
Expand All @@ -112,6 +105,18 @@ func (c *verifyClient) waitForCorrectVersion(
return nil
}

func (c *verifyClient) ensureConfigVersion(ctx context.Context, expectedVersion int) error {
return wait.PollUntilContextCancel(
ctx,
25*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
version, err := c.getConfigVersion()
return version == expectedVersion, err
},
)
}

func ensureNewNginxWorkers(
ctx context.Context,
childProcFile string,
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/nginx/runtime/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestEnsureNewNginxWorkers(t *testing.T) {
ctx := context.Background()

cancellingCtx, cancel := context.WithCancel(ctx)
time.AfterFunc(10000*time.Millisecond, cancel)
time.AfterFunc(100*time.Millisecond, cancel)

cancellingCtx2, cancel2 := context.WithCancel(ctx)
time.AfterFunc(1*time.Millisecond, cancel2)
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestEnsureNewNginxWorkers(t *testing.T) {
readFile: readFilePrevious,
previousContents: previousContents,
expectError: true,
name: "no new workers",
name: "timed out waiting for new workers",
},
{
ctx: cancellingCtx2,
Expand Down

0 comments on commit 7a95c9f

Please sign in to comment.