Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 2 additions & 15 deletions engine/worker/internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,8 @@ func (w *CurrentWorker) setupHooks(ctx context.Context, jobInfo sdk.WorkflowNode
}
}

for capa, hookConfig := range hook.Configuration.ByCapabilities {
// check is the capabilities exist on the current worker
if _, err := exec.LookPath(capa); err != nil {
// The error contains 'Executable file not found', the capa is not on the worker
continue
}

for i := range hook.Configuration.ByCapabilities {
hookConfig := hook.Configuration.ByCapabilities[i]
hookFilename := fmt.Sprintf("%d-%s-%s", hookConfig.Priority, integrationName, slug.Convert(hookConfig.Label))

w.hooks = append(w.hooks, workerHook{
Expand All @@ -548,14 +543,6 @@ func (w *CurrentWorker) setupHooks(ctx context.Context, jobInfo sdk.WorkflowNode
}

for _, h := range w.hooks {
infos := []sdk.SpawnInfo{{
RemoteTime: time.Now(),
Message: sdk.SpawnMsg{ID: sdk.MsgSpawnInfoWorkerHookSetup.ID, Args: []interface{}{h.Config.Label}},
}}
if err := w.Client().QueueJobSendSpawnInfo(ctx, strconv.FormatInt(w.currentJob.wJob.ID, 10), infos); err != nil {
return sdk.WrapError(err, "cannot record QueueJobSendSpawnInfo for job (err spawn): %d", w.currentJob.wJob.ID)
}

log.Info(ctx, "setting up hook at %q", h.SetupPath)

hookFile, err := fs.Create(h.SetupPath)
Expand Down
19 changes: 2 additions & 17 deletions engine/worker/internal/runV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,13 +1177,8 @@ func (w *CurrentWorker) setupHooksV2(ctx context.Context, currentJob CurrentJobV
}
}

for capa, hookConfig := range hook.Configuration.ByCapabilities {
// check is the capabilities exist on the current worker
if _, err := exec.LookPath(capa); err != nil {
// The error contains 'Executable file not found', the capa is not on the worker
continue
}

for i := range hook.Configuration.ByCapabilities {
hookConfig := hook.Configuration.ByCapabilities[i]
hookFilename := fmt.Sprintf("%d-%s-%s", hookConfig.Priority, integ.Name, slug.Convert(hookConfig.Label))

w.hooks = append(w.hooks, workerHook{
Expand All @@ -1195,16 +1190,6 @@ func (w *CurrentWorker) setupHooksV2(ctx context.Context, currentJob CurrentJobV
}

for _, h := range w.hooks {
info := sdk.V2SendJobRunInfo{
Message: fmt.Sprintf("Setting up worker hook %q", h.Config.Label),
Level: sdk.WorkflowRunInfoLevelInfo,
Time: time.Now(),
}

if err := w.ClientV2().V2QueuePushJobInfo(ctx, w.currentJobV2.runJob.Region, w.currentJobV2.runJob.ID, info); err != nil {
log.Error(ctx, "runJobServiceReadiness> Unable to send spawn info: %v", err)
}

log.Info(ctx, "setting up hook at %q", h.SetupPath)

hookFile, err := fs.Create(h.SetupPath)
Expand Down
2 changes: 0 additions & 2 deletions sdk/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ var (
MsgSpawnErrorHatcheryRetryAttempt = &Message{"MsgSpawnErrorHatcheryRetryAttempt", trad{EN: "Job execution failed by hatchery %s. Reason: %s"}, nil, RunInfoTypeError}
MsgSpawnInfoDisableSecretInjection = &Message{"MsgSpawnInfoDisableSecretInjection", trad{EN: "⚠ Project's secrets were not automatically injected for this job because of a region prerequisite: %s"}, nil, RunInfoTypInfo}
MsgSpawnInfoManualSecretInjection = &Message{"MsgSpawnInfoManualSecretInjection", trad{EN: "Prerequisites of type secret matched %s secret(s)"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookSetup = &Message{"MsgSpawnInfoWorkerHookSetup", trad{EN: "Setting up worker hook %q"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookRun = &Message{"MsgSpawnInfoWorkerHookRun", trad{EN: "Running worker hook %q"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookRunTeardown = &Message{"MsgSpawnInfoWorkerHookRunTeardown", trad{EN: "Running worker hook %q teardown"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerDisabledByHatchery = &Message{"MsgSpawnInfoWorkerDisabledByHatchery", trad{EN: "The worker (not responding) %s was disabled by hatchery"}, nil, RunInfoTypeWarning}
Expand Down Expand Up @@ -188,7 +187,6 @@ var Messages = map[string]*Message{
MsgSpawnErrorHatcheryRetryAttempt.ID: MsgSpawnErrorHatcheryRetryAttempt,
MsgSpawnInfoDisableSecretInjection.ID: MsgSpawnInfoDisableSecretInjection,
MsgSpawnInfoManualSecretInjection.ID: MsgSpawnInfoManualSecretInjection,
MsgSpawnInfoWorkerHookSetup.ID: MsgSpawnInfoWorkerHookSetup,
MsgSpawnInfoWorkerHookRun.ID: MsgSpawnInfoWorkerHookRun,
MsgSpawnInfoWorkerHookRunTeardown.ID: MsgSpawnInfoWorkerHookRunTeardown,
MsgSpawnInfoWorkerDisabledByHatchery.ID: MsgSpawnInfoWorkerDisabledByHatchery,
Expand Down