fix: output of talosctl logs
might be corruped
The line was not copied properly, so sometimes `talosctl logs` output was garbled as the buffer was re-used. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
criconstants "github.com/containerd/containerd/pkg/cri/constants"
|
criconstants "github.com/containerd/containerd/pkg/cri/constants"
|
||||||
|
"github.com/siderolabs/gen/slices"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|
||||||
@ -134,11 +135,14 @@ func (slicer *lineSlicer) chopper(r io.Reader, hostname string) {
|
|||||||
scanner := bufio.NewScanner(r)
|
scanner := bufio.NewScanner(r)
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
line := scanner.Bytes()
|
||||||
|
line = slices.Copy(line, len(line))
|
||||||
|
|
||||||
slicer.respCh <- &common.Data{
|
slicer.respCh <- &common.Data{
|
||||||
Metadata: &common.Metadata{
|
Metadata: &common.Metadata{
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
},
|
},
|
||||||
Bytes: scanner.Bytes(),
|
Bytes: line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user