Skip to content

Commit

Permalink
NET-6204- Repeating error log in consul-connect-injector (#3128)
Browse files Browse the repository at this point in the history
* better handle gateway timeout errors

* strings not refs

* changelog

* Add missing import, fix import blocking

---------

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
  • Loading branch information
sophie-gairo and nathancoleman authored Oct 24, 2023
1 parent 901f55c commit 0d85bbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/3128.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
control-plane: only alert on valid errors, not timeouts in gateway
```
14 changes: 11 additions & 3 deletions control-plane/api-gateway/cache/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ package cache
import (
"context"
"fmt"
"strings"
"sync"

"github.com/cenkalti/backoff"
"github.com/go-logr/logr"
"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/consul"
"github.com/hashicorp/consul/api"
"k8s.io/apimachinery/pkg/types"

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/consul"
)

type GatewayCache struct {
Expand Down Expand Up @@ -125,7 +127,13 @@ func (r *GatewayCache) subscribeToGateway(ctx context.Context, ref api.ResourceR

return nil
}, backoff.WithContext(retryBackoff, ctx)); err != nil {
r.logger.Error(err, fmt.Sprintf("unable to fetch config entry for gateway: %s/%s", ref.Namespace, ref.Name))
// if we timeout we don't care about the error message because it's expected to happen on long polls
// any other error we want to alert on
if !strings.Contains(strings.ToLower(err.Error()), "timeout") &&
!strings.Contains(strings.ToLower(err.Error()), "no such host") &&
!strings.Contains(strings.ToLower(err.Error()), "connection refused") {
r.logger.Error(err, fmt.Sprintf("unable to fetch config entry for gateway: %s/%s", ref.Namespace, ref.Name))
}
continue
}

Expand Down

0 comments on commit 0d85bbc

Please sign in to comment.