Skip to content

Commit

Permalink
Merge pull request #10502 from owncloud/fix-gateway-nats-checks
Browse files Browse the repository at this point in the history
only check nats if it is used
  • Loading branch information
butonic authored Nov 7, 2024
2 parents 5610e09 + 4092599 commit eb8b013
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-gateway-nats-checks.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions ocis-pkg/registry/register.go
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion services/gateway/pkg/server/debug/server.go
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eb8b013

Please sign in to comment.