mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 22:49:58 +00:00
TUN-8734: add log collection for kubernetes
## Summary Adds the log collector for K8s based deployments. Closes TUN-8734
This commit is contained in:
@@ -3,7 +3,6 @@ package diagnostic
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -44,40 +43,5 @@ func (collector *DockerLogCollector) Collect(ctx context.Context) (*LogInformati
|
||||
collector.containerID,
|
||||
)
|
||||
|
||||
stdoutReader, err := command.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error retrieving output from command '%s': %w",
|
||||
command.String(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
if err := command.Start(); err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error running command '%s': %w",
|
||||
command.String(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
_, err = io.Copy(outputHandle, stdoutReader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error copying output from %s to file %s: %w",
|
||||
command.String(),
|
||||
outputHandle.Name(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
if err := command.Wait(); err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error waiting from command '%s': %w",
|
||||
command.String(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
return NewLogInformation(outputHandle.Name(), true, false), nil
|
||||
return PipeCommandOutputToFile(command, outputHandle)
|
||||
}
|
||||
|
Reference in New Issue
Block a user