Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethink runtime annotations #2210

Open
jodh-intel opened this issue Jul 9, 2021 · 3 comments
Open

Rethink runtime annotations #2210

jodh-intel opened this issue Jul 9, 2021 · 3 comments
Labels
area/runtime Issues that impact the runtime (including shimv2) enhancement Improvement to an existing feature

Comments

@jodh-intel
Copy link
Contributor

PR #902 added the ability to restrict the set of annotations the runtime will honour, based on a set of regular expressions. However, with the advent of the useful PR #2156, I think we need to do more.

Current design

  • Set DEFENABLEANNOTATIONS in src/runtime/Makefile to a set of regular expressions. If an annotation matches a regex, it is allowed.
  • This list is added to the auto-generated configuration file (such as configuration-qemu.toml) as enable_annotations =.
  • When the runtime parses the OCI config file, it calls addAnnotations() (in src/runtime/virtcontainers/pkg/oci/utils.go) to check that the annotations specified in the OCI config file have been enabled. If any specified annotation is not enabled, the function returns and error.

Problems

  • There is currently no way to list available annotations: you need to go and view the source file src/runtime/virtcontainers/pkg/annotations/annotations.go or look at the docs (which we have to remember to update...).
  • As highlighted on runtime: Enable all the "non dangerous" annotations by default #2156, we arguably have an "annotation management issue": we have a lot of annotations and need to be able to create an allow or deny list to manage the default set. But currently we either have a huge allow list (safer) or a smaller deny list. The latter is easier to manage but less safe: if we use a deny list and add a new annotation but forget to add it to the deny list (even if it's "dangerous"), that new annotation will be allowed.

Proposals

Create a new runtime command to list annotations:

$ kata-runtime annotations list

This command will list atleast the following details (potentially in various output formats (csv, json, blah):

  • The name of the annotation.

  • The type of the annotation (int, bool, string, etc).

  • The human readable textual description of the annotation.

  • Whether the annotation would be enabled at runtime.
    (based on the current values speciifed in the enable_annotations = setting in the configuration file).

  • Whether the annotation is "dangerous"

    It may be better to encode one or more "types" for each annotation, one of which could be "security"?

All fields would be mandatory.

Advantages

  • Guaranteed correct annotation details: Admins wouldn't need to look at the source / potentiall outdated docs to find out what an annotation does.

  • Simpler docs: we could auto-generate docs/how-to/how-to-set-sandbox-config-kata.md from the output of kata-runtime annotations list (or just tell admins the command to run themselves).

  • Safer updates: If a new annotation is added to the runtime, it would need to specify the details above, meaning everyone would always be able to determine which annotations where "dangerous".

  • We could generate a guaranteed safe set of "non-dangerous" annotations as part of the packaging by running something equivalent to:

    $ kata-runtime annotations list | grep -iv dangerous > configuration-annotations.toml
  • We could "seed" the CI by creating a data file in the tests repo.

    Ever PR could then run a set of simple annotation tests that ran kata-runtime annotations list.
    If the output contains annotations not listed in the test repos data file, the CI would immediately fail
    (since it indicates we added an annotation without updating the tests config file). The correct way to deal with a new annotation would be to update the tests config file before testing a PR that added a new annotation.

Refactoring work

Remove the "bare const" annotation variables and instead create a function that returns a slice of all available annotations. There will be some additional rework (and unit tests) for this, but by making the annotation code more cohesive, we get the benefits outlined above.

The work would in fact be similar to #1086 (and would require rework of the asset types package).

See also

/cc @fidencio, @c3d, @amshinde, @egernst, @sameo

@jodh-intel jodh-intel added enhancement Improvement to an existing feature needs-review Needs to be assessed by the team. labels Jul 9, 2021
@eadamsintel
Copy link
Contributor

I think this is a wonderful enhancement idea. Are you also suggesting to move the annotations enabled out of the Kata configuration.toml file and into a configuration-annotations.toml file? I personally would try to keep a single Kata configuration.toml for all configuration items for simplicity. I didn't catch it in the proposal but could you enable/disable annotations directly from kata-runtime. That would be a nice feature as well. I could see something like the following. I put multiple ones in a list since I assume people would want multiple annotations turned on and off by default. You could extend this idea with the dangerous annotations as well so you could enable everything but the dangerous ones or just enable every annotation with a single command.

$ sudo kata-runtime annotations enable kernel image kernel_params

I can see benefits to having the annotations configured in a separate file as well. In the case of kata-deploy or even a Kata operator you could install Kata but then drop in the supported annotation file to your cluster to ensure you set the right level of security. If the kata-deploy pod got restarted it might reinstall the kata artifacts over writing any custom config which is where a separate approved annotations file could make sense. I had this actually happen to me when I enabled all the annotations and 20 min later my configuration.toml got reverted.

@fidencio
Copy link
Member

fidencio commented Jul 9, 2021

@eadamsintel, partially related to your comment, but I've been going back and forth with the idea of supporting drop-in snippets, something that could be read from /etc/kata-containers/configuration.d/00-annotations, for instance, so admins could simply drop-in a file to augment the default configuration with whatever they need.

This is something that's been on my long-term todo list for a while already, and I think that sooner or later (depending on my employer's wishlist) I'll end up taking the bullet and implementing it. While on this, I should track it. /o.

