Skip to content

Commit

Permalink
Adding default poll interval
Browse files Browse the repository at this point in the history
  • Loading branch information
mvbrock committed Nov 7, 2024
1 parent 1b7719f commit f3ae8f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"context"
"crypto/x509"
"errors"
"github.com/go-ldap/ldap/v3"
"io"
"io/fs"
"log/slog"
Expand All @@ -43,7 +44,6 @@ import (
"time"
"unicode"

"github.com/go-ldap/ldap/v3"
"github.com/gravitational/trace"
log "github.com/sirupsen/logrus"
kyaml "k8s.io/apimachinery/pkg/util/yaml"
Expand Down Expand Up @@ -1751,7 +1751,9 @@ kubernetes matchers are present`)
AssumeRole: assumeRole,
})
}
tMatcher.PollInterval = types.Duration(fc.Discovery.AccessGraph.PollInterval)
if fc.Discovery.AccessGraph.PollInterval > 0 {
tMatcher.PollInterval = types.Duration(fc.Discovery.AccessGraph.PollInterval)
}
cfg.Discovery.AccessGraph = &tMatcher
}

Expand Down
5 changes: 5 additions & 0 deletions lib/srv/discovery/access_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const (
// batchSize is the maximum number of resources to send in a single
// request to the access graph service.
batchSize = 500
// defaultPollInterval is the default interval between polling for access graph resources
defaultPollInterval = 15 * time.Minute
)

// errNoAccessGraphFetchers is returned when there are no TAG fetchers.
Expand Down Expand Up @@ -368,6 +370,9 @@ func (s *Server) initializeAndWatchAccessGraph(ctx context.Context, reloadCh <-c
currentTAGResources := &aws_sync.Resources{}
s.Log.InfoContext(ctx, "Access graph service poll interval", "poll_interval", s.Config.Matchers.AccessGraph.PollInterval)
tickerInterval := time.Duration(s.Config.Matchers.AccessGraph.PollInterval)
if tickerInterval <= 0 {
tickerInterval = defaultPollInterval
}
ticker := time.NewTicker(tickerInterval)
defer ticker.Stop()
for {
Expand Down

0 comments on commit f3ae8f0

Please sign in to comment.