knuu icon indicating copy to clipboard operation
knuu copied to clipboard

Do busy waiting in replacement with a timeout

Open smuu opened this issue 2 years ago • 1 comments

  • https://github.com/celestiaorg/knuu/blob/62170e970a1da935458910d8c9e74b5cd390e15e/pkg/k8s/k8s_statefulset.go#L74
  • https://github.com/celestiaorg/knuu/blob/62170e970a1da935458910d8c9e74b5cd390e15e/pkg/k8s/k8s_pod.go#L104
  • check for other places in the code

smuu avatar Jun 23 '23 12:06 smuu

timeout := 5 * time.Second // Set the timeout duration start := time.Now() // Record the start time

for { _, err := getPod(podConfig.Namespace, podConfig.Name) if err != nil { break }

if time.Since(start) >= timeout {
	// Timeout exceeded, handle the timeout condition
	// For example, you can log an error or return an appropriate response.
	break
}

time.Sleep(100 * time.Millisecond)

}

something like this?

Harshal662 avatar Jun 23 '23 17:06 Harshal662