extract kverify.WaitForAPIServerStatus() helper
parent
0559802bed
commit
8a9fbe9bbf
|
|
@ -143,6 +143,22 @@ func APIServerVersionMatch(client *kubernetes.Clientset, expected string) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// WaitForAPIServerStatus waits for 'to' duration to get apiserver pod running or stopped
|
||||
// this functions is intended to use in situations where apiserver process can be recreated
|
||||
// by container runtime restart for example and there is a gap before it comes back
|
||||
func WaitForAPIServerStatus(cr command.Runner, to time.Duration, hostname string, port int) (state.State, error) {
|
||||
var st state.State
|
||||
var err error
|
||||
err = wait.PollImmediate(200*time.Millisecond, to, func() (bool, error) {
|
||||
st, err := APIServerStatus(cr, hostname, port)
|
||||
if st == state.Stopped {
|
||||
return false, nil
|
||||
}
|
||||
return true, err
|
||||
})
|
||||
return st, err
|
||||
}
|
||||
|
||||
// APIServerStatus returns apiserver status in libmachine style state.State
|
||||
func APIServerStatus(cr command.Runner, hostname string, port int) (state.State, error) {
|
||||
klog.Infof("Checking apiserver status ...")
|
||||
|
|
|
|||
|
|
@ -569,15 +569,8 @@ func (k *Bootstrapper) needsReconfigure(conf string, hostname string, port int,
|
|||
return true
|
||||
}
|
||||
// cruntime.Enable() may restart kube-apiserver but does not wait for it to return back
|
||||
var st state.State
|
||||
err := wait.PollImmediate(500*time.Millisecond, 3*time.Second, func() (bool, error) {
|
||||
var ierr error
|
||||
st, ierr = kverify.APIServerStatus(k.c, hostname, port)
|
||||
if st == state.Stopped {
|
||||
return false, nil
|
||||
}
|
||||
return true, ierr
|
||||
})
|
||||
apiStatusTimeout := 1500 * time.Millisecond
|
||||
st, err := kverify.WaitForAPIServerStatus(k.c, apiStatusTimeout, hostname, port)
|
||||
if err != nil {
|
||||
klog.Infof("needs reconfigure: apiserver error: %v", err)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in New Issue