15 Commits
Author SHA1 Message Date
Etienne PerotandgVisor bot b4ca91450f Standardize timestamps in runsc log filenames.
Prior to this change, the log files each have their own timestamp computed
independently. For example, this means that the coverage log file, the panic
log file, the debug log file, the first Gofer's log file, and the profile
files for the same Sentry may all have different timestamps in their
filenames. Now they are the same.

This change introduces a central `runsc/starttime` package for which the sole
purpose is to hold the start time of the `runsc` process, for easy plumbing
in all places that need it.

PiperOrigin-RevId: 646667986
2024-06-25 17:48:13 -07:00
Etienne PerotandgVisor bot c8da73daaf Add option to dump profiling metrics within a container's stdout logs.
This is part of a series of changes to add metric charts in performance
benchmarks.

This change is useful to be able to extract profiling metric data easily
regardless of runtime configuration.

This change also changes where profiling metrics are initialized and
configured. They are now only part of `runsc boot`, rather than all `runsc`
invocations.

PiperOrigin-RevId: 629900287
2024-05-01 18:33:26 -07:00
Josh Seba 5f52ed57e5 Add subcommand to list nvproxy supported driver versions
Since the driver versions are hard-coded, determining the supported
version list requires code inspection, which is difficult to automate.
Add a sub-command (and category) to print the list of nvidia
driver versions supported by nvproxy for a given build of runsc.

Signed-off-by: Josh Seba <jseba@cloudflare.com>
2023-10-30 15:19:06 -07:00
Konstantin BogomolovandgVisor bot 440b37a5c1 Add profiling metric flags to output metric data to local TSV file.
The idea behind conditionally compiled metrics originally was to use them in
hotpaths for profiling purposes. This CL makes that possible by outputting
declared metrics in TSV format, which can be used to track custom events at
runtime in relatively high resolution.

Usage:
    1. Optionally enable compilation of runsc conditionally-compiled metrics
       by passing in condmetric_profiling to the Go tags.
    2. Add these flags to runsc:
    - [Required] --profiling-metrics-log=/tmp/some.csv
    - [Optional] --profiling-metrics=/task/syscalls,/task/faults
      - If this flag is not specified it will monitor all
        conditionally-compiled metrics by default.
    - [Optional] --profiling-metrics-rate-us=10000

Some future improvements:
    - Flag to output a metric-difference between timestamps instead of
      constant accumulation.
    - Output a gnuplot command along with the data.
    - Current monitoring resolution is limited by what time.Sleep allows.
      This can be overcome by spinning/yielding when lower monitoring
      rates are requested.

PiperOrigin-RevId: 560849611
2023-08-28 16:28:09 -07:00
Ayush RanjanandgVisor bot 7981df85f3 Make all custom flag.Value implementations idempotent.
Set(String()) should be an idempotent operation. This is a useful property
which allows us to generate args while re-execing the same process. Setting
`--flag-name=val.String()` should work.

PiperOrigin-RevId: 552598313
2023-07-31 14:53:21 -07:00
Etienne PerotandgVisor bot d0326a67da runsc: Refactor in how the version string is propagated in runsc.
This is helpful so that it can be imported form other packages without import
loops.

This will be used in a follow-up change to add the version string as a
per-sandbox metric metadata label.

PiperOrigin-RevId: 519002695
2023-03-23 17:12:09 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Konstantin BogomolovandgVisor bot 1832c38a95 Add TESTONLY sentry panic trigger through afs_syscall.
This flag is added for tests that need to trigger a panic in the sentry
kernel. Only done for x86_64 which does have a dedicated syscall number for
afs_syscall; ARM does not.

PiperOrigin-RevId: 512731631
2023-02-27 14:28:30 -08:00
Ayush RanjanandgVisor bot 175db901ca Replace pkg/refs with pkg/refsvfs2.
All VFS1 only bits have been deleted.

Updates #1624

