Skip to content

Commit

Permalink
ci_runner,executor: remove os-specific syscall (#4642)
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng authored Aug 31, 2023
1 parent 03d8f02 commit 8cc54d4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
9 changes: 7 additions & 2 deletions enterprise/server/cmd/ci_runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"runtime"
"strings"
"sync"
"syscall"
"time"

"github.com/buildbuddy-io/buildbuddy/enterprise/server/build_event_publisher"
Expand Down Expand Up @@ -854,7 +853,13 @@ func (ar *actionRunner) Run(ctx context.Context, ws *workspace) error {
// completed so that the outer workflow invocation gets disconnected
// rather than finishing with an error.
if *workflowID != "" && exitCode == bazelLocalEnvironmentalErrorExitCode {
syscall.Kill(os.Getpid(), syscall.SIGKILL)
p, err := os.FindProcess(os.Getpid())
if err != nil {
return err
}
if err := p.Kill(); err != nil {
return err
}
}

// If this is a successfully "bazel run" invocation from which we are extracting run information via
Expand Down
2 changes: 2 additions & 0 deletions enterprise/server/cmd/executor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ go_library(
"executor.go",
"executor_linux.go",
"executor_notlinux.go",
"executor_unix.go",
"executor_windows.go",
],
importpath = "github.com/buildbuddy-io/buildbuddy/enterprise/server/cmd/executor",
visibility = ["//visibility:public"],
Expand Down
10 changes: 1 addition & 9 deletions enterprise/server/cmd/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"net/url"
"os"
"syscall"
"time"

"github.com/buildbuddy-io/buildbuddy/enterprise/server/auth"
Expand Down Expand Up @@ -147,14 +146,7 @@ func GetConfiguredEnvironmentOrDie(healthChecker *healthcheck.HealthChecker) env
}

func main() {
// The default umask (0022) has the effect of clearing the group-write and
// others-write bits when setting up workspace directories, regardless of the
// permissions bits passed to mkdir. We want to create these directories with
// 0777 permissions in some cases, because we need those to be writable by the
// container user, and it is too costly to enable those permissions via
// explicit chown or chmod calls on those directories. So, we clear the umask
// here to allow group-write and others-write permissions.
syscall.Umask(0)
setUmask()

rootContext := context.Background()

Expand Down
16 changes: 16 additions & 0 deletions enterprise/server/cmd/executor/executor_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build unix

package main

import "syscall"

func setUmask() {
// The default umask (0022) has the effect of clearing the group-write and
// others-write bits when setting up workspace directories, regardless of the
// permissions bits passed to mkdir. We want to create these directories with
// 0777 permissions in some cases, because we need those to be writable by the
// container user, and it is too costly to enable those permissions via
// explicit chown or chmod calls on those directories. So, we clear the umask
// here to allow group-write and others-write permissions.
syscall.Umask(0)
}
4 changes: 4 additions & 0 deletions enterprise/server/cmd/executor/executor_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package main

func setUmask() {
}

0 comments on commit 8cc54d4

Please sign in to comment.