k0sproject / k0sproject/k0sctl

ansi color panic on Windows when using busybox sh

Open
#752 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
582
Forks
113
Avg merge
2d 13h
Merged PRs (30d)
34

Description

```
INFO ==> Running phase: Download k0s on hosts
[36mINFO[36mINFOpanic: runtime error: slice bounds out of range [1:0]

goroutine 655 [running]:
github.com/shiena/ansicolor.(*ansiColorWriter).Write(0xc0003dc2a0, {0xc00019f180, 0x41, 0x80})
github.com/shiena/ansicolor@v0.0.0-20230509054315-a9deabde6e02/ansicolor_windows.go:385 +0x45b
github.com/k0sproject/k0sctl/cmd.(*loghook).Fire(0xc0003b0cc0, 0xc000947a18?)
github.com/k0sproject/k0sctl/cmd/flags.go:374 +0xb3
github.com/sirupsen/logrus.LevelHooks.Fire(0xc000947a58?, 0x947a18?, 0xc0003aa150)
github.com/sirupsen/logrus@v1.9.3/hooks.go:28 +0x64
github.com/sirupsen/logrus.(*Entry).fireHooks(0xc0003aa150)
github.com/sirupsen/logrus@v1.9.3/entry.go:280 +0x1fa
github.com/sirupsen/logrus.(*Entry).log(0xc0003aa000, 0x4, {0xc000a8ea40, 0x31})
github.com/sirupsen/logrus@v1.9.3/entry.go:242 +0x399
github.com/sirupsen/logrus.(*Entry).Log(0xc0003aa000, 0x4, {0xc000947c18?, 0x2?, 0x2?})
github.com/sirupsen/logrus@v1.9.3/entry.go:304 +0x48
github.com/sirupsen/logrus.(*Entry).Logf(0xc0003aa000, 0x4, {0xd30780?, 0x12?}, {0xc000947dd8?, 0x5?, 0xc00090e480?})
github.com/sirupsen/logrus@v1.9.3/entry.go:349 +0x7c
github.com/sirupsen/logrus.(*Logger).Logf(0x1502e80, 0x4, {0xd30780, 0x16}, {0xc000947dd8, 0x2, 0x2})
github.com/sirupsen/logrus@v1.9.3/logger.go:154 +0x7c
github.com/sirupsen/logrus.(*Logger).Infof(...)
github.com/sirupsen/logrus@v1.9.3/logger.go:168
github.com/sirupsen/logrus.Infof(...)
github.com/sirupsen/logrus@v1.9.3/exported.go:199
github.com/k0sproject/k0sctl/phase.(*DownloadK0s).downloadK0s(0xc0000c6370, 0xc0001ceb48)
github.com/k0sproject/k0sctl/phase/download_k0s.go:65 +0x174
github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster.Hosts.ParallelEach.func1(0xc0001ceb48)
github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/hosts.go:124 +0x91
created by github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster.Hosts.ParallelEach in goroutine 1
github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/hosts.go:122 +0x1bb
```
is there a way to easily disable console coloring?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in cmd/flags.go around the loghook call shown in the stack trace, then inspect the Windows path at ansicolor_windows.go:385. Reproduce the panic while running k0sctl through BusyBox sh on Windows and check how console coloring is configured. Done means the command no longer panics and the reported coloring behavior can be disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.