Skip to content

Commit d39f39d

Browse files
mvbrocktigrato
andcommitted
Invoking the Azure fetcher in the Discovery service (#50369)
* Protobuf and configuration for Access Graph Azure Discovery * Adding the Azure sync module functions along with new cloud client functionality * Fixing rebase after protobuf gen * Updating to use existing msgraph client * PR feedback * Using variadic options * Removing memberOf expansion * Expanding memberships by calling memberOf on each user * PR feedback * Rebase go.sum stuff * Go mod tidy * Fixing go.mod * Update lib/msgraph/paginated.go Co-authored-by: Tiago Silva <[email protected]> * PR feedback * Adding the Azure sync module functions along with new cloud client functionality * Protobuf and configuration for Access Graph Azure Discovery * Adding Azure sync functionality which can be called by the Azure fetcher * Protobuf update * Invoking membership expansion * Setting principals before expansion * Removing msgraphclient * Linting * PR feedback * PR feedback * Adding the Azure sync module functions along with new cloud client functionality * Updating to use existing msgraph client * PR feedback * Using variadic options * Removing memberOf expansion * Expanding memberships by calling memberOf on each user * PR feedback * Rebase go.sum stuff * PR feedback * Adding the Azure sync module functions along with new cloud client functionality * Protobuf and configuration for Access Graph Azure Discovery * Invoking the Azure fetcher in the Discovery service * Protobuf gen fix * Conformant package name * Removing msgraphclient (again?) * Rebase fixes * More cleanup * PR feedback --------- Co-authored-by: Tiago Silva <[email protected]>
1 parent f2f461d commit d39f39d

12 files changed

+462
-35
lines changed

lib/srv/discovery/access_graph.go lib/srv/discovery/access_graph_aws.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ const (
5050
batchSize = 500
5151
// defaultPollInterval is the default interval between polling for access graph resources
5252
defaultPollInterval = 15 * time.Minute
53+
// Configure health check service to monitor access graph service and
54+
// automatically reconnect if the connection is lost without
55+
// relying on new events from the auth server to trigger a reconnect.
56+
serviceConfig = `{
57+
"loadBalancingPolicy": "round_robin",
58+
"healthCheckConfig": {
59+
"serviceName": ""
60+
}
61+
}`
5362
)
5463

5564
// errNoAccessGraphFetchers is returned when there are no TAG fetchers.
@@ -145,15 +154,15 @@ func (s *Server) reconcileAccessGraph(ctx context.Context, currentTAGResources *
145154

146155
// getAllAWSSyncFetchers returns all AWS sync fetchers.
147156
func (s *Server) getAllAWSSyncFetchers() []aws_sync.AWSSync {
148-
allFetchers := make([]aws_sync.AWSSync, 0, len(s.dynamicTAGSyncFetchers))
157+
allFetchers := make([]aws_sync.AWSSync, 0, len(s.dynamicTAGAWSFetchers))
149158

150-
s.muDynamicTAGSyncFetchers.RLock()
151-
for _, fetcherSet := range s.dynamicTAGSyncFetchers {
159+
s.muDynamicTAGAWSFetchers.RLock()
160+
for _, fetcherSet := range s.dynamicTAGAWSFetchers {
152161
allFetchers = append(allFetchers, fetcherSet...)
153162
}
154-
s.muDynamicTAGSyncFetchers.RUnlock()
163+
s.muDynamicTAGAWSFetchers.RUnlock()
155164

156-
allFetchers = append(allFetchers, s.staticTAGSyncFetchers...)
165+
allFetchers = append(allFetchers, s.staticTAGAWSFetchers...)
157166
// TODO(tigrato): submit fetchers event
158167
return allFetchers
159168
}
@@ -257,15 +266,6 @@ func (s *Server) initializeAndWatchAccessGraph(ctx context.Context, reloadCh <-c
257266
const (
258267
// aws discovery semaphore lock.
259268
semaphoreName = "access_graph_aws_sync"
260-
// Configure health check service to monitor access graph service and
261-
// automatically reconnect if the connection is lost without
262-
// relying on new events from the auth server to trigger a reconnect.
263-
serviceConfig = `{
264-
"loadBalancingPolicy": "round_robin",
265-
"healthCheckConfig": {
266-
"serviceName": ""
267-
}
268-
}`
269269
)
270270

271271
clusterFeatures := s.Config.ClusterFeatures()
@@ -438,12 +438,12 @@ func grpcCredentials(config AccessGraphConfig, getCert func() (*tls.Certificate,
438438
return grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)), nil
439439
}
440440

441-
func (s *Server) initAccessGraphWatchers(ctx context.Context, cfg *Config) error {
442-
fetchers, err := s.accessGraphFetchersFromMatchers(ctx, cfg.Matchers, "" /* discoveryConfigName */)
441+
func (s *Server) initTAGAWSWatchers(ctx context.Context, cfg *Config) error {
442+
fetchers, err := s.accessGraphAWSFetchersFromMatchers(ctx, cfg.Matchers, "" /* discoveryConfigName */)
443443
if err != nil {
444444
s.Log.ErrorContext(ctx, "Error initializing access graph fetchers", "error", err)
445445
}
446-
s.staticTAGSyncFetchers = fetchers
446+
s.staticTAGAWSFetchers = fetchers
447447

448448
if cfg.AccessGraphConfig.Enabled {
449449
go func() {
@@ -482,8 +482,8 @@ func (s *Server) initAccessGraphWatchers(ctx context.Context, cfg *Config) error
482482
return nil
483483
}
484484

485-
// accessGraphFetchersFromMatchers converts Matchers into a set of AWS Sync Fetchers.
486-
func (s *Server) accessGraphFetchersFromMatchers(ctx context.Context, matchers Matchers, discoveryConfigName string) ([]aws_sync.AWSSync, error) {
485+
// accessGraphAWSFetchersFromMatchers converts Matchers into a set of AWS Sync Fetchers.
486+
func (s *Server) accessGraphAWSFetchersFromMatchers(ctx context.Context, matchers Matchers, discoveryConfigName string) ([]aws_sync.AWSSync, error) {
487487
var fetchers []aws_sync.AWSSync
488488
var errs []error
489489
if matchers.AccessGraph == nil {

0 commit comments

Comments
 (0)