Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nocturnalastro committed Jan 10, 2024
1 parent 756e3f4 commit 522a5d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/clients/exec_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
startTimeout = 5 * time.Second
startTimeout = 2 * time.Minute
deletionTimeout = 10 * time.Minute
)

Expand Down
20 changes: 16 additions & 4 deletions pkg/cmd/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,22 @@ var collectCmd = &cobra.Command{
utils.IfErrorExitOrPanic(err)

for _, c := range collectorNames {
if (c == collectors.LogsCollectorName || c == runner.All) && logsOutputFile == "" {
utils.IfErrorExitOrPanic(utils.NewMissingInputError(
errors.New("if Logs collector is selected you must also provide a log output file")),
)
if c == collectors.LogsCollectorName || c == runner.All {
if logsOutputFile == "" {
utils.IfErrorExitOrPanic(utils.NewMissingInputError(
errors.New("if Logs collector is selected you must also provide a log output file")),
)
} else if strings.Contains(logsOutputFile, "~") {
usr, err := user.Current()
if err != nil {
log.Fatal("Failed to fetch current user so could not resolve tempdir")
}
if logsOutputFile == "~" {
logsOutputFile = usr.HomeDir
} else if strings.HasPrefix(logsOutputFile, "~/") {
logsOutputFile = filepath.Join(usr.HomeDir, logsOutputFile[2:])
}
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/loglines/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func (lt *GenerationalLockedTime) Generation() uint32 {
func (lt *GenerationalLockedTime) Update(update time.Time) {
lt.lock.Lock()
defer lt.lock.Unlock()
lt.time = update
lt.generation += 1
if update.Sub(lt.time) > 0 {
lt.time = update
lt.generation += 1
}
}

type LineSlice struct {
Expand Down Expand Up @@ -221,6 +223,9 @@ func (gens *Generations) FlushAll() *LineSlice {
for _, value := range gens.Store {
gensToFlush = append(gensToFlush, value)
}
if len(gensToFlush) == 0 {
return &LineSlice{}
}
result, lastSlice := gens.flush(gensToFlush)
return MakeSliceFromLines(MakeNewCombinedSlice(result.Lines, lastSlice.Lines), lastSlice.Generation)
}
Expand Down

0 comments on commit 522a5d1

Please sign in to comment.