Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UUID instead of step name where possible #3136

Merged
merged 7 commits into from
Jan 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion pipeline/backend/local/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow
e.output, _ = cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout

state.stepCMDs[step.Name] = cmd
state.stepCMDs[step.UUID] = cmd

return cmd.Start()
}
Expand Down
8 changes: 4 additions & 4 deletions pipeline/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (e *local) execCommands(ctx context.Context, step *types.Step, state *workf
e.output = io.NopCloser(transform.NewReader(e.output, unicode.UTF8.NewDecoder().Transformer))
}

state.stepCMDs[step.Name] = cmd
state.stepCMDs[step.UUID] = cmd

return cmd.Start()
}
Expand All @@ -186,7 +186,7 @@ func (e *local) execPlugin(ctx context.Context, step *types.Step, state *workflo
e.output, _ = cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout

state.stepCMDs[step.Name] = cmd
state.stepCMDs[step.UUID] = cmd

return cmd.Start()
}
Expand All @@ -201,9 +201,9 @@ func (e *local) WaitStep(_ context.Context, step *types.Step, taskUUID string) (
return nil, err
}

cmd, ok := state.stepCMDs[step.Name]
cmd, ok := state.stepCMDs[step.UUID]
if !ok {
return nil, fmt.Errorf("step cmd %s not found", step.Name)
return nil, fmt.Errorf("step cmd for %s not found", step.UUID)
}

err = cmd.Wait()
Expand Down
8 changes: 4 additions & 4 deletions pipeline/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ var (

// An ExitError reports an unsuccessful exit.
type ExitError struct {
Name string
UUID string
Code int
}

// Error returns the error message in string format.
func (e *ExitError) Error() string {
return fmt.Sprintf("%s : exit code %d", e.Name, e.Code)
return fmt.Sprintf("uuid=%s: exit code %d", e.UUID, e.Code)
}

// An OomError reports the process received an OOMKill from the kernel.
type OomError struct {
Name string
UUID string
Code int
}

// Error returns the error message in string format.
func (e *OomError) Error() string {
return fmt.Sprintf("%s : received oom kill", e.Name)
return fmt.Sprintf("uuid=%s: received oom kill", e.UUID)
}
8 changes: 4 additions & 4 deletions pipeline/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ import (

func TestExitError(t *testing.T) {
err := ExitError{
Name: "build",
UUID: "14534321",
Code: 255,
}
got, want := err.Error(), "build : exit code 255"
got, want := err.Error(), "uuid=14534321: exit code 255"
if got != want {
t.Errorf("Want error message %q, got %q", want, got)
}
}

func TestOomError(t *testing.T) {
err := OomError{
Name: "build",
UUID: "14534321",
}
got, want := err.Error(), "build : received oom kill"
got, want := err.Error(), "uuid=14534321: received oom kill"
if got != want {
t.Errorf("Want error message %q, got %q", want, got)
}
Expand Down
4 changes: 2 additions & 2 deletions pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ func (r *Runtime) exec(step *backend.Step) (*backend.State, error) {

if waitState.OOMKilled {
return waitState, &OomError{
Name: step.Name,
UUID: step.UUID,
Code: waitState.ExitCode,
}
} else if waitState.ExitCode != 0 {
return waitState, &ExitError{
Name: step.Name,
UUID: step.UUID,
Code: waitState.ExitCode,
}
}
Expand Down