@@ -133,11 +133,11 @@ func (e *Executor) Run() {
133
133
}
134
134
135
135
// hasValidProvisioner checks whether there is at least one valid (non-stale, correct tags) provisioner
136
- // based on t and the tags on templateVersionJob.
137
- func (e * Executor ) hasValidProvisioner (ctx context.Context , tx database.Store , t time.Time , ws database.Workspace , templateVersionJob database. ProvisionerJob ) (bool , error ) {
136
+ // based on time t and the tags maps (such as from a templateVersionJob) .
137
+ func (e * Executor ) hasValidProvisioner (ctx context.Context , tx database.Store , t time.Time , ws database.Workspace , tags map [ string ] string ) (bool , error ) {
138
138
queryParams := database.GetProvisionerDaemonsByOrganizationParams {
139
139
OrganizationID : ws .OrganizationID ,
140
- WantTags : templateVersionJob . Tags ,
140
+ WantTags : tags ,
141
141
}
142
142
143
143
// nolint: gocritic // The user (in this case, the user/context for autostart builds) may not have the full
@@ -148,20 +148,20 @@ func (e *Executor) hasValidProvisioner(ctx context.Context, tx database.Store, t
148
148
return false , xerrors .Errorf ("get provisioner daemons: %w" , err )
149
149
}
150
150
151
- logger := e .log .With (slog .F ("tags" , templateVersionJob . Tags ))
151
+ logger := e .log .With (slog .F ("tags" , tags ))
152
152
// Check if any provisioners are active (not stale)
153
153
for _ , pd := range provisionerDaemons {
154
154
if pd .LastSeenAt .Valid {
155
155
age := t .Sub (pd .LastSeenAt .Time )
156
156
if age <= provisionerdserver .StaleInterval {
157
- logger .Debug (ctx , "hasAvailableProvisioners : found active provisioner" ,
157
+ logger .Debug (ctx , "hasValidProvisioner : found active provisioner" ,
158
158
slog .F ("daemon_id" , pd .ID ),
159
159
)
160
160
return true , nil
161
161
}
162
162
}
163
163
}
164
- logger .Debug (ctx , "hasAvailableProvisioners : no active provisioners found" )
164
+ logger .Debug (ctx , "hasValidProvisioner : no active provisioners found" )
165
165
return false , nil
166
166
}
167
167
@@ -321,7 +321,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
321
321
}
322
322
323
323
// Before creating the workspace build, check for available provisioners
324
- hasProvisioners , err := e .hasValidProvisioner (e .ctx , tx , t , ws , templateVersionJob )
324
+ hasProvisioners , err := e .hasValidProvisioner (e .ctx , tx , t , ws , templateVersionJob . Tags )
325
325
if err != nil {
326
326
return xerrors .Errorf ("check provisioner availability: %w" , err )
327
327
}
0 commit comments