diff --git a/internal/dao/registry.go b/internal/dao/registry.go index cb43946544eb360c1163c3f313e98753dfda01f1..390d50e65904059b58c8478670b03b85e84b2c8b 100644 --- a/internal/dao/registry.go +++ b/internal/dao/registry.go @@ -43,7 +43,7 @@ func AccessorFor(f Factory, gvr client.GVR) (Accessor, error) { r, ok := m[gvr] if !ok { r = &Generic{} - log.Warn().Msgf("No DAO registry entry for %q. Using factory!", gvr) + log.Debug().Msgf("No DAO registry entry for %q. Using factory!", gvr) } r.Init(f, gvr) diff --git a/internal/view/helpers.go b/internal/view/helpers.go index cee13f8340e31edfb8caba2e528069e5ecbf0e64..8e917664cf0faffb585e970dc851398f49ec3d38 100644 --- a/internal/view/helpers.go +++ b/internal/view/helpers.go @@ -101,7 +101,7 @@ func showPods(app *App, path, labelSel, fieldSel string) { app.switchNS("") v := NewPod(client.NewGVR("v1/pods")) - v.SetContextFn(podCtx(path, labelSel, fieldSel)) + v.SetContextFn(podCtx(app, path, labelSel, fieldSel)) v.GetTable().SetColorerFn(render.Pod{}.ColorerFunc()) ns, _ := client.Namespaced(path) @@ -113,10 +113,20 @@ func showPods(app *App, path, labelSel, fieldSel string) { } } -func podCtx(path, labelSel, fieldSel string) ContextFunc { +func podCtx(app *App, path, labelSel, fieldSel string) ContextFunc { return func(ctx context.Context) context.Context { ctx = context.WithValue(ctx, internal.KeyPath, path) ctx = context.WithValue(ctx, internal.KeyLabels, labelSel) + + ns, _ := client.Namespaced(path) + log.Debug().Msgf("POD METRICS in NS %q", ns) + mx := client.NewMetricsServer(app.factory.Client()) + nmx, err := mx.FetchPodsMetrics(ns) + if err != nil { + log.Warn().Err(err).Msgf("No pods metrics") + } + ctx = context.WithValue(ctx, internal.KeyMetrics, nmx) + return context.WithValue(ctx, internal.KeyFields, fieldSel) } } diff --git a/internal/view/pod.go b/internal/view/pod.go index c55c1ac90fc146a0bdb676b34f1919dddb888f19..fbc83a2a550a63a10ebe36dd37a7571c62f8cef2 100644 --- a/internal/view/pod.go +++ b/internal/view/pod.go @@ -32,7 +32,7 @@ func NewPod(gvr client.GVR) ResourceViewer { p.SetBindKeysFn(p.bindKeys) p.GetTable().SetEnterFn(p.showContainers) p.GetTable().SetColorerFn(render.Pod{}.ColorerFunc()) - p.SetContextFn(p.podMXContext) + p.SetContextFn(p.podContext) return &p } @@ -53,31 +53,31 @@ func (p *Pod) bindKeys(aa ui.KeyActions) { }) } -func (p *Pod) podMXContext(ctx context.Context) context.Context { +func (p *Pod) showContainers(app *App, ns, gvr, path string) { + log.Debug().Msgf("SHOW CONTAINERS %q -- %q -- %q", gvr, ns, path) + co := NewContainer(client.NewGVR("containers")) + co.SetContextFn(p.coContext) + if err := app.inject(co); err != nil { + app.Flash().Err(err) + } +} + +func (p *Pod) podContext(ctx context.Context) context.Context { ns, ok := ctx.Value(internal.KeyNamespace).(string) if !ok { log.Error().Err(fmt.Errorf("Expecting context namespace")) } + log.Debug().Msgf("POD METRICS in NS %q", ns) mx := client.NewMetricsServer(p.App().factory.Client()) nmx, err := mx.FetchPodsMetrics(ns) if err != nil { log.Warn().Err(err).Msgf("No pods metrics") } - return context.WithValue(ctx, internal.KeyMetrics, nmx) } -func (p *Pod) showContainers(app *App, ns, gvr, path string) { - log.Debug().Msgf("SHOW CONTAINERS %q -- %q -- %q", gvr, ns, path) - co := NewContainer(client.NewGVR("containers")) - co.SetContextFn(p.podContext) - if err := app.inject(co); err != nil { - app.Flash().Err(err) - } -} - -func (p *Pod) podContext(ctx context.Context) context.Context { +func (p *Pod) coContext(ctx context.Context) context.Context { return context.WithValue(ctx, internal.KeyPath, p.GetTable().GetSelectedItem()) } diff --git a/internal/watch/factory.go b/internal/watch/factory.go index c8b9d8ac2cd8b74c7a0847e98787e969d0e39244..ba51737f3fe67558cee2b31d77168899b8ed450f 100644 --- a/internal/watch/factory.go +++ b/internal/watch/factory.go @@ -110,10 +110,11 @@ func (f *Factory) waitForCacheSync(ns string) { c := make(chan struct{}) go func(c chan struct{}) { <-time.After(dur) - log.Warn().Msgf("Wait for sync timed out!") + log.Debug().Msgf("Wait for sync timed out!") close(c) }(c) fac.WaitForCacheSync(c) + log.Debug().Msgf("Sync completed for ns %q", ns) } }