bols: implement ReadFileByBlock and unify handler across daemons
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+1 - LGTM.
One doc nit inline, unresolved. Unrelated aside: TestGetServoTopology_ReturnsFtdiMauiCableAsRoot fails on any workstation that has /sys/bus/usb/devices/1-4 (fails identically on main without this CL) because the host-mode path runs filepath.Glob against the real sysfs - worth a separate fix since it makes local `go test ./cros/lib/bols/...` red for developers.
| Code-Review | +1 |
// - NumberOfBlocks: number of blocks to read ("dd count=<number_of_blocks>"); if <= 0, reads until EOF.nit (doc, non-blocking): worth one sentence here on the timeout asymmetry, since this line advertises "reads until EOF" (i.e. potentially a whole USB device):
So a PARIS/bols_testing caller doing an until-EOF read of a large device in container mode must set a deadline or the stream dies at 60s with a generic "exceeded timeout". Same applies to WriteFileByBlock, so a shared note is fine.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// - NumberOfBlocks: number of blocks to read ("dd count=<number_of_blocks>"); if <= 0, reads until EOF.nit (doc, non-blocking): worth one sentence here on the timeout asymmetry, since this line advertises "reads until EOF" (i.e. potentially a whole USB device):
- container mode passes timeRemaining(ctx) to docker Exec, which falls back to a 1-minute default when the caller set no deadline, and a cancel does not kill the dd inside the container;
- host mode is unbounded and exec.CommandContext kills dd on cancel.
So a PARIS/bols_testing caller doing an until-EOF read of a large device in container mode must set a deadline or the stream dies at 60s with a generic "exceeded timeout". Same applies to WriteFileByBlock, so a shared note is fine.
Done. Added the timeout caveat to the docstring noting the 1-minute fallback in container mode and bounded cancellation in host mode.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: go/src/infra/cros/lib/bols/file_service.go
Insertions: 4, Deletions: 0.
@@ -720,6 +720,10 @@
// - FilePath: required path to the regular file or block device (e.g., "/dev/sda").
// - ByteSize: block size in bytes passed to "dd bs=<byte_size>" (defaults to 512 if <= 0).
// - NumberOfBlocks: number of blocks to read ("dd count=<number_of_blocks>"); if <= 0, reads until EOF.
+// Timeout caveat: in container mode, docker Exec enforces a 1-minute default timeout if ctx
+// has no deadline (cancelling ctx does not kill dd inside the container). Callers performing
+// large until-EOF reads in container mode must configure an explicit ctx deadline. In host mode,
+// execution is bounded by ctx and dd is killed on cancel.
//
// Example use cases in PARIS (infra/cros/recovery):
// - USB-drive health audit (audit_usb): reading 1 MiB or 4 MiB blocks from a
```
bols: implement ReadFileByBlock and unify handler across daemons
Summary:
Implement the ReadFileByBlock streaming gRPC handler on *bols.Service in
infra/cros/lib/bols and remove the duplicate ReadFileByBlock handler from
bols_labstation so bols_satlab, bols_linux, and bols_labstation share a
single implementation.
Why / Reasoning:
Previously, ReadFileByBlock was only implemented in bols_labstation while
bols_satlab and bols_linux returned Unimplemented. Moving ReadFileByBlock
into infra/cros/lib/bols/file_service.go with host-mode and container-mode
dispatch eliminates duplicate gRPC stream handling across the three BOLS
daemons.
Associated Bugs:
b/572930938
Other Details:
Documented the logic difference between host mode (bols_labstation, where
dd reads directly from the host filesystem) and container mode
(bols_satlab and bols_linux, where dd executes inside the target Docker
container and streams stdout chunks via an io.Writer adapter) along with
PARIS recovery usage examples.
How Tested:
1. Ran unit tests and golangci-lint across cros/lib/bols and all three
BOLS daemon packages.
2. Verified end-to-end BOLS RPC suite on Satlab s2 and Labstation
chromeos15-row1-rack1-labstation via SSH port-forwarding.
BUG=b:572930938
TEST=go test ./cros/lib/bols/... ./cros/cmd/cft/bols_labstation/... ./cros/cmd/cft/bols_satlab/... ./cros/cmd/cft/bols_linux/...
TEST=make -C cros/cmd/cft/testing/bols_testing run-on-satlab-dev SATLAB_HOSTNAME=s2 NEW_FEATURES=true
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |