fix locking issue when shelling out #171
parent
d0fd83f90f
commit
1357608f95
|
|
@ -173,6 +173,8 @@ func (v *podView) shellCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *podView) shellIn(path, co string) {
|
func (v *podView) shellIn(path, co string) {
|
||||||
|
v.suspend()
|
||||||
|
{
|
||||||
ns, po := namespaced(path)
|
ns, po := namespaced(path)
|
||||||
args := make([]string, 0, 12)
|
args := make([]string, 0, 12)
|
||||||
args = append(args, "exec", "-it")
|
args = append(args, "exec", "-it")
|
||||||
|
|
@ -185,6 +187,8 @@ func (v *podView) shellIn(path, co string) {
|
||||||
args = append(args, "--", "sh")
|
args = append(args, "--", "sh")
|
||||||
log.Debug().Msgf("Shell args %v", args)
|
log.Debug().Msgf("Shell args %v", args)
|
||||||
runK(true, v.app, args...)
|
runK(true, v.app, args...)
|
||||||
|
}
|
||||||
|
v.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *podView) extraActions(aa keyActions) {
|
func (v *podView) extraActions(aa keyActions) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/config"
|
"github.com/derailed/k9s/internal/config"
|
||||||
|
|
@ -43,6 +44,8 @@ type (
|
||||||
decorateFn decorateFn
|
decorateFn decorateFn
|
||||||
colorerFn colorerFn
|
colorerFn colorerFn
|
||||||
actions keyActions
|
actions keyActions
|
||||||
|
mx sync.Mutex
|
||||||
|
suspended bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -78,6 +81,15 @@ func (v *resourceView) init(ctx context.Context, ns string) {
|
||||||
}
|
}
|
||||||
v.getTV().setColorer(colorer)
|
v.getTV().setColorer(colorer)
|
||||||
|
|
||||||
|
go v.updater(ctx)
|
||||||
|
v.refresh()
|
||||||
|
if tv, ok := v.CurrentPage().Item.(*tableView); ok {
|
||||||
|
tv.Select(1, 0)
|
||||||
|
v.selChanged(1, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *resourceView) updater(ctx context.Context) {
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
@ -85,17 +97,37 @@ func (v *resourceView) init(ctx context.Context, ns string) {
|
||||||
log.Debug().Msgf("%s watcher canceled!", v.title)
|
log.Debug().Msgf("%s watcher canceled!", v.title)
|
||||||
return
|
return
|
||||||
case <-time.After(time.Duration(v.app.config.K9s.RefreshRate) * time.Second):
|
case <-time.After(time.Duration(v.app.config.K9s.RefreshRate) * time.Second):
|
||||||
|
var suspended bool
|
||||||
|
v.mx.Lock()
|
||||||
|
{
|
||||||
|
suspended = v.suspended
|
||||||
|
}
|
||||||
|
v.mx.Unlock()
|
||||||
|
if suspended == true {
|
||||||
|
continue
|
||||||
|
}
|
||||||
v.app.QueueUpdate(func() {
|
v.app.QueueUpdate(func() {
|
||||||
v.refresh()
|
v.refresh()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(ctx)
|
}(ctx)
|
||||||
v.refresh()
|
}
|
||||||
if tv, ok := v.CurrentPage().Item.(*tableView); ok {
|
|
||||||
tv.Select(1, 0)
|
func (v *resourceView) suspend() {
|
||||||
v.selChanged(1, 0)
|
v.mx.Lock()
|
||||||
|
{
|
||||||
|
v.suspended = true
|
||||||
}
|
}
|
||||||
|
v.mx.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *resourceView) resume() {
|
||||||
|
v.mx.Lock()
|
||||||
|
{
|
||||||
|
v.suspended = false
|
||||||
|
}
|
||||||
|
v.mx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *resourceView) setExtraActionsFn(f actionsFn) {
|
func (v *resourceView) setExtraActionsFn(f actionsFn) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue