Skip to content

feat: Add provisioner force-cancel flag #4947

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 4 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
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
Next Next commit
feat: Add provisionerd force cancel flag
  • Loading branch information
mtojek committed Nov 8, 2022
commit adfd782ab8d5225dd1678a48f742e1e0987d5eab
8 changes: 8 additions & 0 deletions cli/deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ func newConfig() *codersdk.DeploymentConfig {
Flag: "user-workspace-quota",
Enterprise: true,
},
Provisionerd: &codersdk.ProvisionerdConfig{
Copy link
Member

Choose a reason for hiding this comment

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

We have another config called ProvisionerDaemons. I think it would be sensible to unify these under Provisioner.Daemons and Provisioner.ForceCancelInterval?

Should be a non-breaking change as well since the flag/env translate to the same.

Copy link
Member Author

@mtojek mtojek Nov 8, 2022

Choose a reason for hiding this comment

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

I assumed that this would be a breaking change if there is a customer who uses the ProvisionerDaemons. I'm for unification, but a bit concerned about disturbing somebody's environment.

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be fine. Neither flag or env should break (was PROVISIONER_DAEMONS and will be the same in the new structure, please correct me if I’m wrong @f0ssel).

The only breakage I can think if is when used as part of server.yaml. But it’s a recent addition and not widely used yet AFAIK.

There may be even more breaking changes to this in the future as we split out provisionerd servers from the coderd server.

ForceCancelInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Force Cancel Interval",
Usage: "Time to force cancel provisioning tasks that are stuck.",
Flag: "provisionerd-force-cancel-interval",
Default: 10 * time.Minute,
},
},
}
}

Expand Down
25 changes: 13 additions & 12 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
}()
provisionerdMetrics := provisionerd.NewMetrics(options.PrometheusRegistry)
for i := 0; i < cfg.ProvisionerDaemons.Value; i++ {
daemon, err := newProvisionerDaemon(ctx, coderAPI, provisionerdMetrics, logger, cfg.CacheDirectory.Value, errCh, false)
daemon, err := newProvisionerDaemon(ctx, coderAPI, provisionerdMetrics, logger, cfg, errCh, false)
if err != nil {
return xerrors.Errorf("create provisioner daemon: %w", err)
}
Expand Down Expand Up @@ -832,7 +832,7 @@ func newProvisionerDaemon(
coderAPI *coderd.API,
metrics provisionerd.Metrics,
logger slog.Logger,
cacheDir string,
cfg *codersdk.DeploymentConfig,
errCh chan error,
dev bool,
) (srv *provisionerd.Server, err error) {
Expand All @@ -843,9 +843,9 @@ func newProvisionerDaemon(
}
}()

err = os.MkdirAll(cacheDir, 0o700)
err = os.MkdirAll(cfg.CacheDirectory.Value, 0o700)
if err != nil {
return nil, xerrors.Errorf("mkdir %q: %w", cacheDir, err)
return nil, xerrors.Errorf("mkdir %q: %w", cfg.CacheDirectory.Value, err)
}

terraformClient, terraformServer := provisionersdk.TransportPipe()
Expand All @@ -861,7 +861,7 @@ func newProvisionerDaemon(
ServeOptions: &provisionersdk.ServeOptions{
Listener: terraformServer,
},
CachePath: cacheDir,
CachePath: cfg.CacheDirectory.Value,
Logger: logger,
})
if err != nil && !xerrors.Is(err, context.Canceled) {
Expand Down Expand Up @@ -902,13 +902,14 @@ func newProvisionerDaemon(
provisioners[string(database.ProvisionerTypeEcho)] = proto.NewDRPCProvisionerClient(provisionersdk.Conn(echoClient))
}
return provisionerd.New(coderAPI.ListenProvisionerDaemon, &provisionerd.Options{
Logger: logger,
PollInterval: 500 * time.Millisecond,
UpdateInterval: 500 * time.Millisecond,
Provisioners: provisioners,
WorkDirectory: tempDir,
TracerProvider: coderAPI.TracerProvider,
Metrics: &metrics,
Logger: logger,
PollInterval: 500 * time.Millisecond,
UpdateInterval: 500 * time.Millisecond,
ForceCancelInterval: cfg.Provisionerd.ForceCancelInterval.Value,
Provisioners: provisioners,
WorkDirectory: tempDir,
TracerProvider: coderAPI.TracerProvider,
Metrics: &metrics,
}), nil
}

Expand Down
Loading