@ariel-adam ariel-adam added area/runtime Issues that impact the runtime (including shimv2) and removed needs-review Needs to be assessed by the team. labels Jul 13, 2021
cmaf added a commit to cmaf/kata-containers that referenced this issue Sep 8, 2021
Upgrade from v0.20.0 to v1.0.0-RC3.

    Git log

    4bfa0034 Release prep v1.0.0-RC3 (kata-containers#2218)
    c7ae470a Refactor SDK span creation and implementation (kata-containers#2213)
    db317fce Verify and update OTLP trace exporter documentation (kata-containers#2053)
    04de34a2 Update the website getting started docs (kata-containers#2203)
    a7b9d021 Rename metric instruments to match feature-freeze API specification (kata-containers#2202)
    1f527a52 Update trace API config creation functions (kata-containers#2212)
    361a2096 Fix RC2 header in changelog (kata-containers#2215)
    e209ee75 chore(exporter/zipkin): improves logging on invalid collector. (kata-containers#2191)
    c0c5ef65 Fix typos in resource.go. (kata-containers#2201)
    abf6afe0 Update otel example guide (kata-containers#2210)
    3b05ba02 Bump actions/setup-go from 2.1.3 to 2.1.4 (kata-containers#2206)
    bcd7ff7b Bump codecov/codecov-action from 2.0.2 to 2.0.3 (kata-containers#2205)
    c912b179 Print JSON objects to stdout without a wrapping array (kata-containers#2196)
    add511c1 Make WithoutTimestamps work (kata-containers#2195)
    85c27e01 Bump github.com/golangci/golangci-lint from 1.41.1 to 1.42.0 in /internal/tools (kata-containers#2199)
    bf6500b3 Bump google.golang.org/grpc from 1.39.1 to 1.40.0 in /exporters/otlp/otlptrace (kata-containers#2184)
    9392af96 Bump google.golang.org/grpc in /exporters/otlp/otlptrace/otlptracegrpc (kata-containers#2185)
    c95694dc Bump google.golang.org/grpc from 1.39.1 to 1.40.0 in /example/otel-collector (kata-containers#2183)
    0528fa66 Bump google.golang.org/grpc from 1.39.1 to 1.40.0 in /exporters/otlp/otlpmetric (kata-containers#2186)
    3a26ed21 Deprecate the oteltest package (kata-containers#2188)
    c885435f Website: support GH page links to canonical src (kata-containers#2189)
    6da20a27 Add cross-module test coverage (kata-containers#2182)
    dfc866bd Support capturing stack trace  (kata-containers#2163)
    41588fea Deprecate the attribute.Any function (kata-containers#2181)
    4e8d667f Support a single Resource per MeterProvider in the SDK (kata-containers#2120)
    a8bb0bf8 Make the tracetest.SpanRecorder concurrent safe (kata-containers#2178)
    87d09df3 Deprecate Array attribute in favor of *Slice types (kata-containers#2162)
    df384a9a Move InstrumentKind into the new metric/sdkapi package (kata-containers#2091)
    1cb5cdca Unify the OTLP attribute transform (kata-containers#2170)
    a882ee37 Clarify the attribute package documentation and order/grouping (kata-containers#2168)
    5d25c4d2 Add support for int32 in attribute.Any (kata-containers#2169)
    2b0e139e Refactor attributes benchmark tests (kata-containers#2167)
    4c7470d9 Bump google.golang.org/grpc from 1.39.0 to 1.39.1 in /exporters/otlp/otlptrace (kata-containers#2176)
    990c534a Bump google.golang.org/grpc in /example/otel-collector (kata-containers#2172)
    b45c9d31 Bump google.golang.org/grpc from 1.39.0 to 1.39.1 in /exporters/otlp/otlpmetric (kata-containers#2174)
    a3d4ff5c Deprecated the bridge/opencensus/utils package (kata-containers#2166)
    b1d1d529 Move OC bridge integration tests to own mod (kata-containers#2165)
    89a9489c Add OC bridge internal unit tests (kata-containers#2164)
    56c743ba Allow global ErrorHandler to be set multiple times (kata-containers#2160)
    d18c135f Add OpenCensus bridge internal package (kata-containers#2146)
    fcf945a4 Just a little typo fix in code documentation. (kata-containers#2159)
    59a82eba Update version.go (kata-containers#2157)
    21d4686f Add ErrorHandlerFunc to simplify creating ErrorHandlers (kata-containers#2149)
    23cb9396 Remove `internal/semconv-gen` (kata-containers#2155)
    39acab32 Fix code sample in otel.GetTraceProvider (kata-containers#2147)
    2b1bb29e Update OpenCensus bridge docs with limitations (kata-containers#2145)
    fd7c327b Fix Jaeger exporter agent port default value and docs (kata-containers#2131)
    b8561785 fix(2138): add guard to constructOTResources to return an empty resource (kata-containers#2139)
    11f62640 Add a SpanRecorder to the sdk/trace/tracetest (kata-containers#2132)
    fd9de7ec rename assertsocketbuffersize.go to *_test (kata-containers#2136)
    a6b4d90c nit doc fix (kata-containers#2135)
    79398418 pre-release v1.0.0-RC2 (kata-containers#2133)
    2501e0fd Use semconv.SchemaURL in STDOUT exporter example (kata-containers#2134)
    ef03dbc9 Bump codecov/codecov-action from 1 to 2.0.2 (kata-containers#2129)
    bbe6ca40 Deprecate oteltest.Harness for removal (kata-containers#2123)
    7a624ac2 Deprecated the oteltest.TraceStateFromKeyValues function (kata-containers#2122)
    ece1879f Removed dropped link's attributes field from API package (kata-containers#2118)
    03902d98 Rename sdk/trace/tracetest test.go -> exporter.go (kata-containers#2128)
    cb607b0a Unify OTLP exporter retry logic (kata-containers#2095)
    abe22437 API: create new linked span from current context (kata-containers#2115)
    db81d4aa Update internal/global/trace testing (kata-containers#2111)
    7f10ef72 Remove propagation testing types from oteltest (kata-containers#2116)
    25d739b0 Remove resource.WithBuiltinDetectors() which has not been maintained (kata-containers#2097)
    d57c5a56  Remove several metrics test helpers (kata-containers#2105)
    49359495 Simplify trace_context tests (#2108)
    56d42011 Simplify trace context benchmark test (#2109)
    63dfe64a Correct status transform in OTLP exporter (kata-containers#2102)
    9b1a5f70 Performance improvement: avoid creating multiple same read-only objects (kata-containers#2104)
    ab78dbd0 Update release URL (kata-containers#2106)
    647af3a0 Pre release experimental metrics v0.22.0 (kata-containers#2101)
    0a562337 Fixed OS type value for DragonFly BSD (kata-containers#2092)
    62c21ffb Bump golang.org/x/tools from 0.1.4 to 0.1.5 in /internal/tools (kata-containers#2096)
    4a3da55a Ensure sample code in website_docs getting started page works (kata-containers#2094)
    d3063a3d Update otel.Meter to global.Meter in Getting Started Document.(kata-containers#2087) (kata-containers#2093)
    00a1ec5f Add documentation guidelines and improve Jaeger exporter readme (kata-containers#2082)
    12f737c7 oteltest: ensure valid SpanContext created for span started WithNewRoot (kata-containers#2073)
    484258eb OS description attribute detector (kata-containers#1840)
    d8c9a955 Bump google.golang.org/grpc from 1.38.0 to 1.39.0 in /example/otel-collector (kata-containers#2054)
    4ffdf034 Add @pellard as an Approver (kata-containers#2047)
    1a74b399 Bump google.golang.org/protobuf from 1.26.0 to 1.27.0 in /exporters/otlp/otlpmetric (kata-containers#2040)
    57c2e8fb Bump golang.org/x/tools from 0.1.3 to 0.1.4 in /internal/tools (kata-containers#2036)
    7cff31a9 Bump google.golang.org/protobuf from 1.26.0 to 1.27.0 in /exporters/otlp/otlptrace (kata-containers#2035)
    9e8f523d when using WithNewRoot, don't use the parent context for sampling (kata-containers#2032)
    62af6c70 semconv-gen: fix capitalization at word boundaries, add stability/deprecation indicators (kata-containers#2033)
    0bceed7e Fix docs on otel-collector example (kata-containers#2034)
    6428cd69 Update doc.go (kata-containers#2030)
    311a6396 fix documentation for trace.Status (kata-containers#2029)
    16f83ce6 export ToZipkinSpanModels for use outside this library (kata-containers#2027)
    d5d4c87f Add HTTP metrics exporter for OTLP (kata-containers#2022)
    d6e8f60f Bump github.com/golangci/golangci-lint from 1.40.1 to 1.41.1 in /internal/tools (kata-containers#2023)
    51dbe3cb Remove deprecated exporters (kata-containers#2020)
    257ef7fc Update project status in README (kata-containers#2017)
    ced177b7 Pre-release 1.0.0-RC1 (kata-containers#2013)
    694c9a41 Interface stability documentation (kata-containers#2012)
    39fe8092 Add span.TracerProvider() (kata-containers#2009)
    d020e1a2 Add more tests for go.opentelemetry.io/otel/trace package. (kata-containers#2004)
    6d4a38f1 replace WithSyncer with WithBatcher in opencensus example (kata-containers#2007)
    c30cd1d0 Split stdout exporter into stdouttrace and stdoutmetric (kata-containers#2005)
    80ca2b1e otlp: mark unix endpoints to work without transport security (kata-containers#2001)
    65140985 Update codecov ignore (kata-containers#2006)
    3be9813d Deprecate the exporters in the "trace" and "metric" sub-directories (kata-containers#1993)
    377f7ce4 remove WithTrace* options from otlptrace exporters (kata-containers#1997)
    b33edaa5 OTLP metrics gRPC exporter (kata-containers#1991)
    64b640cc Remove old OTLP exporter (kata-containers#1990)
    7728a521 Remove dependency on metrics packages (kata-containers#1988)
    135ac4b6 Moved internal/tools duplicated findRepoRoot function to common package (kata-containers#1978)
    cdf67ddf Update semantic conventions to v1.4.0, move to versioned package (kata-containers#1987)
    4883cb11 Refactor exporter creation functions (kata-containers#1985)
    87cc1e1f Test BatchSpanProcessor export timeout directly (kata-containers#1982)
    7ffe2845 Added inputPath validation to semconv-gen (kata-containers#1986)
    a113856a Add caveat about installing opencensus bridge (kata-containers#1983)
    741cb9a3 Fix generator.go call typo in RELEASING.md (kata-containers#1977)
    7a0cee7b Replaces golint by revive and fix newly reported linter issues (kata-containers#1946)
    46d9687a Add Schema URL support to Resource (kata-containers#1938)
    0827aa62 Use mock server as jaeger agent listener. (kata-containers#1930)
    20886012 Bugfix jaeger exporter test panic (kata-containers#1973)
    4bf6150f Add baggage implementation based on the W3C and OpenTelemetry specification (kata-containers#1967)
    bbe2b8a3 Bump github.com/itchyny/gojq from 0.12.3 to 0.12.4 in /internal/tools (kata-containers#1971)
    4949bf05 Bump github.com/cenkalti/backoff/v4 from 4.1.0 to 4.1.1 in /exporters/otlp/otlptrace (kata-containers#1972)
    015b4c17 Bump github.com/cenkalti/backoff/v4 from 4.1.0 to 4.1.1 in /exporters/otlp (kata-containers#1970)
    13eb12ac Bump github.com/prometheus/client_golang from 1.10.0 to 1.11.0 in /exporters/metric/prometheus (kata-containers#1974)
    2371bb0a add otlp trace http exporter (kata-containers#1963)
    a75ade4e sdk/resource: honor OTEL_SERVICE_NAME in fromEnv resource detector (kata-containers#1969)
    aed45802 Bump go.opentelemetry.io/proto/otlp from 0.8.0 to 0.9.0 in /exporters/otlp/otlptrace (kata-containers#1959)
    c4ebae6a Bump go.opentelemetry.io/proto/otlp (kata-containers#1960)
    b1d2be3b Bump google.golang.org/grpc from 1.37.1 to 1.38.0 in /exporters/otlp/otlptrace (kata-containers#1958)
    f6daea5e Generate semantic conventions according to specification latest tagged version (kata-containers#1933)
    435a63b3 Bump github.com/google/go-cmp from 0.5.5 to 0.5.6 (kata-containers#1954)
    6c46af66 Bump github.com/google/go-cmp from 0.5.5 to 0.5.6 in /exporters/trace/jaeger (kata-containers#1953)
    4d294853 Bump actions/cache from 2.1.5 to 2.1.6 (kata-containers#1952)
    dfe2b6f1 OTLP trace gRPC exporter (kata-containers#1922)
    5a8f7ff7 Bump go.opentelemetry.io/proto/otlp from 0.8.0 to 0.9.0 in /exporters/otlp (kata-containers#1943)
    bd935866 Add schema URL support to Tracer (kata-containers#1889)
    c1f460e0 Update API configs. (kata-containers#1921)
    270cc603 Small fixes on some Span method's documentation headers (kata-containers#1950)
    8603b902 Fix typo in doc (kata-containers#1949)
    acbb1882 Bump google.golang.org/grpc from 1.37.1 to 1.38.0 in /exporters/otlp (kata-containers#1942)
    b1621501 Add codecov badge (kata-containers#1940)
    ea1434c3 Fix some golint issues (kata-containers#1947)
    0eeb8f87 Refactor Tracestate (kata-containers#1931)
    d3b12808 Add Passthrough example (kata-containers#1912)
    f06cace6 Add @MadVikingGod as a project Approver (kata-containers#1923)
    ab5facb3 Bump github.com/golangci/golangci-lint in /internal/tools (kata-containers#1925)
    d23cc61b Refactor configs (kata-containers#1882)
    6324adaa Add tracer option argument to global Tracer function (kata-containers#1902)
    035fc650 Do not include authentication information in the http.url attribute (kata-containers#1919)
    d8ac212c Fix sporadic test failure in otlp exporter http driver (kata-containers#1906)
    a3df00f4 Create .gitattributes (kata-containers#1920)
    fb88e926 Bump google.golang.org/grpc from 1.37.0 to 1.37.1 in /exporters/otlp (kata-containers#1914)
    1982dc46 Bump google.golang.org/grpc in /example/prom-collector (kata-containers#1915)
    1759c630 Bump github.com/golangci/golangci-lint in /internal/tools (kata-containers#1916)
    7342aa47 Bump google.golang.org/grpc in /example/otel-collector (kata-containers#1913)
    21c16418 Add support for scheme in OTEL_EXPORTER_OTLP_ENDPOINT (kata-containers#1886)
    5cb62636 Semantic Convention generation tooling (kata-containers#1891)
    6219221f Move the unit package to the metric module (kata-containers#1903)
    63e0ecfc Implement global default non-recording span (kata-containers#1901)
    b6d5442f Remove the Tracer method from the Span API (kata-containers#1900)
    ae85fab3 Document functional options (kata-containers#1899)
    cabf0c07 Fix default Jaeger collector endpoint (kata-containers#1898)
    1e3fa3a3 Bump go.opentelemetry.io/proto/otlp from 0.7.0 to 0.8.0 in /exporters/otlp (kata-containers#1872)
    696af787 Bump github.com/benbjohnson/clock from 1.0.3 to 1.1.0 in /sdk/metric (kata-containers#1532)
    97eea6c3 Fix some golint issues (kata-containers#1894)
    79d9852e fix container port mismatch issue (kata-containers#1895)
    d20e7228 CI builds validate against last two versions of Go, dropping 1.14 and adding 1.16 (kata-containers#1865)
    cbcd4b1a Redefine ExportSpans of SpanExporter with ReadOnlySpan (kata-containers#1873)
    c99d5e99 Split large jaeger span batch to admire the udp packet size limit  (kata-containers#1853)
    42a84509 Unembed SpanContext (kata-containers#1877)
    b7d02db1 Add Status type to SDK (kata-containers#1874)
    f90d0d93 Update README (kata-containers#1876)
    a1349944 Update resource.go (kata-containers#1871)
    f40cad5e Add markdown link check configuration and action (kata-containers#1869)
    9bc28f6b Fix existing markdown lint issues (kata-containers#1866)
    08f4c270 Add documentation for tracer.Start() (kata-containers#1864)
    2bd4840c remove Set.Encoded(Encoder) enconding cache (kata-containers#1855)
    7674eebf Removed different types of Detectors for Resources. (kata-containers#1810)
    f92a6d83 Implement retry policy for the OTLP/gRPC  exporter (kata-containers#1832)
    ec75390f Fix BSP context done tests (kata-containers#1863)
    8e55f10a Move the Event type from the API to the SDK (kata-containers#1846)
    e399d355 drop failed to exporter batches and return error when forcing flush a span processor (kata-containers#1860)
    f6a9279a Honor context deadline or cancellation in SimpleSpanProcessor.Shutdown (kata-containers#1856)
    aeef8e00 Add markdown lint GitHub action (kata-containers#1849)
    d4c8ffad Replace spaces to tabs in Go code snippets (kata-containers#1854)
    cb097250 fixed typo (kata-containers#1857)
    392a44fa Refine configuration design docs (kata-containers#1841)
    62cd933d Handle Resource env error when non-nil (kata-containers#1851)
    24a91628 Document the SSP is not for production use (kata-containers#1844)
    ec26ac23 Update RELEASING.md (kata-containers#1843)
    8eb0bb99 Fix golint issue caused by typo (kata-containers#1847)
    ca130e54 Markdownlint (kata-containers#1842)
    1144a83d Small typo fixes to existing CHANGELOG entries (kata-containers#1839)
    e6086958 Update website_docs to v0.20.0 (kata-containers#1838)
    0f4e454c Change NewSplitDriver paramater and initialization (kata-containers#1798)

Fixes kata-containers#2591

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
@eadamsintel
Copy link
Contributor

I ran into what I think is a bug with the current implementation. I was just using kata-deploy and the configuration-qemu.toml has it set to enable_annotations = []. When I changed this to enable_annotations = [".*"] I was able to change things like the PCIe root port and other items. However, when I rebooted my computer the kata-deploy script ran again and overwrote my installation and reset the configuration-qemu.toml back to its original. That means that my pod couldn't start back up after rebooting.

Failed to create pod sandbox: rpc error: code = Unknown desc = CreateContainer failed: annotation io.katacontainers.config.hypervisor.kernel_params is not enabled: unknown

Probably this is a bug with kata-deploy to not install over itself, but it is the annotations that really makes this issue manifest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime Issues that impact the runtime (including shimv2) enhancement Improvement to an existing feature
Projects
Issue backlog
  
To do
Development

No branches or pull requests

4 participants