@@ -56,6 +56,7 @@ type Options struct {
56
56
TracerProvider trace.TracerProvider
57
57
Metrics * Metrics
58
58
59
+ ExternalProvisioner bool
59
60
ForceCancelInterval time.Duration
60
61
UpdateInterval time.Duration
61
62
LogBufferInterval time.Duration
@@ -97,12 +98,13 @@ func New(clientDialer Dialer, opts *Options) *Server {
97
98
clientDialer :clientDialer ,
98
99
clientCh :make (chan proto.DRPCProvisionerDaemonClient ),
99
100
100
- closeContext :ctx ,
101
- closeCancel :ctxCancel ,
102
- closedCh :make (chan struct {}),
103
- shuttingDownCh :make (chan struct {}),
104
- acquireDoneCh :make (chan struct {}),
105
- initConnectionCh :opts .InitConnectionCh ,
101
+ closeContext :ctx ,
102
+ closeCancel :ctxCancel ,
103
+ closedCh :make (chan struct {}),
104
+ shuttingDownCh :make (chan struct {}),
105
+ acquireDoneCh :make (chan struct {}),
106
+ initConnectionCh :opts .InitConnectionCh ,
107
+ externalProvisioner :opts .ExternalProvisioner ,
106
108
}
107
109
108
110
daemon .wg .Add (2 )
@@ -141,8 +143,9 @@ type Server struct {
141
143
// shuttingDownCh will receive when we start graceful shutdown
142
144
shuttingDownCh chan struct {}
143
145
// acquireDoneCh will receive when the acquireLoop exits
144
- acquireDoneCh chan struct {}
145
- activeJob * runner.Runner
146
+ acquireDoneCh chan struct {}
147
+ activeJob * runner.Runner
148
+ externalProvisioner bool
146
149
}
147
150
148
151
type Metrics struct {
@@ -212,6 +215,10 @@ func NewMetrics(reg prometheus.Registerer) Metrics {
212
215
func (p * Server )connect () {
213
216
defer p .opts .Logger .Debug (p .closeContext ,"connect loop exited" )
214
217
defer p .wg .Done ()
218
+ logConnect := p .opts .Logger .Debug
219
+ if p .externalProvisioner {
220
+ logConnect = p .opts .Logger .Info
221
+ }
215
222
// An exponential back-off occurs when the connection is failing to dial.
216
223
// This is to prevent server spam in case of a coderd outage.
217
224
connectLoop:
@@ -239,7 +246,13 @@ connectLoop:
239
246
p .opts .Logger .Warn (p .closeContext ,"coderd client failed to dial" ,slog .Error (err ))
240
247
continue
241
248
}
242
- p .opts .Logger .Info (p .closeContext ,"successfully connected to coderd" )
249
+ // This log is useful to verify that an external provisioner daemon is
250
+ // successfully connecting to coderd. It doesn't add much value if the
251
+ // daemon is built-in, so we only log it on the info level if p.externalProvisioner
252
+ // is true. This log message is mentioned in the docs:
253
+ // https://github.com/coder/coder/blob/5bd86cb1c06561d1d3e90ce689da220467e525c0/docs/admin/provisioners.md#L346
254
+ logConnect (p .closeContext ,"successfully connected to coderd" )
255
+ retrier .Reset ()
243
256
retrier .Reset ()
244
257
p .initConnectionOnce .Do (func () {
245
258
close (p .initConnectionCh )
@@ -252,7 +265,7 @@ connectLoop:
252
265
client .DRPCConn ().Close ()
253
266
return
254
267
case <- client .DRPCConn ().Closed ():
255
- p . opts . Logger . Info (p .closeContext ,"connection to coderd closed" )
268
+ logConnect (p .closeContext ,"connection to coderd closed" )
256
269
continue connectLoop
257
270
case p .clientCh <- client :
258
271
continue