Skip to content

Commit

Permalink
fix(hatchery/local): worker binary name (#4725)
Browse files Browse the repository at this point in the history
close #4724
  • Loading branch information
yesnault authored and sguiheux committed Oct 29, 2019
1 parent 7afd34e commit 6443c23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 11 additions & 2 deletions engine/hatchery/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (h *HatcheryLocal) Serve(ctx context.Context) error {
return fmt.Errorf("Cannot download worker binary from api: %v", err)
}

cmdWorker := fmt.Sprintf("%s/worker --api={{.API}} --token={{.Token}} --basedir={{.BaseDir}} --model={{.Model}} --name={{.Name}} --hatchery-name={{.HatcheryName}} --insecure={{.HTTPInsecure}} --graylog-extra-key={{.GraylogExtraKey}} --graylog-extra-value={{.GraylogExtraValue}} --graylog-host={{.GraylogHost}} --graylog-port={{.GraylogPort}} --booked-workflow-job-id={{.WorkflowJobID}} --single-use --force-exit", h.BasedirDedicated)
cmdWorker := fmt.Sprintf("%s/%s --api={{.API}} --token={{.Token}} --basedir={{.BaseDir}} --model={{.Model}} --name={{.Name}} --hatchery-name={{.HatcheryName}} --insecure={{.HTTPInsecure}} --graylog-extra-key={{.GraylogExtraKey}} --graylog-extra-value={{.GraylogExtraValue}} --graylog-host={{.GraylogHost}} --graylog-port={{.GraylogPort}} --booked-workflow-job-id={{.WorkflowJobID}} --single-use --force-exit", h.BasedirDedicated, h.getWorkerBinaryName())
h.ModelLocal = sdk.Model{
Name: h.Name,
Type: sdk.HostProcess,
Expand Down Expand Up @@ -182,7 +182,7 @@ func (h *HatcheryLocal) downloadWorker() error {
return fmt.Errorf("Error http code: %d, url called: %s", resp.StatusCode, urlBinary)
}

workerFullPath := path.Join(h.BasedirDedicated, "worker")
workerFullPath := path.Join(h.BasedirDedicated, h.getWorkerBinaryName())

if _, err := os.Stat(workerFullPath); err == nil {
log.Debug("removing existing worker binary from %s", workerFullPath)
Expand All @@ -204,6 +204,15 @@ func (h *HatcheryLocal) downloadWorker() error {
return sdk.WithStack(fp.Close())
}

func (h *HatcheryLocal) getWorkerBinaryName() string {
workerName := "worker"

if sdk.GOOS == "windows" {
workerName += ".exe"
}
return workerName
}

// checkCapabilities checks all requirements, foreach type binary, check if binary is on current host
// returns an error "Exit status X" if current host misses one requirement
func (h *HatcheryLocal) checkCapabilities(req []sdk.Requirement) ([]sdk.Requirement, error) {
Expand Down
9 changes: 7 additions & 2 deletions engine/worker/cmd_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ func cmdMain(w *currentWorker) *cobra.Command {
var mainCmd = &cobra.Command{
Use: "worker",
Short: "CDS Worker",
Long: "A pipeline is structured in sequential stages containing one or multiple concurrent jobs. A Job will be executed by a worker.",
Run: runCmd(w),
Long: `A pipeline is structured in sequential stages containing
one or multiple concurrent jobs. A Job will be executed by a worker.
The worker provides some useful commands that can be used in a step, as ` + "`worker upload...`" + `, ` + "`worker download...`" + "`worker cache...`" + `
On Windows OS, theses commands can be accessed with ` + "`worker.exe [cmd]` syntax.",
Run: runCmd(w),
}

initFlagsRun(mainCmd)
Expand Down

0 comments on commit 6443c23

Please sign in to comment.