Skip to content

Commit

Permalink
testing stuff here for kine
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Savian <[email protected]>
  • Loading branch information
vitorsavian committed Feb 20, 2024
1 parent 1c17461 commit beb5ac8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/daemons/control/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,12 @@ func waitForAPIServerInBackground(ctx context.Context, runtime *config.ControlRu
for {
select {
case <-ctx.Done():
logrus.Info("the context is done bruv")
logrus.Info("--------------------------")
return
case <-runtime.ETCDReady:
logrus.Info("i will break the for loop")
logrus.Info("--------------------------")
break etcdLoop
case <-time.After(30 * time.Second):
logrus.Infof("Waiting for etcd server to become available")
Expand All @@ -445,6 +449,7 @@ func waitForAPIServerInBackground(ctx context.Context, runtime *config.ControlRu
return
case err := <-promise(func() error { return util.WaitForAPIServerReady(ctx, runtime.KubeConfigSupervisor, 30*time.Second) }):
if err != nil {
logrus.Errorf("Failed to get apiserver /readyz status: %v", err)
logrus.Infof("Waiting for API server to become available")
continue
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/util/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package util

import (
"context"
"encoding/json"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -75,11 +76,20 @@ func WaitForAPIServerReady(ctx context.Context, kubeconfigPath string, timeout t

restConfig = dynamic.ConfigFor(restConfig)
restConfig.GroupVersion = &schema.GroupVersion{}

jsonDataRestConfig, err := json.MarshalIndent(restConfig, "", " ")
if err != nil {
return err
}

logrus.Infof("restConfig: %s", string(jsonDataRestConfig))

restClient, err := rest.RESTClientFor(restConfig)
if err != nil {
return err
}

// here to verify this thing
err = wait.PollImmediateWithContext(ctx, time.Second, timeout, func(ctx context.Context) (bool, error) {
healthStatus := 0
result := restClient.Get().AbsPath("/readyz").Do(ctx).StatusCode(&healthStatus)
Expand All @@ -96,7 +106,6 @@ func WaitForAPIServerReady(ctx context.Context, kubeconfigPath string, timeout t

return true, nil
})

if err != nil {
return merr.NewErrors(err, lastErr)
}
Expand Down Expand Up @@ -140,7 +149,6 @@ func WaitForRBACReady(ctx context.Context, kubeconfigPath string, timeout time.D
lastErr = errors.New(status.Reason)
return false, nil
})

if err != nil {
return merr.NewErrors(err, lastErr)
}
Expand Down

0 comments on commit beb5ac8

Please sign in to comment.