Skip to content

Commit

Permalink
Fixes linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin Dzhigarov committed Dec 27, 2024
1 parent 126156f commit e5a0a8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions k8s/result_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/rest"
)
Expand Down Expand Up @@ -84,20 +85,20 @@ func (w *ResultWriter) Write(ctx context.Context, searchResults []SearchResult)
for _, containerLogger := range containers {
semaphore <- 1 // Acquire a slot
wg.Add(1)
go func(logger Container) {
go func(pod unstructured.Unstructured, logger Container) {
defer wg.Done()
defer func() { <-semaphore }() // Release the slot
reader, e := logger.Fetch(ctx, w.restApi)
if e != nil {
logrus.Errorf("Failed to fetch container logs for pod %s: %s", podItem.GetName(), e)
logrus.Errorf("Failed to fetch container logs for pod %s: %s", pod.GetName(), e)
return
}
e = logger.Write(reader, logDir)
if e != nil {
logrus.Errorf("Failed to write container logs for pod %s: %s", podItem.GetName(), e)
logrus.Errorf("Failed to write container logs for pod %s: %s", pod.GetName(), e)
return
}
}(containerLogger)
}(podItem, containerLogger)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions testing/kindcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ spec:

// Wait until pod is in Error state or max 10 seconds
timeout := time.After(10 * time.Second)
tick := time.Tick(500 * time.Millisecond)
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop() // Ensure the ticker is stopped to prevent resource leaks

for {
select {
case <-timeout:
return fmt.Errorf("timed out waiting for pod to be in Terminating state")
case <-tick:
case <-ticker.C:
p = k.e.RunProc(fmt.Sprintf(`kubectl --context kind-%s get pod stuck-pod -o jsonpath='{.status.phase}'`, k.name))
if p.Err() != nil {
return fmt.Errorf("failed to check pod status: %s: %s", p.Err(), p.Result())
Expand Down

0 comments on commit e5a0a8e

Please sign in to comment.