From 409259949eed1aaeef6728fb28d0bcab24c8c91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 7 Nov 2024 12:22:06 +0100 Subject: [PATCH] only check nats if it is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-gateway-nats-checks.md | 5 +++++ ocis-pkg/registry/register.go | 4 ++++ services/gateway/pkg/server/debug/server.go | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-gateway-nats-checks.md diff --git a/changelog/unreleased/fix-gateway-nats-checks.md b/changelog/unreleased/fix-gateway-nats-checks.md new file mode 100644 index 000000000..a76be45e2 --- /dev/null +++ b/changelog/unreleased/fix-gateway-nats-checks.md @@ -0,0 +1,5 @@ +Bugfix: fix gateway nats checks + +We now only check if nats is available when the gateway actually uses it. Furthermore, we added a backoff for checking the readys endpoint. + +https://github.com/owncloud/ocis/pull/10502 diff --git a/ocis-pkg/registry/register.go b/ocis-pkg/registry/register.go index 926fd351a..5c39d299b 100644 --- a/ocis-pkg/registry/register.go +++ b/ocis-pkg/registry/register.go @@ -27,11 +27,15 @@ func RegisterService(ctx context.Context, logger log.Logger, service *mRegistry. go func() { // check if the service is ready + delay := 500 * time.Millisecond for { resp, err := http.DefaultClient.Get("http://" + debugAddr + "/readyz") if err == nil && resp.StatusCode == http.StatusOK { + resp.Body.Close() break } + time.Sleep(delay) + delay *= 2 } for { select { diff --git a/services/gateway/pkg/server/debug/server.go b/services/gateway/pkg/server/debug/server.go index cc851382d..15985427f 100644 --- a/services/gateway/pkg/server/debug/server.go +++ b/services/gateway/pkg/server/debug/server.go @@ -17,7 +17,7 @@ func Server(opts ...Option) (*http.Server, error) { readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration(). WithLogger(options.Logger). WithCheck("nats reachability", func(ctx context.Context) error { - if len(options.Config.Cache.ProviderCacheNodes) > 0 { + if options.Config.Cache.ProviderCacheStore == "nats-js-kv" && len(options.Config.Cache.ProviderCacheNodes) > 0 { return checks.NewNatsCheck(options.Config.Cache.ProviderCacheNodes[0])(ctx) } return nil