Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: shutdown provisioner should stop waiting on client#13118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 3 commits intomainfromstevenmasley/provisioner_close
May 3, 2024

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedMay 1, 2024
edited
Loading

provisionerd does not respond toctrl+c if no coderd exits.

Rungo run main.go provisionerd start without a coderd. After a second or two, hitctrl +c. The process will not terminate. The issue is we callShutdown for a graceful closure.

Currently:

  • connect() does not terminate on shutdown.Only onClose
  • Shutdown does not call close. The caller needs to callShutdown and thenClose. Updated the cli to do this, although it is not intuitive imo.
  • acquireLoop blocks on a client, but if no client is ever established, the shutdown never gets checked, and this blocks forever.

This PR callsClose afterShutdown and makesp.client() return a nil client during shutdown.


I'd like to see provisionerd'sShutdown callClose.

Copy link
Contributor

@spikecurtisspikecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we get a unit test?

@Emyrk
Copy link
MemberAuthor

@spikecurtis test added:

t.Run("ShutdownNoCoderd",func(t*testing.T) {
t.Parallel()
done:=make(chanstruct{})
t.Cleanup(func() {
close(done)
})
connectAttemptedClose:= sync.Once{}
connectAttempted:=make(chanstruct{})
server:=createProvisionerd(t,func(ctx context.Context) (proto.DRPCProvisionerDaemonClient,error) {
// This is the dial out to Coderd, which in this unit test will always fail.
connectAttemptedClose.Do(func() {close(connectAttempted) })
returnnil,fmt.Errorf("client connection always fails")
}, provisionerd.LocalProvisioners{
"someprovisioner":createProvisionerClient(t,done,provisionerTestServer{}),
})
// Wait for at least 1 attempt to connect to ensure the connect go routine
// is running.
require.Condition(t,closedWithin(connectAttempted,testutil.WaitShort))
// The test is ensuring this Shutdown call does not block indefinitely.
// If it does, the context will return with an error, and the test will
// fail.
shutdownCtx:=testutil.Context(t,testutil.WaitShort)
err:=server.Shutdown(shutdownCtx,true)
require.NoError(t,err,"shutdown did not unblock. Failed to close the server gracefully.")
require.NoError(t,server.Close())
})

@EmyrkEmyrk requested a review fromspikecurtisMay 2, 2024 16:30
Copy link
Contributor

@spikecurtisspikecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!


// Wait for at least 1 attempt to connect to ensure the connect go routine
// is running.
require.Condition(t, closedWithin(connectAttempted, testutil.WaitShort))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

just FYI, we havetestutil.RequireRecvCtx() which is what I usually use for this sort of thing.

Emyrk reacted with thumbs up emoji
@EmyrkEmyrk merged commit09f00c0 intomainMay 3, 2024
@EmyrkEmyrk deleted the stevenmasley/provisioner_close branchMay 3, 2024 15:15
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 3, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@spikecurtisspikecurtisspikecurtis approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Emyrk@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp