Skip to content

Commit 5ee53c6

Browse files
authored
[3.1.10 backport] CBG-4127 use a non cancellable context for OIDC metadata (#7061)
1 parent 3cbb24a commit 5ee53c6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

auth/oidc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ func (op *OIDCProvider) startDiscoverySync(ctx context.Context, discoveryURL str
692692
return err
693693
}
694694
go func() {
695+
ctx := base.NewNonCancelCtxForDatabase(ctx).Ctx
695696
for {
696697
select {
697698
case <-time.After(duration):

base/util.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ func NewNonCancelCtx() NonCancellableContext {
6363
return ctxStruct
6464
}
6565

66-
// NewNonCancelCtx creates a new background context struct for operations that require a fresh context, with database logging context added
67-
func NewNonCancelCtxForDatabase(dbName string, dbConsoleLogConfig *DbConsoleLogConfig) NonCancellableContext {
68-
dbLogContext := DatabaseLogCtx(context.Background(), dbName, dbConsoleLogConfig)
69-
ctxStruct := NonCancellableContext{
66+
// NewNonCancelCtxForDatabase creates a new background context struct for operations that require a fresh context, with database logging context added
67+
func NewNonCancelCtxForDatabase(parentCtx context.Context) NonCancellableContext {
68+
ctx := getLogCtx(parentCtx)
69+
70+
dbLogContext := DatabaseLogCtx(context.Background(), ctx.Database, ctx.DbConsoleLogConfig)
71+
72+
return NonCancellableContext{
7073
Ctx: dbLogContext,
7174
}
72-
return ctxStruct
7375
}
7476

7577
// RedactBasicAuthURLUserAndPassword returns the given string, with a redacted HTTP basic auth component.

rest/server_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config
948948
// before going online
949949
base.InfofCtx(ctx, base.KeyAll, "Waiting for database init to complete asynchonously...")
950950
atomic.StoreUint32(&dbcontext.State, db.DBStarting)
951-
nonCancelCtx := base.NewNonCancelCtxForDatabase(dbName, dbcontext.Options.LoggingConfig.Console)
951+
nonCancelCtx := base.NewNonCancelCtxForDatabase(ctx)
952952
go sc.asyncDatabaseOnline(nonCancelCtx, dbcontext, dbInitDoneChan, config.Version)
953953
return dbcontext, nil
954954
}

0 commit comments

Comments
 (0)