Skip to content

Commit

Permalink
Add godocs and correct a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mvbrock committed Jan 24, 2025
1 parent 9400025 commit dff9837
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions lib/srv/discovery/access_graph_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (s *Server) reconcileAccessGraph(ctx context.Context, currentTAGResources *
}

for _, fetcher := range allFetchers {
s.syncStatus.syncStarted(fetcher, s.clock.Now())
s.tagSyncStatus.syncStarted(fetcher, s.clock.Now())
}
for _, discoveryConfigName := range s.syncStatus.discoveryConfigs() {
for _, discoveryConfigName := range s.tagSyncStatus.discoveryConfigs() {
s.updateDiscoveryConfigStatus(discoveryConfigName)
}

Expand Down Expand Up @@ -129,9 +129,9 @@ func (s *Server) reconcileAccessGraph(ctx context.Context, currentTAGResources *
pushErr := push(stream, upsert, toDel)

for _, fetcher := range allFetchers {
s.syncStatus.syncFinished(fetcher, pushErr, s.clock.Now())
s.tagSyncStatus.syncFinished(fetcher, pushErr, s.clock.Now())
}
for _, discoveryConfigName := range s.syncStatus.discoveryConfigs() {
for _, discoveryConfigName := range s.tagSyncStatus.discoveryConfigs() {
s.updateDiscoveryConfigStatus(discoveryConfigName)
}

Expand Down
8 changes: 4 additions & 4 deletions lib/srv/discovery/access_graph_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func (s *Server) reconcileAccessGraphAzure(
}

for _, fetcher := range allFetchers {
s.syncStatus.syncStarted(fetcher, s.clock.Now())
s.tagSyncStatus.syncStarted(fetcher, s.clock.Now())
}
for _, discoveryConfigName := range s.syncStatus.discoveryConfigs() {
for _, discoveryConfigName := range s.tagSyncStatus.discoveryConfigs() {
s.updateDiscoveryConfigStatus(discoveryConfigName)
}

Expand Down Expand Up @@ -117,9 +117,9 @@ func (s *Server) reconcileAccessGraphAzure(
pushErr := azurePush(stream, upsert, toDel)

for _, fetcher := range allFetchers {
s.syncStatus.syncFinished(fetcher, pushErr, s.clock.Now())
s.tagSyncStatus.syncFinished(fetcher, pushErr, s.clock.Now())
}
for _, discoveryConfigName := range s.syncStatus.discoveryConfigs() {
for _, discoveryConfigName := range s.tagSyncStatus.discoveryConfigs() {
s.updateDiscoveryConfigStatus(discoveryConfigName)
}

Expand Down
8 changes: 4 additions & 4 deletions lib/srv/discovery/access_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,20 @@ func TestServer_updateDiscoveryConfigStatus(t *testing.T) {
AccessPoint: accessPoint,
clock: clock,
},
syncStatus: newTagSyncStatus(),
tagSyncStatus: newTagSyncStatus(),
}

if tt.args.preRun {
for _, fetcher := range tt.args.fetchers {
s.syncStatus.syncStarted(fetcher, s.clock.Now())
s.tagSyncStatus.syncStarted(fetcher, s.clock.Now())
}
} else {
for _, fetcher := range tt.args.fetchers {
s.syncStatus.syncFinished(fetcher, tt.args.pushErr, s.clock.Now())
s.tagSyncStatus.syncFinished(fetcher, tt.args.pushErr, s.clock.Now())
}
}

for _, discoveryConfigName := range s.syncStatus.discoveryConfigs() {
for _, discoveryConfigName := range s.tagSyncStatus.discoveryConfigs() {
s.updateDiscoveryConfigStatus(discoveryConfigName)
}

Expand Down
4 changes: 2 additions & 2 deletions lib/srv/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ type Server struct {

dynamicDiscoveryConfig map[string]*discoveryconfig.DiscoveryConfig

syncStatus *tagSyncStatus
tagSyncStatus *tagSyncStatus
awsEC2ResourcesStatus awsResourcesStatus
awsRDSResourcesStatus awsResourcesStatus
awsEKSResourcesStatus awsResourcesStatus
Expand Down Expand Up @@ -480,7 +480,7 @@ func New(ctx context.Context, cfg *Config) (*Server, error) {
dynamicTAGAWSFetchers: make(map[string][]*aws_sync.Fetcher),
dynamicTAGAzureFetchers: make(map[string][]*azure_sync.Fetcher),
dynamicDiscoveryConfig: make(map[string]*discoveryconfig.DiscoveryConfig),
syncStatus: newTagSyncStatus(),
tagSyncStatus: newTagSyncStatus(),
awsEC2ResourcesStatus: newAWSResourceStatusCollector(types.AWSMatcherEC2),
awsRDSResourcesStatus: newAWSResourceStatusCollector(types.AWSMatcherRDS),
awsEKSResourcesStatus: newAWSResourceStatusCollector(types.AWSMatcherEKS),
Expand Down
8 changes: 4 additions & 4 deletions lib/srv/discovery/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/gravitational/teleport/lib/srv/server"
)

// FetcherStatus defines an interface for fetchers to report status
type FetcherStatus interface {
// Status reports the last known status of the fetcher.
Status() (uint64, error)
Expand Down Expand Up @@ -67,10 +68,8 @@ func (s *Server) updateDiscoveryConfigStatus(discoveryConfigNames ...string) {
IntegrationDiscoveredResources: make(map[string]*discoveryconfigv1.IntegrationDiscoveredSummary),
}

// Merge AWS Sync (TAG) status
discoveryConfigStatus = s.syncStatus.mergeIntoGlobalStatus(discoveryConfigName, discoveryConfigStatus)

// Merge Azure Sync (TAG) status
// Merge AWS or Azure Sync (TAG) status
discoveryConfigStatus = s.tagSyncStatus.mergeIntoGlobalStatus(discoveryConfigName, discoveryConfigStatus)

// Merge AWS EC2 Instances (auto discovery) status
discoveryConfigStatus = s.awsEC2ResourcesStatus.mergeIntoGlobalStatus(discoveryConfigName, discoveryConfigStatus)
Expand Down Expand Up @@ -102,6 +101,7 @@ type tagSyncStatus struct {
syncResults map[string][]tagSyncResult
}

// newTagSyncStatus creates a new sync status object for storing results from the last fetch
func newTagSyncStatus() *tagSyncStatus {
return &tagSyncStatus{
syncResults: make(map[string][]tagSyncResult),
Expand Down

0 comments on commit dff9837

Please sign in to comment.