Fix many instances of contexts and loggers not being propagated (#5340)

This also replaces instances where we manually write "return ctx.Err()"
with "return context.Cause(ctx)" which is functionally identical, but
will also correctly propagate cause errors if present.
This commit is contained in:
Joe Kralicky 2024-10-25 14:50:56 -04:00 committed by GitHub
parent e1880ba20f
commit fe31799eb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 297 additions and 221 deletions

View file

@ -124,13 +124,13 @@ func (mgr *Manager) refreshLoop(ctx context.Context, update <-chan updateRecords
// wait for initial sync
select {
case <-ctx.Done():
return ctx.Err()
return context.Cause(ctx)
case <-clear:
mgr.reset()
}
select {
case <-ctx.Done():
return ctx.Err()
return context.Cause(ctx)
case msg := <-update:
mgr.onUpdateRecords(ctx, msg)
}
@ -150,7 +150,7 @@ func (mgr *Manager) refreshLoop(ctx context.Context, update <-chan updateRecords
for {
select {
case <-ctx.Done():
return ctx.Err()
return context.Cause(ctx)
case <-clear:
mgr.reset()
case msg := <-update:

View file

@ -17,7 +17,7 @@ type dataBrokerSyncer struct {
}
func newDataBrokerSyncer(
_ context.Context,
ctx context.Context,
cfg *atomicutil.Value[*config],
update chan<- updateRecordsMessage,
clear chan<- struct{},
@ -28,7 +28,7 @@ func newDataBrokerSyncer(
update: update,
clear: clear,
}
syncer.syncer = databroker.NewSyncer("identity_manager", syncer)
syncer.syncer = databroker.NewSyncer(ctx, "identity_manager", syncer)
return syncer
}

View file

@ -16,7 +16,7 @@ type sessionSyncerHandler struct {
}
func newSessionSyncer(ctx context.Context, mgr *Manager) *databroker.Syncer {
return databroker.NewSyncer("identity_manager/sessions", sessionSyncerHandler{baseCtx: ctx, mgr: mgr},
return databroker.NewSyncer(ctx, "identity_manager/sessions", sessionSyncerHandler{baseCtx: ctx, mgr: mgr},
databroker.WithTypeURL(grpcutil.GetTypeURL(new(session.Session))))
}
@ -50,7 +50,7 @@ type userSyncerHandler struct {
}
func newUserSyncer(ctx context.Context, mgr *Manager) *databroker.Syncer {
return databroker.NewSyncer("identity_manager/users", userSyncerHandler{baseCtx: ctx, mgr: mgr},
return databroker.NewSyncer(ctx, "identity_manager/users", userSyncerHandler{baseCtx: ctx, mgr: mgr},
databroker.WithTypeURL(grpcutil.GetTypeURL(new(user.User))))
}