K9s 1186: prev logs (#1190)

* fix cron triggers

* fix cron triggers again...

* fix #1186

* update rel notes
mine
Fernand Galiana 2021-07-08 07:11:35 -06:00 committed by GitHub
parent 97e6c4b75a
commit 026adfbfbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 13 deletions

View File

@ -5,7 +5,7 @@ PACKAGE := github.com/derailed/$(NAME)
GIT_REV ?= $(shell git rev-parse --short HEAD) GIT_REV ?= $(shell git rev-parse --short HEAD)
SOURCE_DATE_EPOCH ?= $(shell date +%s) SOURCE_DATE_EPOCH ?= $(shell date +%s)
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ") 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 IMG_NAME := derailed/k9s
IMAGE := ${IMG_NAME}:${VERSION} IMAGE := ${IMG_NAME}:${VERSION}

View File

@ -0,0 +1,24 @@
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s_small.png" align="right" width="200" height="auto"/>
# 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!
---
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2020 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

View File

@ -91,7 +91,7 @@ func (c *Container) k9sEnv() Env {
return env return env
} }
func (c *Container) logOptions() (*dao.LogOptions, error) { func (c *Container) logOptions(prev bool) (*dao.LogOptions, error) {
path := c.GetTable().GetSelectedItem() path := c.GetTable().GetSelectedItem()
if path == "" { if path == "" {
return nil, errors.New("nothing selected") return nil, errors.New("nothing selected")
@ -105,6 +105,7 @@ func (c *Container) logOptions() (*dao.LogOptions, error) {
SinceSeconds: cfg.SinceSeconds, SinceSeconds: cfg.SinceSeconds,
SingleContainer: true, SingleContainer: true,
ShowTimestamp: cfg.ShowTime, ShowTimestamp: cfg.ShowTime,
Previous: prev,
} }
return &opts, nil return &opts, nil

View File

@ -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() path := d.GetTable().GetSelectedItem()
if path == "" { if path == "" {
return nil, errors.New("you must provide a selection") return nil, errors.New("you must provide a selection")
@ -78,6 +78,7 @@ func (d *Deploy) logOptions() (*dao.LogOptions, error) {
SingleContainer: len(cc) == 1, SingleContainer: len(cc) == 1,
AllContainers: allCos, AllContainers: allCos,
ShowTimestamp: cfg.ShowTime, ShowTimestamp: cfg.ShowTime,
Previous: prev,
} }
if co == "" { if co == "" {
opts.AllContainers = true opts.AllContainers = true

View File

@ -63,11 +63,12 @@ func (l *LogsExtender) showLogs(path string, prev bool) {
opts := l.buildLogOpts(path, "", prev) opts := l.buildLogOpts(path, "", prev)
if l.optionsFn != nil { if l.optionsFn != nil {
if opts, err = l.optionsFn(); err != nil { if opts, err = l.optionsFn(prev); err != nil {
l.App().Flash().Err(err) l.App().Flash().Err(err)
return return
} }
} }
if err := l.App().inject(NewLog(l.GVR(), opts)); err != nil { if err := l.App().inject(NewLog(l.GVR(), opts)); err != nil {
l.App().Flash().Err(err) l.App().Flash().Err(err)
} }

View File

@ -85,7 +85,7 @@ func (p *Pod) bindKeys(aa ui.KeyActions) {
aa.Add(resourceSorters(p.GetTable())) 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() path := p.GetTable().GetSelectedItem()
if path == "" { if path == "" {
return nil, errors.New("you must provide a selection") return nil, errors.New("you must provide a selection")
@ -96,16 +96,14 @@ func (p *Pod) logOptions() (*dao.LogOptions, error) {
return nil, err return nil, err
} }
cc := fetchContainers(pod.Spec, true) cc, cfg := fetchContainers(pod.Spec, true), p.App().Config.K9s.Logger
cfg := p.App().Config.K9s.Logger
opts := dao.LogOptions{ opts := dao.LogOptions{
Path: path, Path: path,
Lines: int64(cfg.TailCount), Lines: int64(cfg.TailCount),
SinceSeconds: cfg.SinceSeconds, SinceSeconds: cfg.SinceSeconds,
SingleContainer: len(cc) == 1, SingleContainer: len(cc) == 1,
AllContainers: false,
ShowTimestamp: cfg.ShowTime, ShowTimestamp: cfg.ShowTime,
Previous: prev,
} }
if c, ok := dao.GetDefaultLogContainer(pod.ObjectMeta, pod.Spec); ok { if c, ok := dao.GetDefaultLogContainer(pod.ObjectMeta, pod.Spec); ok {
opts.Container, opts.DefaultContainer = c, c opts.Container, opts.DefaultContainer = c, c

View File

@ -138,6 +138,9 @@ func batchViewers(vv MetaViewers) {
vv[client.NewGVR("batch/v1beta1/cronjobs")] = MetaViewer{ vv[client.NewGVR("batch/v1beta1/cronjobs")] = MetaViewer{
viewerFn: NewCronJob, viewerFn: NewCronJob,
} }
vv[client.NewGVR("batch/v1/cronjobs")] = MetaViewer{
viewerFn: NewCronJob,
}
vv[client.NewGVR("batch/v1/jobs")] = MetaViewer{ vv[client.NewGVR("batch/v1/jobs")] = MetaViewer{
viewerFn: NewJob, viewerFn: NewJob,
} }

View File

@ -102,9 +102,9 @@ func (s *ScaleExtender) makeScaleForm(sel string) (*tview.Form, error) {
if err := s.scale(ctx, sel, count); err != nil { if err := s.scale(ctx, sel, count); err != nil {
log.Error().Err(err).Msgf("DP %s scaling failed", sel) log.Error().Err(err).Msgf("DP %s scaling failed", sel)
s.App().Flash().Err(err) s.App().Flash().Err(err)
} else { return
s.App().Flash().Infof("Resource %s:%s scaled successfully", s.GVR(), sel)
} }
s.App().Flash().Infof("Resource %s:%s scaled successfully", s.GVR(), sel)
}) })
f.AddButton("Cancel", func() { f.AddButton("Cancel", func() {

View File

@ -34,7 +34,7 @@ func NewStatefulSet(gvr client.GVR) ResourceViewer {
return &s return &s
} }
func (s *StatefulSet) logOptions() (*dao.LogOptions, error) { func (s *StatefulSet) logOptions(prev bool) (*dao.LogOptions, error) {
path := s.GetTable().GetSelectedItem() path := s.GetTable().GetSelectedItem()
if path == "" { if path == "" {
return nil, errors.New("you must provide a selection") return nil, errors.New("you must provide a selection")
@ -67,6 +67,7 @@ func (s *StatefulSet) logOptions() (*dao.LogOptions, error) {
SinceSeconds: cfg.SinceSeconds, SinceSeconds: cfg.SinceSeconds,
AllContainers: allCos, AllContainers: allCos,
ShowTimestamp: cfg.ShowTime, ShowTimestamp: cfg.ShowTime,
Previous: prev,
} }
if co == "" { if co == "" {
opts.AllContainers = true opts.AllContainers = true

View File

@ -31,7 +31,7 @@ type (
EnterFunc func(app *App, model ui.Tabular, gvr, path string) EnterFunc func(app *App, model ui.Tabular, gvr, path string)
// LogOptionsFunc returns the active log options. // LogOptionsFunc returns the active log options.
LogOptionsFunc func() (*dao.LogOptions, error) LogOptionsFunc func(bool) (*dao.LogOptions, error)
// ContextFunc enhances a given context. // ContextFunc enhances a given context.
ContextFunc func(context.Context) context.Context ContextFunc func(context.Context) context.Context