PiperOrigin-RevId: 492273183
2022-12-01 12:46:11 -08:00
Fabricio VoznikaandgVisor bot f34e34b3c3 Add runsc trace commands
The trace commands allows a user to manipulate trace sessions.

`runsc trace create <name> --config <file>` => creates a new trace session
`runsc trace delete <name>` => deletes an existing trace session
`runsc trace list` => lists all running trace sessions
`runsc trace metadata` => lists all point with their respective optional and
context fields

This allows trace sessions to be created/deleted on a running sandbox. Note
that the system currently only allows a single trace session to exist, named
'Default'. Attempts to manipulate other sessions will error out.

Updates #4805

PiperOrigin-RevId: 447815153
2022-05-10 13:40:39 -07:00
Fabricio VoznikaandgVisor bot 368a4fe8b3 Refactor subcommands error handling into a separate package
This is going to be used by the trace subcommand which lives in
another package.

Updates #4805

PiperOrigin-RevId: 447006075
2022-05-06 09:40:39 -07:00
Dean DengandgVisor bot 20b1c3c632 Move runsc reference leak checking to better locations.
In the previous spot, there was a roughly 50% chance that leak checking would
actually run. Move it to the waitContainer() call on the root container, where
it is guaranteed to run before the sandbox process is terminated. Add it to
runsc/cli/main.go as well for good measure, in case the sandbox exit path does
not involve waitContainer().

PiperOrigin-RevId: 369329796
2021-04-19 16:48:27 -07:00
Dean DengandgVisor bot 0c3e8daf50 Allow runsc to generate coverage reports.
Add a coverage-report flag that will cause the sandbox to generate a coverage
report (with suffix .cov) in the debug log directory upon exiting. For the
report to be generated, runsc must have been built with the following Bazel
flags: `--collect_code_coverage --instrumentation_filter=...`.

With coverage reports, we should be able to aggregate results across all tests
to surface code coverage statistics for the project as a whole.

The report is simply a text file with each line representing a covered block
as `file:start_line.start_col,end_line.end_col`. Note that this is similar to
the format of coverage reports generated with `go test -coverprofile`,
although we omit the count and number of statements, which are not useful for
us.

Some simple ways of getting coverage reports:

bazel test <some_test> --collect_code_coverage \
  --instrumentation_filter=//pkg/...

bazel build //runsc --collect_code_coverage \
  --instrumentation_filter=//pkg/...
runsc -coverage-report=dir/ <other_flags> do ...

PiperOrigin-RevId: 368952911
2021-04-16 17:56:16 -07:00
Ayush RanjanandgVisor bot e668288faf [op] Replace syscall package usage with golang.org/x/sys/unix in runsc/.
The syscall package has been deprecated in favor of golang.org/x/sys.

Note that syscall is still used in some places because the following don't seem
to have an equivalent in unix package:
- syscall.SysProcIDMap
- syscall.Credential

Updates #214

PiperOrigin-RevId: 361381490
2021-03-06 22:07:07 -08:00
Adin ScannellandgVisor bot 54e989ec3a Remove legacy bazel configurations.
Using the newer bazel rules necessitates a transition from proto1 to
proto2. In order to resolve the incompatibility between proto2 and
gogoproto, the cri runtimeoptions proto must be vendored.

Further, some of the semantics of bazel caching changed during the
transition. It is now necessary to:

- Ensure that :gopath depends only on pure library targets, as the
  propagation of go_binary build attributes (pure, static) will
  affected the generated files (though content remains the same,
  there are conflicts with respect to the gopath).
- Update bazel.mk to include the possibility of binaries in the
  bazel-out directory, as it will now put runsc and others there.
  This required some refinements to the mechanism of extracting
  paths, since some the existing regex resulted in false positives.
- Change nogo rules to prevent escape generation on binary targets.
  For some reason, the newer version of bazel attempted to run the
  nogo analysis on the binary targets, which fails due to the fact
  that objdump does not work on the final binary. This must be due
  to a change in the semantics of aspects in bazel3.

PiperOrigin-RevId: 337958324
2020-10-19 16:28:40 -07:00