Skip to content

Commit

Permalink
Upgrade RunResponse.exit_code to int64
Browse files Browse the repository at this point in the history
POSIX allows returning values that span all of int. This means that on
ILP64 systems, int32 is not necessarily large enough to fit all possible
exit codes.
  • Loading branch information
EdSchouten committed Dec 4, 2024
1 parent dfdb1c2 commit 99cd358
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/builder/local_build_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (be *localBuildExecutor) Execute(ctx context.Context, filePool re_filesyste

// Attach the exit code or execution error.
if runErr == nil {
response.Result.ExitCode = runResponse.ExitCode
response.Result.ExitCode = int32(runResponse.ExitCode)
response.Result.ExecutionMetadata.AuxiliaryMetadata = append(response.Result.ExecutionMetadata.AuxiliaryMetadata, runResponse.ResourceUsage...)
} else {
attachErrorToExecuteResponse(response, util.StatusWrap(runErr, "Failed to run command"))
Expand Down
6 changes: 3 additions & 3 deletions pkg/proto/runner/runner.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/runner/runner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ message RunRequest {

message RunResponse {
// Exit code generated by the process.
int32 exit_code = 1;
int64 exit_code = 1;

// Runner-specific information on the amount of resources used during
// execution.
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/local_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (r *localRunner) Run(ctx context.Context, request *runner.RunRequest) (*run
return nil, util.StatusWrap(err, "Failed to marshal POSIX resource usage")
}
return &runner.RunResponse{
ExitCode: int32(cmd.ProcessState.ExitCode()),
ExitCode: int64(cmd.ProcessState.ExitCode()),
ResourceUsage: []*anypb.Any{posixResourceUsage},
}, nil
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/runner/local_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "EmptyEnvironment/tmp",
})
require.NoError(t, err)
require.Equal(t, int32(0), response.ExitCode)
require.Equal(t, int64(0), response.ExitCode)

stdout, err := os.ReadFile(filepath.Join(testPath, "stdout"))
require.NoError(t, err)
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "NonEmptyEnvironment/tmp",
})
require.NoError(t, err)
require.Equal(t, int32(0), response.ExitCode)
require.Equal(t, int64(0), response.ExitCode)

stdout, err := os.ReadFile(filepath.Join(testPath, "stdout"))
require.NoError(t, err)
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "OverridingTmpdir/tmp",
})
require.NoError(t, err)
require.Equal(t, int32(0), response.ExitCode)
require.Equal(t, int64(0), response.ExitCode)

stdout, err := os.ReadFile(filepath.Join(testPath, "stdout"))
require.NoError(t, err)
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "NonZeroExitCode/tmp",
})
require.NoError(t, err)
require.Equal(t, int32(255), response.ExitCode)
require.Equal(t, int64(255), response.ExitCode)

stdout, err := os.ReadFile(filepath.Join(testPath, "stdout"))
require.NoError(t, err)
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "SigKill/tmp",
})
require.NoError(t, err)
require.NotEqual(t, int32(0), response.ExitCode)
require.NotEqual(t, int64(0), response.ExitCode)

require.Len(t, response.ResourceUsage, 1)
var posixResourceUsage resourceusage.POSIXResourceUsage
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestLocalRunnerRun(t *testing.T) {
TemporaryDirectory: "RelativeSearchPath/tmp",
})
require.NoError(t, err)
require.Equal(t, int32(42), response.ExitCode)
require.Equal(t, int64(42), response.ExitCode)

stdout, err := os.ReadFile(filepath.Join(testPath, "stdout"))
require.NoError(t, err)
Expand Down

0 comments on commit 99cd358

Please sign in to comment.