Skip to content

fix(coderd/provisionerdserver): pass through api ctx to provisionerdserver #10259

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address PR nits
  • Loading branch information
johnstcn committed Oct 16, 2023
commit 1d58f8b1d25a38390f33221ffa35f47ee208c10a
15 changes: 9 additions & 6 deletions coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ type Options struct {
}

type server struct {
ctx context.Context
// lifecycleCtx must be tied to the API server's lifecycle
// as when the API server shuts down, we want to cancel any
// long-running operations.
lifecycleCtx context.Context
AccessURL *url.URL
ID uuid.UUID
Logger slog.Logger
Expand Down Expand Up @@ -108,7 +111,7 @@ func (t Tags) Valid() error {
}

func NewServer(
ctx context.Context,
lifecycleCtx context.Context,
accessURL *url.URL,
id uuid.UUID,
logger slog.Logger,
Expand All @@ -126,8 +129,8 @@ func NewServer(
deploymentValues *codersdk.DeploymentValues,
options Options,
) (proto.DRPCProvisionerDaemonServer, error) {
// Panic early if pointers are nil
if ctx == nil {
// Fail-fast if pointers are nil
if lifecycleCtx == nil {
return nil, xerrors.New("ctx is nil")
}
if quotaCommitter == nil {
Expand Down Expand Up @@ -158,7 +161,7 @@ func NewServer(
options.AcquireJobLongPollDur = DefaultAcquireJobLongPollDur
}
return &server{
ctx: ctx,
lifecycleCtx: lifecycleCtx,
AccessURL: accessURL,
ID: id,
Logger: logger,
Expand Down Expand Up @@ -1191,7 +1194,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob)
go func() {
for _, wait := range updates {
select {
case <-s.ctx.Done():
case <-s.lifecycleCtx.Done():
// If the server is shutting down, we don't want to wait around.
s.Logger.Warn(context.Background(), "stopping notifications due to server shutdown",
slog.F("workspace_build_id", workspaceBuild.ID),
Expand Down