From 026adfbfbf230033c4c68511972e67991c51fa47 Mon Sep 17 00:00:00 2001 From: Fernand Galiana Date: Thu, 8 Jul 2021 07:11:35 -0600 Subject: [PATCH] K9s 1186: prev logs (#1190) * fix cron triggers * fix cron triggers again... * fix #1186 * update rel notes --- Makefile | 2 +- change_logs/release_v0.24.14.md | 24 ++++++++++++++++++++++++ internal/view/container.go | 3 ++- internal/view/dp.go | 3 ++- internal/view/logs_extender.go | 3 ++- internal/view/pod.go | 8 +++----- internal/view/registrar.go | 3 +++ internal/view/scale_extender.go | 4 ++-- internal/view/sts.go | 3 ++- internal/view/types.go | 2 +- 10 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 change_logs/release_v0.24.14.md diff --git a/Makefile b/Makefile index 0730c5f1..4a4a0ca4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PACKAGE := github.com/derailed/$(NAME) GIT_REV ?= $(shell git rev-parse --short HEAD) SOURCE_DATE_EPOCH ?= $(shell date +%s) DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ") -VERSION ?= v0.24.13 +VERSION ?= v0.24.14 IMG_NAME := derailed/k9s IMAGE := ${IMG_NAME}:${VERSION} diff --git a/change_logs/release_v0.24.14.md b/change_logs/release_v0.24.14.md new file mode 100644 index 00000000..cdcf9483 --- /dev/null +++ b/change_logs/release_v0.24.14.md @@ -0,0 +1,24 @@ + + +# Release v0.24.14 + +## Notes + +Thank you to all that contributed with flushing out issues and enhancements for K9s! I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev and see if we're happier with some of the fixes! If you've filed an issue please help me verify and close. Your support, kindness and awesome suggestions to make K9s better are as ever very much noted and appreciated! + +If you feel K9s is helping your Kubernetes journey, please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer) + +On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM) + +## Maintenance Release! + +--- + +## Resolved Issues + +* [Issue #1186](https://github.com/derailed/k9s/issues/1186) Viewing previous logs does not work +* [Issue #1167](https://github.com/derailed/k9s/issues/1167) Cronjob trigger busted with feelings! + +--- + + © 2020 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0) diff --git a/internal/view/container.go b/internal/view/container.go index 20cbdf69..b51bd55a 100644 --- a/internal/view/container.go +++ b/internal/view/container.go @@ -91,7 +91,7 @@ func (c *Container) k9sEnv() Env { return env } -func (c *Container) logOptions() (*dao.LogOptions, error) { +func (c *Container) logOptions(prev bool) (*dao.LogOptions, error) { path := c.GetTable().GetSelectedItem() if path == "" { return nil, errors.New("nothing selected") @@ -105,6 +105,7 @@ func (c *Container) logOptions() (*dao.LogOptions, error) { SinceSeconds: cfg.SinceSeconds, SingleContainer: true, ShowTimestamp: cfg.ShowTime, + Previous: prev, } return &opts, nil diff --git a/internal/view/dp.go b/internal/view/dp.go index 87cb9e43..1daa7346 100644 --- a/internal/view/dp.go +++ b/internal/view/dp.go @@ -45,7 +45,7 @@ func (d *Deploy) bindKeys(aa ui.KeyActions) { }) } -func (d *Deploy) logOptions() (*dao.LogOptions, error) { +func (d *Deploy) logOptions(prev bool) (*dao.LogOptions, error) { path := d.GetTable().GetSelectedItem() if path == "" { return nil, errors.New("you must provide a selection") @@ -78,6 +78,7 @@ func (d *Deploy) logOptions() (*dao.LogOptions, error) { SingleContainer: len(cc) == 1, AllContainers: allCos, ShowTimestamp: cfg.ShowTime, + Previous: prev, } if co == "" { opts.AllContainers = true diff --git a/internal/view/logs_extender.go b/internal/view/logs_extender.go index 53d73185..ca5f88cc 100644 --- a/internal/view/logs_extender.go +++ b/internal/view/logs_extender.go @@ -63,11 +63,12 @@ func (l *LogsExtender) showLogs(path string, prev bool) { opts := l.buildLogOpts(path, "", prev) if l.optionsFn != nil { - if opts, err = l.optionsFn(); err != nil { + if opts, err = l.optionsFn(prev); err != nil { l.App().Flash().Err(err) return } } + if err := l.App().inject(NewLog(l.GVR(), opts)); err != nil { l.App().Flash().Err(err) } diff --git a/internal/view/pod.go b/internal/view/pod.go index d77f006f..342e58f7 100644 --- a/internal/view/pod.go +++ b/internal/view/pod.go @@ -85,7 +85,7 @@ func (p *Pod) bindKeys(aa ui.KeyActions) { aa.Add(resourceSorters(p.GetTable())) } -func (p *Pod) logOptions() (*dao.LogOptions, error) { +func (p *Pod) logOptions(prev bool) (*dao.LogOptions, error) { path := p.GetTable().GetSelectedItem() if path == "" { return nil, errors.New("you must provide a selection") @@ -96,16 +96,14 @@ func (p *Pod) logOptions() (*dao.LogOptions, error) { return nil, err } - cc := fetchContainers(pod.Spec, true) - - cfg := p.App().Config.K9s.Logger + cc, cfg := fetchContainers(pod.Spec, true), p.App().Config.K9s.Logger opts := dao.LogOptions{ Path: path, Lines: int64(cfg.TailCount), SinceSeconds: cfg.SinceSeconds, SingleContainer: len(cc) == 1, - AllContainers: false, ShowTimestamp: cfg.ShowTime, + Previous: prev, } if c, ok := dao.GetDefaultLogContainer(pod.ObjectMeta, pod.Spec); ok { opts.Container, opts.DefaultContainer = c, c diff --git a/internal/view/registrar.go b/internal/view/registrar.go index 7c006f3a..5370e398 100644 --- a/internal/view/registrar.go +++ b/internal/view/registrar.go @@ -138,6 +138,9 @@ func batchViewers(vv MetaViewers) { vv[client.NewGVR("batch/v1beta1/cronjobs")] = MetaViewer{ viewerFn: NewCronJob, } + vv[client.NewGVR("batch/v1/cronjobs")] = MetaViewer{ + viewerFn: NewCronJob, + } vv[client.NewGVR("batch/v1/jobs")] = MetaViewer{ viewerFn: NewJob, } diff --git a/internal/view/scale_extender.go b/internal/view/scale_extender.go index 2981b241..49816a67 100644 --- a/internal/view/scale_extender.go +++ b/internal/view/scale_extender.go @@ -102,9 +102,9 @@ func (s *ScaleExtender) makeScaleForm(sel string) (*tview.Form, error) { if err := s.scale(ctx, sel, count); err != nil { log.Error().Err(err).Msgf("DP %s scaling failed", sel) s.App().Flash().Err(err) - } else { - s.App().Flash().Infof("Resource %s:%s scaled successfully", s.GVR(), sel) + return } + s.App().Flash().Infof("Resource %s:%s scaled successfully", s.GVR(), sel) }) f.AddButton("Cancel", func() { diff --git a/internal/view/sts.go b/internal/view/sts.go index d7cab256..6e5db813 100644 --- a/internal/view/sts.go +++ b/internal/view/sts.go @@ -34,7 +34,7 @@ func NewStatefulSet(gvr client.GVR) ResourceViewer { return &s } -func (s *StatefulSet) logOptions() (*dao.LogOptions, error) { +func (s *StatefulSet) logOptions(prev bool) (*dao.LogOptions, error) { path := s.GetTable().GetSelectedItem() if path == "" { return nil, errors.New("you must provide a selection") @@ -67,6 +67,7 @@ func (s *StatefulSet) logOptions() (*dao.LogOptions, error) { SinceSeconds: cfg.SinceSeconds, AllContainers: allCos, ShowTimestamp: cfg.ShowTime, + Previous: prev, } if co == "" { opts.AllContainers = true diff --git a/internal/view/types.go b/internal/view/types.go index 457170f8..c54372de 100644 --- a/internal/view/types.go +++ b/internal/view/types.go @@ -31,7 +31,7 @@ type ( EnterFunc func(app *App, model ui.Tabular, gvr, path string) // LogOptionsFunc returns the active log options. - LogOptionsFunc func() (*dao.LogOptions, error) + LogOptionsFunc func(bool) (*dao.LogOptions, error) // ContextFunc enhances a given context. ContextFunc func(context.Context) context.Context