Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions pkg/sync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,22 @@ func (p *ProgressCounts) LogResourcesProgress(ctx context.Context, resourceType
func (p *ProgressCounts) LogEntitlementsProgress(ctx context.Context, resourceType string) {
entitlementsProgress := p.EntitlementsProgress[resourceType]
resources := p.Resources[resourceType]

l := ctxzap.Extract(ctx)
if resources == 0 {
// if resuming sync, resource counts will be zero, so don't calculate percentage. just log every 10 seconds.
if time.Since(p.LastEntitlementLog[resourceType]) > maxLogFrequency {
Copy link
Contributor

@kans kans Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment here (and below maybe) for why resources are 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

l.Info("Syncing entitlements",
zap.String("resource_type_id", resourceType),
zap.Int("synced", entitlementsProgress),
)
p.LastEntitlementLog[resourceType] = time.Now()
}
return
}

percentComplete := (entitlementsProgress * 100) / resources

l := ctxzap.Extract(ctx)
switch {
case entitlementsProgress > resources:
l.Error("more entitlement resources than resources",
Expand Down Expand Up @@ -118,12 +128,22 @@ func (p *ProgressCounts) LogEntitlementsProgress(ctx context.Context, resourceTy
func (p *ProgressCounts) LogGrantsProgress(ctx context.Context, resourceType string) {
grantsProgress := p.GrantsProgress[resourceType]
resources := p.Resources[resourceType]

l := ctxzap.Extract(ctx)
if resources == 0 {
// if resuming sync, resource counts will be zero, so don't calculate percentage. just log every 10 seconds.
if time.Since(p.LastGrantLog[resourceType]) > maxLogFrequency {
l.Info("Syncing grants",
zap.String("resource_type_id", resourceType),
zap.Int("synced", grantsProgress),
)
p.LastGrantLog[resourceType] = time.Now()
}
return
}

percentComplete := (grantsProgress * 100) / resources

l := ctxzap.Extract(ctx)
switch {
case grantsProgress > resources:
l.Error("more grant resources than resources",
Expand Down Expand Up @@ -1132,8 +1152,8 @@ func (s *syncer) SyncGrantExpansion(ctx context.Context) error {
l.Warn(
"cycle detected in entitlement graph",
zap.Any("cycle", cycle),
zap.Any("initial graph", entitlementGraph),
)
l.Debug("initial graph", zap.Any("initial graph", entitlementGraph))
if dontFixCycles {
return fmt.Errorf("cycles detected in entitlement graph")
}
Expand Down
Loading