Commit Graph

54 Commits

Author SHA1 Message Date
Ashutosh Narkar c858397ffc plugins: Surface more decision log errors via status API
Previously in #5732 we updated the decision log plugin to
surface errors via the Status API. However in that change
certain events like encoder errors and log drops due to
buffer size limits had no metrics associated with them.
This change adds more metrics for these events so that they
can be surfaced via the Status API.

Fixes: #5637

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-03-30 09:08:53 -07:00
Stephan Renatus c6a341baa5 plugins/logs: don't convert EventV1 to ast.Value twice (#5761)
The existing benchmarks on the masking can't be compared with before/after:
it's unfair, we're no longer converting the event to ast.Value inside that
method.

But in the overall query processing, this change should be beneficial: we
avoid converting every event _twice_.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-03-17 10:31:43 +01:00
Ashutosh Narkar c4efb263ea plugins: Surface decision log errors via status API
Currently errors encountered during decision log uploads
are logged. This change now includes these errors as
part of status updates  which can be useful for the control plane
to determine if OPA is having any issues while processing, uploading logs etc.

Fixes: #5637

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-03-08 00:12:42 -08:00
Charlie Egan 8bb23ba156 [rego] Check store modules before skipping parsing (#5520)
* [rego] Check store modules before skipping parsing

Fixes https://github.com/open-policy-agent/opa/issues/5511

This change will cause the operation to be timed if the store
modules have already all been compiled and there are no
rawModules. This might be undesirable.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-01-05 10:47:48 +00:00
Humberto Corrêa da Silva f1761ac77e server+runtime+logs: Add the req_id attribute on the decision logs (#5196)
Today it is not possible to correlate the decision log with
other types of logs (server, print, etc.) when the server log
level is >= INFO. The log correlation could be helpful in
troubleshooting.

A solution is to add a common attribute in all logs to make
the log correlation possible, so adding the req_id attribute
on decision logs, when server log level is >= INFO, will make it
possible.

Fixes: #5006

* Add documentation about decision log req_id attribute

The documentation purpose is to explain the relation with
others logs, how it could be used, and when it is included
on decision logs.

Signed-off-by: Humberto Corrêa da Silva <humbertoc_silva@hotmail.com>
2022-10-14 13:12:15 +02:00
Marius Larsen 49c0051f24 plugins/logs: allow rule-based dropping of decision log entries (#5221)
Fixes: #3945

Signed-off-by: Marius Larsen <larsen.b.marius@gmail.com>
Co-authored-by: Lukas Menzel <lmenzel@united-internet.de>
Co-authored-by: Maren-Sofie Weien Stubø <msws@live.no>
2022-10-12 21:01:39 +02:00
Philip Conrad ac20ef2bf5 server+sdk+plugins: Integrate NDBCache into decision logging. (#5147)
This commit integrates the non-deterministic builtins caching system
into decision logging, both in the server and sdk packages. Some
reworking of the NDBCache's serialization format were required to
accommodate this. The feature is disabled by default, and must be
opted into by user configuration.

The feature can be enabled via a top-level config key:

    nd_builtin_cache=true

The NDBCache is exposed to the masking system under the
`/nd_builtin_cache` path, which allows masking or dropping sensitive
values from decision logs selectively.

Note: If a decision log event exceeds the `upload_size_limit_bytes`
value for the OPA instance, OPA will reattempt uploading it, after
dropping the NDBCache from the event. This behavior will trigger a log
error, and will increment the `decision_logs_nd_builtin_cache_dropped`
metrics counter.

Fixes: #1514

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
2022-10-06 16:27:54 -04:00
Stephan Renatus 137d7b6f72 storage/inmem: Allow disabling util.Roundtrip on Write (#5015)
Add option to inmem.store which allows disabling the round-tripping
through JSON when adding data to the store.

This option is intended for callers who can guarantee the objects they
pass to Write are JSON objects, and have properly ensured the object
will be only be accessed by store once added.

Fixes #4708.

This is continuance of https://github.com/open-policy-agent/opa/pull/4709,
adding these bits:

* storage/inmem: backwards-compat nitpicks, test adaptations

  I might have overshot here, but adding variable-length function parameters
  is not a backwards-compatible move. Concretely, if you had been using code like

      var x func() storage.Store = inmem.New

  going from New() to New(...Opts) would break it.

* storage/inmem: use it where possible without roundtrip

* storage/inmem: deal with nil map

  It looks like this is something the roundtrip had guarded us from.
  Now, we'll explicitly check this.

  This came up when running the bundle tests with roundtripping disabled.

* loader: add StoreWithOpts convenience method

Co-authored-by: Will Beason <willbeason@google.com>
Co-authored-by: Philip Conrad <conradp@chariot-chaser.net>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2022-08-18 08:38:21 +02:00
Anders Eknert d613b87e99 Fix error when initializing empty logging plugin (#4302)
Move the check for "emptiness" before validation and
injection of defaults, as there isn't a whole lot we
can do with a logging plugin that doesn't actually
log anything. Rather than error though, just return
nil to skip initialization of the plugin.

Fixes #4291

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-29 09:25:08 +01:00
Anders Eknert 9887cd2348 test: fix "too many open files" issue on Mac OS (#4287)
`make test` was crashing on Mac OS due to "too many open files",
which could be traced to two different issues.

The first one was the disk based storage being opened but not closed
in some cases. This change takes the number of open file pointers
from >300 to ~30 after the disk based tests have run.

The second issue was a fixture HTTP server allowing keep-alive
connections, and since each test would call the server on a
random port, no connection reuse was possible. Since the test
ran over 400 iterations, and the max open file handles on Mac
OS by default is 256, things broke.

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-27 07:35:34 +01:00
Anders Eknert 9cc0d2cfe9 Make print() work in decision masking policy
Signed-off-by: Anders Eknert <anders@eknert.com>
2021-12-01 10:39:08 +01:00
Stephan Renatus 2b7df1c402 plugins/logs: allow for using service AND custom plugin (#4039)
Now any subset of service, plugin, console logger should be usable.

Fixes #4013.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-11-19 10:22:57 +01:00
Ashutosh Narkar 4a48b65d7b Add an adaptive limit for the upload chunk size
This commit adds a chunk adaptive limit that acts as a
measure for encoding as many decisions into each chunk as possible.
This change should help fill-up the chunks close to their allowed
limit and thereby help reduce netwrok and memory resources.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-11-03 09:54:59 -07:00
Ashutosh Narkar ea96db6de6 plugins: Fix default trigger mode in the non-discovery path
When individual plugins (except discovery) were configured, the
default trigger mode was set as periodic. So if the plugin specified
a different mode (eg. manual), the configuration check would incorrectly
fail on account of a mode mismatch. This commit fixes the issue by
updating the trigger mode check to not specify a default mode in
scenarios when only plugins (except discovery) are configured.

Fixes: #3797

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-09-23 09:10:17 -07:00
Torin Sandall 0b7a2c38af Add support for manual plugin triggers
This commit introduces the idea of manual triggers to trigger
plugins. Currently plugins such as discovery, bundle, decision log etc.
perform their functions in a timer-based loop. For example, the bundle
plugin periodically checks for new bundles by polling a remote server.

This change adds the ability to trigger a plugin thereby allowing callers
to control when a bundle download happens, when a decision log is
uploaded etc. The periodic mode is still the default for the plugins.

This feature allows callers to trigger individual plugins. Plugins perform
their functions and then report back to the caller when done.

Co-authored-by: Torin Sandall <torinsandall@gmail.com>
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-08-26 09:35:02 -07:00
Casey Buto 452bc8310c plugins: Add new Resource configuration for decision logs (#3657)
As described in #3618, when using a service with a specific path for receiving logs (like a SaaS SIEM) its often the case that the path to the endpoint is static and cannot be changed.
This change allows setting the entire path to be used when sending decision logs via the decision_logs.resource field, unlike the partition name configuration which appends the path as /log/<partition>. Partition name has been deprecated and its recommended to use resource instead but if partition name is set, it will take precendence over resource.

Fixes #3618

Signed-off-by: Casey Buto <cbuto22@gmail.com>
2021-07-21 20:40:26 +02:00
Will Beason 3be1d08b87 Change check-lint to use golangci-lint (#3465)
golint is deprecated. The author of the code no longer supports the
codebase. golangci-lint is faster than golint, and is in use by other
opa repositories (e.g. Gatekeeper).

This commit changes tools.go to reference golangci (so it ends up in
vendor) and modifies check-lint to use golangci instead.

Breaking API Changes:

- plugins/rest/rest.go: Fix typo "AllowInsureTLS" -> "AllowInsecureTLS"
- storage/errors.go: Removed unused IndexingNotSupportedErr

Signed-off-by: Will Beason <willbeason@google.com>
2021-05-19 07:52:02 +02:00
Stephan Renatus 1a4227b7dc nightly checks: fix races, bump logrus version (#3439)
* runtime_test: avoid race condition

This had been flagged by our nightly race deteector run. Now, we'll
wait for the server to have stopped before checking its log output.

* plugins: avoid races, bump github.com/sirupsen/logrus

To fix that other one, I've first tried updating logrus (there was a
mention of fixed races in the changelog), but to no avail. Setting up
the hook before any plugin would log from that test resolved the issue.

No harm in updating logrus, though, let's keep that: 1.6.0 -> 1.8.1

* plugins/bundle: fix race

Golang for-range loops need special care when using a reference to the
second variable (v in `for k, v := range m`). We had been copying the
value of m[k], which is a pointer to Status, we had not been -- as was
intended -- copying the values of the struct that the pointer had been
pointing to.

Tests needed to be adapted for this, the s4 update will NOT contain
any bundle-activation-related metrics, as no bundle was activated, and
its status is a fresh copy.

* workflow: add race detector to PR checks

When run from nightly, we use ubuntu-latest; whereas the other checks
in the pull-request workflow use ubuntu-18.04.

I don't think it matters at all for the race detector, since that one
runs only from another docker container, using the golang image.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-12 11:06:40 +02:00
Torin Sandall 3fcc875a55 logging: Move logging infrastructure into separate package
This commit moves the logging interface and implementations out of the
sdk package into the logging package.

This commit also updates the status and decision log plugins to use a
logger obtained from the plugin manager instead of going to the global
console logger in the plugins package. The latter change will be
important for SDK consumers. This change is backwards incompatible but
it's unlikely that anyone is relying on that export. The test for
console logger independence has also been moved into the plugins
package (from the status package.)

Fixes #3275

Co-authored-by: Torin Sandall <torinsandall@gmail.com>
Co-authored-by: Anders Eknert <anders@eknert.com>

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Signed-off-by: Anders Eknert <anders@eknert.com>
2021-05-10 11:34:14 -04:00
Grant Shively dd35d6ce8d plugins/status: add plugin support
Added support for plugins in status plugin, similar to the pattern
employed in the decision logs plugin. By setting `status.plugin`
in configuration, you can override how the status plugin sends status
updates.

Related to #3047

Signed-off-by: Grant Shively <gshively@godaddy.com>
2021-04-16 09:31:23 -04:00
Ashutosh Narkar 9cbe2e1433 plugins/logs: Add test to check upload size limit on reconfig
This change adds a test to check the upload limit is updated
when the log plugin is reconfigured.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-04-10 18:05:18 -07:00
Ashutosh Narkar 489c581433 plugins: Include log drop count in the status plugin's metrics
This change adds the count of the decision log events that
were dropped when the rate limit was exceeded to the status
plugin's metrics provider. These metrics are part of the periodic
status update and hence should allow control planes to monitor the
number of dropped log events.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-04-02 13:44:13 -07:00
Ashutosh Narkar 959de3dac1 plugins/log: Add rate limit control for encoding decision log events
This change allows users to configure the rate at which decision
logs can be written into the encoder. A token bucket based rate
limiter is used to decide if a log event should be written into
the encoder. The encoded events are then added to the
buffer. If the rate limit is exceeded the event is dropped.

This change provides added control to users over buufering log events
on top of the existing behavior of specifying a buffer size limit.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2021-03-29 14:04:51 -07:00
Stan Lagun 9063587794 logs: do not block Stop if there are no logs to publish
Addresses #3197

Signed-off-by: Stan Lagun <stan@styra.com>
2021-02-25 23:23:21 +01:00
Patrick East 3fb39b560e plugins/logs: Remove empty test case
Removing dead code..

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-11-11 09:54:03 -05:00
Patrick East 3449360596 plugins/logs: Refactor shutdown log flushing
This removes some time-related stuff from both the implementation and
the unit tests with the aim to make it less flakey.

For the implementation we will now rely only on the deadline set by
the original context. We don't mess with canceling it as the signal
that we've completed. We use a new more explicit done channel.

In the unit test we no longer check that it stopped immediately, it
will instead ensure that the plugin was forcefully stopped with logs
still in its buffer.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-11-11 09:54:03 -05:00
Patrick East eb6bbfc0c1 Revert "plugins/logs: Close channel in unit test"
This reverts commit ac06c3b73c.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-11-05 08:54:03 -05:00
Patrick East ac06c3b73c plugins/logs: Close channel in unit test
One of the unit tests created a new channel for the testServer and
was not closing it when done. This changes the test to close the
channel after stopping the plugin but before the server gets shut down

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-10-21 15:00:33 -07:00
Patrick East a23158e044 plugins/logs: Correct hang in unit test fixture
Periodically we would get hangs in unit tests because the testServer
http handler would be stuck trying to send an event through the
channel. If the unit test was completed nothing would be reading,
and the send would be blocked indefinitely... as it turns out, the
http test server cannot shutdown while handlers are still running,
so the unit tests hang indefinitely.

To prevent this from happening we will drain any pending events when
stopping the testServer.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-10-21 15:00:33 -07:00
Anders Eknert 3cd195c925 Flush buffered decision logs on graceful shutdown
..re-attempting until either the graceful shutdown period is over or all logs have been uploaded.

Fixes #780

Signed-off-by: Anders Eknert <anders.eknert@bisnode.com>
2020-10-14 14:11:34 -07:00
Anders Eknert 777b31dee3 Fix discarded logs on chunk upload failure
If the size of the decision logs buffered exceeeds that of `upload_size_limit_bytes`, the upload will be split into chunks. If one of the attempted uploads return with an error the chunk is stored in the "new" buffer and will be re-attempted at the next invocation of the `oneShot` method. However, once that is done the function returns, leaving any decisions left in the buffer to be discarded. This PR fixes that, preserving all failed chunk uploads to the buffer.

Signed-off-by: Anders Eknert <anders.eknert@bisnode.com>
2020-09-30 17:12:33 -07:00
Torin Sandall 7559ad0f51 build: Move VERSION into version/version.go
The decision logger unit tests had to be updated to always set the
version.Version value because they are sensitive to changes in the
payload sizes.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2020-09-11 13:26:11 -04:00
Patrick East 739777cfff plugins/logs: Add custom EventV1 -> AST helper
This pretty substantially improves performance by avoiding to do a
JSON round trip and then converting into AST types.

There are a couple of fields left that require the round trip, we can
iterate on this as needed to supply better options for the results
and metrics.

This custom ASTer leaves out the rule counts, which also helps to
improve the performance.

On my local machine the numbers look like:

```
name                              old time/op    new time/op    delta
MaskingNop-8                         129µs ± 1%     110µs ± 1%  -15.19%  (p=0.000 n=7+10)
MaskingRuleCountsNop/1Rules-8        138µs ± 1%     111µs ± 1%  -19.34%  (p=0.000 n=10+10)
MaskingRuleCountsNop/10Rules-8       180µs ± 1%     116µs ± 4%  -35.70%  (p=0.000 n=10+10)
MaskingRuleCountsNop/100Rules-8      614µs ± 1%     113µs ± 1%  -81.66%  (p=0.000 n=10+8)
MaskingRuleCountsNop/1000Rules-8    5.16ms ± 2%    0.11ms ± 1%  -97.79%  (p=0.000 n=10+10)
MaskingErase-8                       148µs ± 2%     129µs ± 0%  -12.65%  (p=0.000 n=10+10)

name                              old alloc/op   new alloc/op   delta
MaskingNop-8                        56.7kB ± 0%    48.0kB ± 0%  -15.43%  (p=0.000 n=10+10)
MaskingRuleCountsNop/1Rules-8       59.5kB ± 0%    48.0kB ± 0%  -19.41%  (p=0.000 n=10+10)
MaskingRuleCountsNop/10Rules-8      84.9kB ± 0%    48.0kB ± 0%  -43.47%  (p=0.000 n=10+10)
MaskingRuleCountsNop/100Rules-8      362kB ± 0%      48kB ± 0%  -86.73%  (p=0.000 n=9+10)
MaskingRuleCountsNop/1000Rules-8    3.26MB ± 1%    0.05MB ± 0%  -98.52%  (p=0.000 n=10+10)
MaskingErase-8                      65.7kB ± 0%    57.0kB ± 0%  -13.33%  (p=0.000 n=10+10)

name                              old allocs/op  new allocs/op  delta
MaskingNop-8                         1.23k ± 0%     1.12k ± 0%   -8.46%  (p=0.000 n=10+10)
MaskingRuleCountsNop/1Rules-8        1.31k ± 0%     1.12k ± 0%  -14.32%  (p=0.000 n=10+10)
MaskingRuleCountsNop/10Rules-8       1.98k ± 0%     1.12k ± 0%  -43.30%  (p=0.000 n=10+10)
MaskingRuleCountsNop/100Rules-8      8.74k ± 0%     1.12k ± 0%  -87.13%  (p=0.000 n=10+10)
MaskingRuleCountsNop/1000Rules-8     76.3k ± 0%      1.1k ± 0%  -98.52%  (p=0.000 n=10+10)
MaskingErase-8                       1.33k ± 0%     1.22k ± 0%   -7.84%  (p=0.000 n=10+10)
```

So the performance no longer scales with the number of rules hit, and
overall the base cost is almost 20% faster. This time directly impacts
round trip latency for OPA REST clients performing evaluations.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-15 12:01:12 -07:00
Patrick East f3a9657920 plugins/logs: Move benchmarks into separate file
Just refactoring, no code changes.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-15 12:01:12 -07:00
Domingo Kiser 95532908c1 logs: Add feature to mutate decision log data in addition to default erase masking feature.
This feature adds the ability to mutate decision logs in addition to the default behavior
of erasing object paths.  A new upsert command was added to a structured way to define
mask rules in a backwards compatible manner.

Fixes: #2379
Signed-off-by: Domingo Kiser <domingo.kiser@gmail.com>
2020-06-11 13:14:18 -04:00
Patrick East ff900144a7 plugins/logs: Add plugin status updates
The log plugin will report its status as "ok" at start time and "not
ready" at stop. It currently doesn't change status or report any
errors. This can potentially be extended in the future.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-02-07 09:49:41 -05:00
Patrick East 9d9367d0ce decision logger: Leave the path unchanged for decisions
The logger was swapping `.`'s with `/`'s but this isn't safe when a
valid path should be /foo/a.b.c/main. The server was already doing
the right thing by passing in the url path where applicable, or only
specifying a query instead of the path.

This might affect anyone using the decision logger golang API passing
in something in dot-notation and expecting it to come out with paths.
Anyone using the HTTP server should be unaffected.

Fixes: #2031
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-01-30 14:11:05 -08:00
Patrick East 346aa964e8 Add support for multiple bundles
This change brings in support for multiple bundles to be downloaded
and activated OPA.

This is enabled by using the new config option `bundles` to define
the bundles, and deprecates the older `bundle` option.

The new `bundles` keyword and structure is propagated through to the
decision logs, status API, provenance, stored manifests, etc. Check
out the doc changes for all the updated structures.

That being said any existing configuration using `bundle` will *not*
see the new structure, everything is intended to be backwards
compatible (almost to a fault).

Fixes: #721

Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-31 03:43:38 -04:00
Torin Sandall d1d4df9798 server: Pass transaction in decision log event
These changes update the server to pass the server's open transaction
to the decision logger. This prevents the same goroutine from
recursively opening a new transcation when the log masking decision is
evaluated.

Alternatively we could update the server to close it's transaction
before logging the decision however this could lead to the log masking
decision being generated from a different policy revision. Another
alternative would be extend the storage layer to support recursive
transactions however this would be quite a bit more work.

We should investigate whether we can cheaply detect recursive
transactions in the store to avoid potential deadlocks in the future.

Also, delete opa binary that was accidentally committed to the repo.

Fixes #1543

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-03 15:10:59 -04:00
Patrick East a1abbbf4c9 logs: console decision logging option
Add option to log decision logs locally. They'll get logged via
Logrus at info level.

To enable configure OPA with something like:

```
decision_logs:
    console: true
```

This will work alongside remote services and plugins. It will also
log the masked events in the case a masking policy is set.

Fixes: #1334
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-06-13 13:27:51 -07:00
Torin Sandall c0cc24676d logs: Update decision logger to support masking
These changes enhance the in-built decision logger to support masking
of input and result fields for cases where sensitive information is
passed to OPA (or generated by the policy.)

Also, fix rego package to avoid panic-ing on programmatically created
queriest that lack Location information.

Fixes #779

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-06-04 16:14:46 -07:00
Torin Sandall 510c5ce77e decision_logs: Update interface to return error
Previously, the decision logger interface did not allow plugin
implementations to return an error. In some cases, implementations may
prefer to make OPA fail-closed if the event cannot be emitted.

This is a backwards incompatible change to the custom decision logger
API that was added in v0.10.3 and it deprecates the old diagnostic
interface as well.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-02-22 20:47:00 -08:00
Andy Curtis 778594ec79 config: add version to labels
Adds OPA version to the config labels, so that the version
appears in status updates. Previously, decision logs had a
top-level version field. This removes that field because
version will be contained in the labels instead.

Signed-off-by: Andy Curtis <arcurtis@gmail.com>
2019-02-08 15:55:27 -08:00
Torin Sandall 1db3023d45 Update decision log events to model paths and queries
Previously paths and queries were modelled with the same
attribute. This was going to cause headaches down the road for
decision log consumers that need to be able to deal with both kinds of
policy invocations.

As part of these changes, the decision logging test in the server has
been refactored to make it a bit more maintainable.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall 4428a9bd31 Update server and decision logger to represent input properly
Previously the input attribute was no represented as *interface{}
which makes it impossible to differentiate between null and undefined
input. This commit changes that. Eventually we should just get rid of
server.Info in favour of the decision log event structure.

This change requires a release note.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall 2f5a0fe0a4 Update decision log event to include error
The error field from the server event was not being copied into the
decision log event. Also, we didn't have test cases to verify that the
error was being set correctly in the first place.

In the future, we should remove the duplication of the server event
and the decision log event (preferring the latter).

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
repenno d85a3e15ca Add query metrics to decision logs
Fixes #1033

Signed-off-by: repenno <rapenno@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall cffc3d996d Add support for custom backends in decision logger
These changes modify the decision logger to support custom
backends. The docs now include an example of how to implement a custom
backend that writes out to stdout.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-10 14:52:14 -08:00
repenno 1773cf64e8 Add OPA version to decision logs
Fixes #1089

=== RUN   TestPluginStartSameInput
--- PASS: TestPluginStartSameInput (0.02s)
=== RUN   TestPluginStartChangingInputValues
--- PASS: TestPluginStartChangingInputValues (0.01s)
=== RUN   TestPluginStartChangingInputKeysAndValues
--- PASS: TestPluginStartChangingInputKeysAndValues (0.01s)
=== RUN   TestPluginRequeue
--- PASS: TestPluginRequeue (0.00s)
=== RUN   TestPluginReconfigure
time="2019-01-09T09:34:03-08:00" level=info msg="Starting decision log uploader." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Log upload skipped." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Stopping decision log uploader." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Decision log uploader configuration changed." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Log upload skipped." plugin=decision_logs
--- PASS: TestPluginReconfigure (0.00s)
PASS

Signed-off-by: repenno <rapenno@gmail.com>
2019-01-09 19:09:19 -08:00
Torin Sandall 2d425494aa Refactor discovery implementation
These changes refactor the discovery implementation a bit to improve
test coverage and remove duplication of common logic shared with the
bundle plugin.

Specifically, the downloading logic has been moved into a separate
package that is shared by bundle and discovery. Second, test coverage in
the discovery implementation is increased from ~15% to ~85%.

These changes also include a few functional improvements:

- The default decision paths can be updated dynamically
- The decision logger can be enabled dynamically
- Discovery downloading errors are reported in status updates
- Discovery bundle is evaluated with all runtime params
- Custom plugins can be created dynamically
- Status updates include both discovery and bundle status

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-12-08 00:45:36 +01:00