go/

directory
v0.0.0-...-c1bc825 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: Apache-2.0

README

Go SDK

Usage

TODO(jsharpe): Write usage instructions.

remotetool

remotetool is a CLI tool to interact with remote build execution. In particular, blobs and input trees can be downloaded and uploaded from CAS, actions and their inputs can be downloaded to be either re-run locally or remotely.

Common flags

Flags that describe the RBE instance used and the authentication method are common to most remotetool invocations. The --instance, --service, and credential flags (--use_application_default_credentials, --use_gce_credentials, --credential_file=FILE, one of which must be set), in particular, are further documented under pkg/flags/flags.go.

--alsologtostderr and -v VERBOSITY_LEVEL can be used to tune the verbosity and location of the output, e.g. --alsologtosrderr -v 1.

Downloading an action's inputs and metadata
bazelisk run //go/cmd/remotetool -- \
  --operation=download_action \
  COMMON_FLAGS \
  --digest=DIGEST \
  --path=PATH
  • For COMMON_FLAGS, see the above section
  • The --digest flag is formatted as "{hash}/{size}" and can typically be obtained from logs of the tool that originally ran the action.
  • The --path flag is the destination where the action inputs will be downloaded (under PATH/input), as well as:
    • metadata relating to the action (e.g. command hash, input tree hash, individual input file hashes...)
    • run_command.sh, a script that contains the command line of the action to be re-run
    • run_locally.sh, a script that contains the docker invocation to re-run the action locally

The action can then be re-run locally by running ./run_locally.sh, or remotely using the instructions below. When running the action locally, local modifications made to the input folder will be picked up automatically, but not if re-running the action remotely, read on for more on this.

Re-running a downloaded action remotely
bazelisk run //go/cmd/remotetool -- \
  --operation=execute_action \
  COMMON_FLAGS
  [--action_root=PATH|--digest=DIGEST] \
  --path OUTPUT_PATH
  • For COMMON_FLAGS, see the above section.
  • An action digest formatted as "{hash}/{size}" can be provided directly using the --digest flag, or a previously downloaded action can be used with --action_root. The --action_root path should point to the --path of a previous download_action invocation. Specifically, the --action_root folder must contain a cmd.textproto and ac.textproto files.
  • --path is the destination where the outputs of the action will be downloaded
Running a modified version of a downloaded action
  1. Download an action to a given PATH following the instructions for downloading an action,
  2. modify the input under PATH/input as needed,
  3. run the action and be sure to include the --action_root=PATH argument.

Alternatively, you could also:

  1. upload the newly formed input directory using remotetool:
    bazelisk run //go/cmd/remotetool -- \
      --operation=upload_dir \
      COMMON_FLAGS \
      --path=PATH/input
    
    remotetool will log the digest of the newly uploaded input folder, NEW_DIGEST.
  2. In the ac.textproto file under PATH, update the input_root_digest fields with the NEW_DIGEST information.
  3. Run the action using the instructions for re-running a downloaded action

Development

Update BUILD.bazel files with (with fix to be more aggressive):

bazel run //:gazelle [fix]

Update go.mod files with:

go mod tidy

Format all files with:

gofmt -w go

Check your code for lint/vet warnings (install golint with sudo apt-get install golint):

golint ./...
go vet ./...

Run all tests:

bazel test ...

or

go test ./...

Directories

Path Synopsis
api
cmd
remotetool
Main package for the remotetool binary.
Main package for the remotetool binary.
rexec
Main package for the rexec binary.
Main package for the rexec binary.
pkg
actas
Package actas provides a TokenSource that returns access tokens that impersonate a different service account other than the default app credentials.
Package actas provides a TokenSource that returns access tokens that impersonate a different service account other than the default app credentials.
balancer
Package balancer is a forked version of https://github.com/GoogleCloudPlatform/grpc-gcp-go.
Package balancer is a forked version of https://github.com/GoogleCloudPlatform/grpc-gcp-go.
cache
Package cache implements a cache that supports single-flight value computation.
Package cache implements a cache that supports single-flight value computation.
cas
Package cas implements an efficient client for Content Addressable Storage.
Package cas implements an efficient client for Content Addressable Storage.
chunker
Package chunker provides a way to chunk an input into uploadable-size byte slices.
Package chunker provides a way to chunk an input into uploadable-size byte slices.
client
Package client contains a high-level remote execution client library.
Package client contains a high-level remote execution client library.
command
Package command defines common types to be used with command execution.
Package command defines common types to be used with command execution.
contextmd
Package contextmd allows attaching metadata to the context of RPC calls.
Package contextmd allows attaching metadata to the context of RPC calls.
digest
Package digest contains functions to simplify handling content digests.
Package digest contains functions to simplify handling content digests.
errors
Package errors provides the ability to wrap multiple errors while maintaining API compatibility with the standard package.
Package errors provides the ability to wrap multiple errors while maintaining API compatibility with the standard package.
fakes
Package fakes contains configurable test fakes for an RE service.
Package fakes contains configurable test fakes for an RE service.
filemetadata
Package filemetadata contains types of metadata for files, to be used for caching.
Package filemetadata contains types of metadata for files, to be used for caching.
flags
Package flags provides a convenient way to initialize the remote client from flags.
Package flags provides a convenient way to initialize the remote client from flags.
moreflag
Package moreflag contains definitions for some useful flag types, such as maps.
Package moreflag contains definitions for some useful flag types, such as maps.
outerr
Package outerr contains types to record/pass system out-err streams.
Package outerr contains types to record/pass system out-err streams.
portpicker
Package portpicker allows Go programs and tests to receive the best guess of an unused port that may be used for ad hoc purposes.
Package portpicker allows Go programs and tests to receive the best guess of an unused port that may be used for ad hoc purposes.
retry
Package retry implements retry logic helpers, which can be used to wrap operations that can intermittently fail, but can be retried at a higher level.
Package retry implements retry logic helpers, which can be used to wrap operations that can intermittently fail, but can be retried at a higher level.
rexec
Package rexec provides a top-level client for executing remote commands.
Package rexec provides a top-level client for executing remote commands.
symlinkopts
Package symlinkopts provides an efficient interface to create unambiguous symlink options.
Package symlinkopts provides an efficient interface to create unambiguous symlink options.
tool
Package tool provides implementation of the debugging related operations supported by go/cmd/remotetool package.
Package tool provides implementation of the debugging related operations supported by go/cmd/remotetool package.
uploadinfo
Package uploadinfo provides a way to move metadata and/or actual data on blobs to be uploaded.
Package uploadinfo provides a way to move metadata and/or actual data on blobs to be uploaded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL