@@ -285,24 +285,27 @@ func (h *Host) UncordonNode(node *Host) error {
285285}
286286
287287// CheckHTTPStatus will perform a web request to the url and return an error if the http status is not the expected
288- func (h * Host ) CheckHTTPStatus (url string , expected int ) error {
288+ func (h * Host ) CheckHTTPStatus (url string , expected ... int ) error {
289289 status , err := h .Configurer .HTTPStatus (h , url )
290290 if err != nil {
291291 return err
292292 }
293293
294- if status != expected {
295- return fmt .Errorf ("expected response code %d but received %d" , expected , status )
294+ for _ , e := range expected {
295+ if status == e {
296+ return nil
297+ }
296298 }
297299
298- return nil
300+ return fmt .Errorf ("expected response code %d but received %d" , expected , status )
301+
299302}
300303
301304// WaitHTTPStatus waits until http status received for a GET from the URL is the expected one
302- func (h * Host ) WaitHTTPStatus (url string , expected int ) error {
305+ func (h * Host ) WaitHTTPStatus (url string , expected ... int ) error {
303306 return retry .Do (
304307 func () error {
305- return h .CheckHTTPStatus (url , expected )
308+ return h .CheckHTTPStatus (url , expected ... )
306309 },
307310 retry .DelayType (retry .CombineDelay (retry .FixedDelay , retry .RandomDelay )),
308311 retry .MaxJitter (time .Second * 2 ),
@@ -364,5 +367,7 @@ func (h *Host) NeedIPTables() bool {
364367
365368// WaitKubeAPIReady blocks until the local kube api responds to /version
366369func (h * Host ) WaitKubeAPIReady () error {
367- return h .WaitHTTPStatus ("https://localhost:6443/version" , 200 )
370+ // If the anon-auth is disabled on kube api the version endpoint will give 401
371+ // thus we need to accept both 200 and 401 as valid statuses when checking kube api
372+ return h .WaitHTTPStatus ("https://localhost:6443/version" , 200 , 401 )
368373}
0 commit comments