Provisioning: discontinue use of service identity based background tasks when onlyApiServer is true (#112634)
* Skip informers if Provisioning disable controllers is enabled * Hydrate requester correctly for Grafana Live * revert to old code because eventualRestConfig provider issues --------- Co-authored-by: Charandas Batra <charandas.batra@grafana.com>
This commit is contained in:
co-authored by
Charandas Batra
parent
fbc81d2fd0
commit
c9daec7b6d
@@ -48,7 +48,7 @@ func (b *WatchRunner) GetHandlerForPath(_ string) (model.ChannelHandler, error)
|
||||
// Valid paths look like: {version}/{resource}[={name}]/{user.uid}
|
||||
// * v0alpha1/dashboards/u12345
|
||||
// * v0alpha1/dashboards=ABCD/u12345
|
||||
func (b *WatchRunner) OnSubscribe(ctx context.Context, u identity.Requester, e model.SubscribeEvent) (model.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
func (b *WatchRunner) OnSubscribe(_ context.Context, u identity.Requester, e model.SubscribeEvent) (model.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
// To make sure we do not share resources across users, in clude the UID in the path
|
||||
userID := u.GetIdentifier()
|
||||
if userID == "" {
|
||||
@@ -87,11 +87,14 @@ func (b *WatchRunner) OnSubscribe(ctx context.Context, u identity.Requester, e m
|
||||
fmt.Errorf("watching provisioned resources is OK allowed (for now)")
|
||||
}
|
||||
|
||||
requester := types.WithAuthInfo(context.Background(), u)
|
||||
cfg, err := b.configProvider.GetRestConfig(requester)
|
||||
// doesn't matter what GetRestConfig sees for context, matters for watch below
|
||||
cfg, err := b.configProvider.GetRestConfig(context.Background())
|
||||
if err != nil {
|
||||
return model.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, err
|
||||
}
|
||||
|
||||
// add user to both requester and authInfo context keys, older implementations are still using requester
|
||||
ctx := identity.WithRequester(types.WithAuthInfo(context.Background(), u), u)
|
||||
uclient, err := dynamic.NewForConfig(cfg)
|
||||
if err != nil {
|
||||
return model.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, err
|
||||
@@ -102,7 +105,7 @@ func (b *WatchRunner) OnSubscribe(ctx context.Context, u identity.Requester, e m
|
||||
if len(name) > 1 {
|
||||
opts.FieldSelector = "metadata.name=" + name
|
||||
}
|
||||
watch, err := client.Watch(requester, opts)
|
||||
watch, err := client.Watch(ctx, opts)
|
||||
if err != nil {
|
||||
return model.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user