mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #49688 from wojtek-t/skip_cacher_if_not_initialized
Automatic merge from submit-queue (batch tested with PRs 49581, 49652, 49681, 49688, 44655) Don't use cacher if uninitialized Ref #49684
This commit is contained in:
commit
0f6a64453c
@ -369,6 +369,12 @@ func (c *Cacher) Get(ctx context.Context, key string, resourceVersion string, ob
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if getRV == 0 && !c.ready.check() {
|
||||||
|
// If Cacher is not yet initialized and we don't require any specific
|
||||||
|
// minimal resource version, simply forward the request to storage.
|
||||||
|
return c.storage.Get(ctx, key, resourceVersion, objPtr, ignoreNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
// Do not create a trace - it's not for free and there are tons
|
// Do not create a trace - it's not for free and there are tons
|
||||||
// of Get requests. We can add it if it will be really needed.
|
// of Get requests. We can add it if it will be really needed.
|
||||||
c.ready.wait()
|
c.ready.wait()
|
||||||
@ -414,6 +420,12 @@ func (c *Cacher) GetToList(ctx context.Context, key string, resourceVersion stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if listRV == 0 && !c.ready.check() {
|
||||||
|
// If Cacher is not yet initialized and we don't require any specific
|
||||||
|
// minimal resource version, simply forward the request to storage.
|
||||||
|
return c.storage.GetToList(ctx, key, resourceVersion, pred, listObj)
|
||||||
|
}
|
||||||
|
|
||||||
trace := utiltrace.New(fmt.Sprintf("cacher %v: List", c.objectType.String()))
|
trace := utiltrace.New(fmt.Sprintf("cacher %v: List", c.objectType.String()))
|
||||||
defer trace.LogIfLong(500 * time.Millisecond)
|
defer trace.LogIfLong(500 * time.Millisecond)
|
||||||
|
|
||||||
@ -470,6 +482,12 @@ func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, p
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if listRV == 0 && !c.ready.check() {
|
||||||
|
// If Cacher is not yet initialized and we don't require any specific
|
||||||
|
// minimal resource version, simply forward the request to storage.
|
||||||
|
return c.storage.List(ctx, key, resourceVersion, pred, listObj)
|
||||||
|
}
|
||||||
|
|
||||||
trace := utiltrace.New(fmt.Sprintf("cacher %v: List", c.objectType.String()))
|
trace := utiltrace.New(fmt.Sprintf("cacher %v: List", c.objectType.String()))
|
||||||
defer trace.LogIfLong(500 * time.Millisecond)
|
defer trace.LogIfLong(500 * time.Millisecond)
|
||||||
|
|
||||||
@ -966,6 +984,14 @@ func (r *ready) wait() {
|
|||||||
r.c.L.Unlock()
|
r.c.L.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make check() function more sophisticated, in particular
|
||||||
|
// allow it to behave as "waitWithTimeout".
|
||||||
|
func (r *ready) check() bool {
|
||||||
|
r.c.L.Lock()
|
||||||
|
defer r.c.L.Unlock()
|
||||||
|
return r.ok
|
||||||
|
}
|
||||||
|
|
||||||
func (r *ready) set(ok bool) {
|
func (r *ready) set(ok bool) {
|
||||||
r.c.L.Lock()
|
r.c.L.Lock()
|
||||||
defer r.c.L.Unlock()
|
defer r.c.L.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user