Skip to content
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
Prev Previous commit
Merge branch 'main' of github.com:coder/coder into spike/9015-stop-in…
…serting-provisioners
  • Loading branch information
spikecurtis committed Sep 8, 2023
commit 0a0d236ef1c96fac2d4434b36789db2b2cfb7d6f
45 changes: 25 additions & 20 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"github.com/coder/coder/v2/coderd/batchstats"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/database/pubsub"
"github.com/coder/coder/v2/coderd/gitauth"
"github.com/coder/coder/v2/coderd/gitsshkey"
Expand Down Expand Up @@ -1089,27 +1088,33 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, debounce ti
name := namesgenerator.GetRandomName(1)
logger := api.Logger.Named(fmt.Sprintf("inmem-provisionerd-%s", name))
logger.Info(ctx, "starting in-memory provisioner daemon")
err = proto.DRPCRegisterProvisionerDaemon(mux, &provisionerdserver.Server{
AccessURL: api.AccessURL,
ID: uuid.New(),
OIDCConfig: api.OIDCConfig,
Database: api.Database,
Pubsub: api.Pubsub,
Provisioners: []database.ProvisionerType{
srv, err := provisionerdserver.NewServer(
api.AccessURL,
uuid.New(),
logger,
[]database.ProvisionerType{
database.ProvisionerTypeEcho, database.ProvisionerTypeTerraform,
},
GitAuthConfigs: api.GitAuthConfigs,
Telemetry: api.Telemetry,
Tracer: tracer,
Tags: tags,
QuotaCommitter: &api.QuotaCommitter,
Auditor: &api.Auditor,
TemplateScheduleStore: api.TemplateScheduleStore,
UserQuietHoursScheduleStore: api.UserQuietHoursScheduleStore,
AcquireJobDebounce: debounce,
Logger: logger,
DeploymentValues: api.DeploymentValues,
})
tags,
api.Database,
api.Pubsub,
api.Telemetry,
tracer,
&api.QuotaCommitter,
&api.Auditor,
api.TemplateScheduleStore,
api.UserQuietHoursScheduleStore,
api.DeploymentValues,
debounce,
provisionerdserver.Options{
OIDCConfig: api.OIDCConfig,
GitAuthConfigs: api.GitAuthConfigs,
},
)
if err != nil {
return nil, err
}
err = proto.DRPCRegisterProvisionerDaemon(mux, srv)
if err != nil {
return nil, err
}
Expand Down
57 changes: 37 additions & 20 deletions enterprise/coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"cdr.dev/slog"
"github.com/coder/coder/v2/coderd"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/coderd/httpmw"
"github.com/coder/coder/v2/coderd/provisionerdserver"
Expand Down Expand Up @@ -192,6 +191,12 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
}
}

name := namesgenerator.GetRandomName(1)
log := api.Logger.With(
slog.F("name", name),
slog.F("provisioners", provisioners),
slog.F("tags", tags),
)
rawTags, err := json.Marshal(tags)
if err != nil {
if !xerrors.Is(err, context.Canceled) {
Expand Down Expand Up @@ -239,26 +244,38 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
return
}
mux := drpcmux.New()
daemonName := namesgenerator.GetRandomName(1)
logger := api.Logger.Named(fmt.Sprintf("ext-provisionerd-%s", daemonName))
logger := api.Logger.Named(fmt.Sprintf("ext-provisionerd-%s", name))
logger.Info(ctx, "starting external provisioner daemon")
err = proto.DRPCRegisterProvisionerDaemon(mux, &provisionerdserver.Server{
AccessURL: api.AccessURL,
GitAuthConfigs: api.GitAuthConfigs,
OIDCConfig: api.OIDCConfig,
ID: uuid.New(),
Database: api.Database,
Pubsub: api.Pubsub,
Provisioners: provisioners,
Telemetry: api.Telemetry,
Auditor: &api.AGPL.Auditor,
TemplateScheduleStore: api.AGPL.TemplateScheduleStore,
UserQuietHoursScheduleStore: api.AGPL.UserQuietHoursScheduleStore,
Logger: logger,
Tags: rawTags,
Tracer: trace.NewNoopTracerProvider().Tracer("noop"),
DeploymentValues: api.DeploymentValues,
})
srv, err := provisionerdserver.NewServer(
api.AccessURL,
uuid.New(),
logger,
provisioners,
rawTags,
api.Database,
api.Pubsub,
api.Telemetry,
trace.NewNoopTracerProvider().Tracer("noop"),
&api.AGPL.QuotaCommitter,
&api.AGPL.Auditor,
api.AGPL.TemplateScheduleStore,
api.AGPL.UserQuietHoursScheduleStore,
api.DeploymentValues,
// TODO(spikecurtis) - fix debounce to not cause flaky tests.
time.Duration(0),
provisionerdserver.Options{
GitAuthConfigs: api.GitAuthConfigs,
OIDCConfig: api.OIDCConfig,
},
)
if err != nil {
if !xerrors.Is(err, context.Canceled) {
log.Error(ctx, "create provisioner daemon server", slog.Error(err))
}
_ = conn.Close(websocket.StatusInternalError, httpapi.WebsocketCloseSprintf("create provisioner daemon server: %s", err))
return
}
err = proto.DRPCRegisterProvisionerDaemon(mux, srv)
if err != nil {
_ = conn.Close(websocket.StatusInternalError, httpapi.WebsocketCloseSprintf("drpc register provisioner daemon: %s", err))
return
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.