@ -47,6 +47,13 @@ type statusWaiter struct {
ctx context . Context
}
// DefaultStatusWatcherTimeout is the timeout used by the status waiter when a
// zero timeout is provided. This prevents callers from accidentally passing a
// zero value (which would immediately cancel the context) and getting
// "context deadline exceeded" errors. SDK callers can rely on this default
// when they don't set a timeout.
var DefaultStatusWatcherTimeout = 30 * time . Second
func alwaysReady ( _ * unstructured . Unstructured ) ( * status . Result , error ) {
return & status . Result {
Status : status . CurrentStatus ,
@ -55,7 +62,10 @@ func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) {
}
func ( w * statusWaiter ) WatchUntilReady ( resourceList ResourceList , timeout time . Duration ) error {
ctx , cancel := w . contextWithTimeout ( timeout )
if timeout == 0 {
timeout = DefaultStatusWatcherTimeout
}
ctx , cancel := context . WithTimeout ( context . Background ( ) , timeout )
defer cancel ( )
slog . Debug ( "waiting for resources" , "count" , len ( resourceList ) , "timeout" , timeout )
sw := watcher . NewDefaultStatusWatcher ( w . client , w . restMapper )
@ -76,7 +86,16 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D
}
func ( w * statusWaiter ) Wait ( resourceList ResourceList , timeout time . Duration ) error {
<< << << < HEAD
ctx , cancel := w . contextWithTimeout ( timeout )
|| || || | parent of 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
== == == =
if timeout == 0 {
timeout = DefaultStatusWatcherTimeout
}
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
>> >> >> > 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
defer cancel ( )
slog . Debug ( "waiting for resources" , "count" , len ( resourceList ) , "timeout" , timeout )
sw := watcher . NewDefaultStatusWatcher ( w . client , w . restMapper )
@ -84,7 +103,16 @@ func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) er
}
func ( w * statusWaiter ) WaitWithJobs ( resourceList ResourceList , timeout time . Duration ) error {
<< << << < HEAD
ctx , cancel := w . contextWithTimeout ( timeout )
|| || || | parent of 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
== == == =
if timeout == 0 {
timeout = DefaultStatusWatcherTimeout
}
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
>> >> >> > 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
defer cancel ( )
slog . Debug ( "waiting for resources" , "count" , len ( resourceList ) , "timeout" , timeout )
sw := watcher . NewDefaultStatusWatcher ( w . client , w . restMapper )
@ -95,7 +123,16 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura
}
func ( w * statusWaiter ) WaitForDelete ( resourceList ResourceList , timeout time . Duration ) error {
<< << << < HEAD
ctx , cancel := w . contextWithTimeout ( timeout )
|| || || | parent of 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
== == == =
if timeout == 0 {
timeout = DefaultStatusWatcherTimeout
}
ctx , cancel := context . WithTimeout ( context . TODO ( ) , timeout )
>> >> >> > 86 f98f870 ( Prevent surprising failure with SDK when timeout is not set )
defer cancel ( )
slog . Debug ( "waiting for resources to be deleted" , "count" , len ( resourceList ) , "timeout" , timeout )
sw := watcher . NewDefaultStatusWatcher ( w . client , w . restMapper )