10 Commits

Author SHA1 Message Date
Charlie Egan 7bdfe03927 runtime: Remove goautomaxprocs and automemlimit (#8869)
The memory pressure in low resource containers this PR aimed to fix was
actually caused by #8817, which was fixed in #8829. The
automaxprocs/automemlimit dependencies are no longer needed as was
intended in #8696.

This reverts commit 88c01e659c and updates
docs to match the current behaviour.

---------

Signed-off-by: Charlie Egan <charlie_egan@apple.com>
2026-07-08 14:13:57 +00:00
Charlie Egan 88c01e659c runtime: Restore goautomaxprocs, add automemlimit (#8784)
This PR reverts the change in #8696 where automaxprocs was removed. This
meant the go language default of 2 procs vs 1 was used. In some memory
constrained deployments of OPA, this caused OOM issues where the server
used more memory than before with 2 processes running. This PR restores
the automaxprocs dependency and this behaviour.

This PR also follows other data-heavy CNCF projects in pairing this with
automemlimit to automate the setting of GOMEMLIMIT based on the cgroup
data too.

This makes no change for users manually setting these, but hopefully
will provide some sensible defaults that work well for most cases, and
better than the Go defaults in low resource deployments.

<details>
<summary>Other projects</summary>

*
https://github.com/prometheus/prometheus/blob/2ad3a871701531d1485f678acb7523cd0aa31789/go.mod#L11
*
https://github.com/istio/istio/blob/4985ae369245dcc91bc107a0c47ea41ded0c1a12/go.mod#L8
*
https://github.com/grafana/alloy/blob/e11d0f03e2b2e727161fb2169cade54698e17bd8/go.mod#L19
* https://github.com/thanos-io/thanos/blob/main/go.mod#L9
* https://github.com/kubernetes/kube-state-metrics/blob/main/go.mod#L6
* https://github.com/authzed/spicedb/blob/main/go.mod#L22

</details>

---------

Signed-off-by: Charlie Egan <charlie_egan@apple.com>
2026-06-15 13:54:43 +00:00
Stephan Renatus bc8e23a174 logging: keep forwarding from BufferedLogger after Flush() (#8544)
The BufferedLogger introduced for logger plugins is created at startup
and passed to the `*plugins.Manager`. Plugins (bundle, discovery,
status, logs) cache `manager.Logger()` in a field at construction time.
After `Manager.Start()`, `ResolveBufferedLogger` flushes the buffer and
swaps the `Manager'`s logger to a `StandardLogger` — but the plugins
still hold the old `BufferedLogger`. Since bundle loading is async, the
"Bundle loaded and activated successfully" message (and similar) gets
written to the already-flushed buffer where nobody reads it.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-04-22 07:42:51 +00:00
Stephan Renatus aa38bb5b57 logging: make WithContext() optional
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-03-30 10:20:13 +02:00
Stephan Renatus d0041c64d9 runtime+server: logger plugins (#8434)
This PR brings support for pluggable logging implementations via the logger plugin interface, which is based on Go's standard log/slog.Handler interface. This allows any slog.Handler implementation to be used as a logger plugin. Loggers can be referenced via the server.logger_plugin configuration option; and can also be used for decision logs. OPA includes a built-in file logger plugin (file_logger) that writes structured JSON logs with rotation support using lumberjack. Users can also implement and register custom logger plugins when building OPA.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-03-26 10:39:06 -05:00
Ville Vesilehto f77322b3fb build: bump Go version requirement to 1.24 (#7839)
Go 1.23 is no longer supported as per Go release policy.

Changes:

- Use Go v1.24.6 as the project SDK requirement
- Apply lint fixes for Go 1.24
- Fix "non-constant format string in call" issues as seen in CI.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-08-24 09:02:09 +02:00
Philip Conrad 614f3cdac0 server+logging: Add BatchDecisionID field to Decision Logs.
This commit adds a new field to Decision Log entries, allowing batches
of decisions to be correlated together later.

Signed-off-by: Philip Conrad <philip@chariot-chaser.net>
2025-07-23 20:23:25 +02:00
Anders Eknert 8ba08ac80c Apply modernize linter fixes (#7599)
Following up on #7566, and now applying the more exciting
modernizations. fmt.Appendf was new to me! But especially
the contains checks are so much better IMHO. I have reviewed
all changes myself and did a few manual changes where it
became obvious that things could be improved a little further.

(the modernize analyzer still has some issues running against
OPA, and I have manually worked around those for the time being)

Signed-off-by: Anders Eknert <anders@styra.com>
2025-05-20 23:12:13 +02:00
Anders Eknert e43ef0a979 Use any in place of interface{} (#7566)
Earlier this evening I tried to run the Go
[modernize](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize)
analyzer on OPA. That didn't go as planned:

- https://github.com/golang/go/issues/73661
- https://github.com/golang/go/issues/73663

While we wait for that to be fixed, I figured an old-fashioned
search-and-replace across the repo may work for at least the
`interface{}` to `any` conversion. That should help make it easier
to see the other fixes as applied by the modernize tool once it has
had those issues resolved.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-05-12 13:57:48 +02:00
Johan Fylling 7bb6dbe36b Preparing for v1 API
Moving (most) source to v1 root package to prepare for v0/v1 API separation.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:09:03 +01:00