Skip to content

Commit

Permalink
Revert "[ci_runner] Populate child invocation cards in UI for bazel c…
Browse files Browse the repository at this point in the history
…ommands in bash" (#7298)
  • Loading branch information
maggie-lou authored Aug 26, 2024
1 parent f680859 commit 49f765e
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 177 deletions.
11 changes: 10 additions & 1 deletion app/invocation/invocation_model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default class InvocationModel {
failedAction?: build_event_stream.BuildEvent;
workflowConfigured?: build_event_stream.WorkflowConfigured;
childInvocationsConfigured: build_event_stream.ChildInvocationsConfigured[] = [];
childInvocationCompletedByInvocationId = new Map<string, build_event_stream.IChildInvocationCompleted>();
childInvocationCompletedByInvocationId = new Map<
string,
build_event_stream.IChildInvocationCompleted | build_event_stream.IWorkflowCommandCompleted
>();
workspaceStatus?: build_event_stream.WorkspaceStatus;
configuration?: build_event_stream.Configuration;
workspaceConfig?: build_event_stream.WorkspaceConfig;
Expand Down Expand Up @@ -142,6 +145,12 @@ export default class InvocationModel {
buildEvent.childInvocationsConfigured as build_event_stream.ChildInvocationsConfigured
);
}
if (buildEvent.workflowCommandCompleted && buildEvent.id?.workflowCommandCompleted?.invocationId) {
this.childInvocationCompletedByInvocationId.set(
buildEvent.id.workflowCommandCompleted.invocationId,
buildEvent.workflowCommandCompleted
);
}
if (buildEvent.childInvocationCompleted && buildEvent.id?.childInvocationCompleted?.invocationId) {
this.childInvocationCompletedByInvocationId.set(
buildEvent.id.childInvocationCompleted.invocationId,
Expand Down
2 changes: 0 additions & 2 deletions cli/remotebazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ go_library(
"//proto:build_event_stream_go_proto",
"//proto:buildbuddy_service_go_proto",
"//proto:eventlog_go_proto",
"//proto:execution_stats_go_proto",
"//proto:git_go_proto",
"//proto:invocation_go_proto",
"//proto:remote_execution_go_proto",
Expand All @@ -40,7 +39,6 @@ go_library(
"@com_github_go_git_go_git_v5//plumbing",
"@org_golang_google_genproto_googleapis_bytestream//:bytestream",
"@org_golang_google_grpc//metadata",
"@org_golang_x_sync//errgroup",
"@org_golang_x_sys//unix",
],
)
Expand Down
62 changes: 18 additions & 44 deletions cli/remotebazel/remotebazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ import (
"github.com/buildbuddy-io/buildbuddy/server/util/status"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"golang.org/x/sync/errgroup"
"golang.org/x/sys/unix"
"google.golang.org/grpc/metadata"

bespb "github.com/buildbuddy-io/buildbuddy/proto/build_event_stream"
bbspb "github.com/buildbuddy-io/buildbuddy/proto/buildbuddy_service"
elpb "github.com/buildbuddy-io/buildbuddy/proto/eventlog"
espb "github.com/buildbuddy-io/buildbuddy/proto/execution_stats"
gitpb "github.com/buildbuddy-io/buildbuddy/proto/git"
inpb "github.com/buildbuddy-io/buildbuddy/proto/invocation"
repb "github.com/buildbuddy-io/buildbuddy/proto/remote_execution"
Expand Down Expand Up @@ -772,6 +770,7 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
CommitSha: repoConfig.CommitSHA,
Branch: repoConfig.Ref,
},
BazelCommand: strings.Join(bazelArgs, " "),
Os: reqOS,
Arch: reqArch,
ContainerImage: *containerImage,
Expand All @@ -781,18 +780,6 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
}
req.GetRepoState().Patch = append(req.GetRepoState().Patch, repoConfig.Patches...)

// TODO(Maggie): Clean up after we've migrated fully to use `Steps`
stepsMode := os.Getenv("STEPS_MODE") == "1"
if stepsMode {
req.Steps = []*rnpb.Step{
{
Run: fmt.Sprintf("bazel %s", strings.Join(bazelArgs, " ")),
},
}
} else {
req.BazelCommand = strings.Join(bazelArgs, " ")
}

if *timeout != 0 {
req.Timeout = timeout.String()
}
Expand Down Expand Up @@ -837,44 +824,25 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
}
isInvocationRunning = false

eg := errgroup.Group{}
var inRsp *inpb.GetInvocationResponse
var exRsp *espb.GetExecutionResponse
eg.Go(func() error {
var err error
inRsp, err = bbClient.GetInvocation(ctx, &inpb.GetInvocationRequest{Lookup: &inpb.InvocationLookup{InvocationId: iid}})
if err != nil {
return fmt.Errorf("could not retrieve invocation: %s", err)
}
if len(inRsp.GetInvocation()) == 0 {
return fmt.Errorf("invocation not found")
}
return nil
})
eg.Go(func() error {
var err error
exRsp, err = bbClient.GetExecution(ctx, &espb.GetExecutionRequest{ExecutionLookup: &espb.ExecutionLookup{
InvocationId: iid,
}})
if err != nil {
return fmt.Errorf("could not retrieve ci_runner execution: %s", err)
}
if len(exRsp.GetExecution()) == 0 {
return fmt.Errorf("ci_runner execution not found")
}
return nil
})
err = eg.Wait()
inRsp, err := bbClient.GetInvocation(ctx, &inpb.GetInvocationRequest{Lookup: &inpb.InvocationLookup{InvocationId: iid}})
if err != nil {
return 0, err
return 0, fmt.Errorf("could not retrieve invocation: %s", err)
}
if len(inRsp.GetInvocation()) == 0 {
return 0, fmt.Errorf("invocation not found")
}

childIID := ""
exitCode := -1
runfilesRoot := ""
var runfiles []*bespb.File
var runfileDirectories []*bespb.Tree
var defaultRunArgs []string
for _, e := range inRsp.GetInvocation()[0].GetEvent() {
if cic, ok := e.GetBuildEvent().GetPayload().(*bespb.BuildEvent_ChildInvocationCompleted); ok {
childIID = e.GetBuildEvent().GetId().GetChildInvocationCompleted().GetInvocationId()
exitCode = int(cic.ChildInvocationCompleted.ExitCode)
}
if runOutput {
if rta, ok := e.GetBuildEvent().GetPayload().(*bespb.BuildEvent_RunTargetAnalyzed); ok {
runfilesRoot = rta.RunTargetAnalyzed.GetRunfilesRoot()
Expand All @@ -885,7 +853,13 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
}
}

exitCode := int(exRsp.GetExecution()[0].ExitCode)
if exitCode == -1 {
if ctx.Err() != nil {
return 0, ctx.Err()
}
return 0, fmt.Errorf("could not determine remote Bazel exit code")
}

if fetchOutputs && exitCode == 0 {
conn, err := grpc_client.DialSimple(opts.Server)
if err != nil {
Expand Down
Loading

0 comments on commit 49f765e

Please sign in to comment.