Skip to content

Commit e48c724

Browse files
committed
hasValidProvisioner only needs tags
Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent a98ef1d commit e48c724

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

coderd/autobuild/lifecycle_executor.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ func (e *Executor) Run() {
133133
}
134134

135135
// 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) {
138138
queryParams := database.GetProvisionerDaemonsByOrganizationParams{
139139
OrganizationID: ws.OrganizationID,
140-
WantTags: templateVersionJob.Tags,
140+
WantTags: tags,
141141
}
142142

143143
// 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
148148
return false, xerrors.Errorf("get provisioner daemons: %w", err)
149149
}
150150

151-
logger := e.log.With(slog.F("tags", templateVersionJob.Tags))
151+
logger := e.log.With(slog.F("tags", tags))
152152
// Check if any provisioners are active (not stale)
153153
for _, pd := range provisionerDaemons {
154154
if pd.LastSeenAt.Valid {
155155
age := t.Sub(pd.LastSeenAt.Time)
156156
if age <= provisionerdserver.StaleInterval {
157-
logger.Debug(ctx, "hasAvailableProvisioners: found active provisioner",
157+
logger.Debug(ctx, "hasValidProvisioner: found active provisioner",
158158
slog.F("daemon_id", pd.ID),
159159
)
160160
return true, nil
161161
}
162162
}
163163
}
164-
logger.Debug(ctx, "hasAvailableProvisioners: no active provisioners found")
164+
logger.Debug(ctx, "hasValidProvisioner: no active provisioners found")
165165
return false, nil
166166
}
167167

@@ -321,7 +321,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
321321
}
322322

323323
// 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)
325325
if err != nil {
326326
return xerrors.Errorf("check provisioner availability: %w", err)
327327
}

0 commit comments

Comments
 (0)