Skip to content

Commit

Permalink
Issue #337 Add resource as parameter for waitForOpenshiftAPIServer fu…
Browse files Browse the repository at this point in the history
…nction

As of now we are just using `oc get pods` to check if apiserver is running.
What actually happen non-core resource take some time and it might fails something like below.

```
error: the server doesn't have a resource type "proxy"
```
  • Loading branch information
praveenkumar committed Dec 14, 2019
1 parent ff5d4d5 commit 1ab8711
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/crc/cluster/cluster.go
Expand Up @@ -93,7 +93,7 @@ func AddPullSecret(sshRunner *ssh.SSHRunner, oc oc.OcConfig, pullSec string) err
fmt.Sprintf(`{"data":{".dockerconfigjson":"%s"}}`, base64OfPullSec),
"-n", "openshift-config", "--type", "merge"}

if err := waitForOpenshiftAPIServer(oc); err != nil {
if err := waitForOpenshiftAPIServer(oc, "secret"); err != nil {
return err
}
_, stderr, err := oc.RunOcCommand(cmdArgs...)
Expand All @@ -108,7 +108,7 @@ func UpdateClusterID(oc oc.OcConfig) error {
cmdArgs := []string{"patch", "clusterversion", "version", "-p",
fmt.Sprintf(`{"spec":{"clusterID":"%s"}}`, clusterID), "--type", "merge"}

if err := waitForOpenshiftAPIServer(oc); err != nil {
if err := waitForOpenshiftAPIServer(oc, "clusterversion"); err != nil {
return err
}
_, stderr, err := oc.RunOcCommand(cmdArgs...)
Expand Down Expand Up @@ -144,7 +144,7 @@ func AddProxyConfigToCluster(oc oc.OcConfig, proxy *network.ProxyConfig) error {
fmt.Sprintf(`{"spec":{"httpProxy":"%s", "httpsProxy":"%s", "noProxy":"%s"}}`, proxy.HttpProxy, proxy.HttpsProxy, proxy.NoProxy),
"-n", "openshift-config", "--type", "merge"}

if err := waitForOpenshiftAPIServer(oc); err != nil {
if err := waitForOpenshiftAPIServer(oc, "proxy"); err != nil {
return err
}
if _, stderr, err := oc.RunOcCommand(cmdArgs...); err != nil {
Expand Down Expand Up @@ -185,13 +185,14 @@ func addPullSecretToInstanceDisk(sshRunner *ssh.SSHRunner, pullSec string) error
return nil
}

func waitForOpenshiftAPIServer(oc oc.OcConfig) error {
func waitForOpenshiftAPIServer(oc oc.OcConfig, resource string) error {
waitForApiServer := func() error {
_, stderr, err := oc.RunOcCommand("get", "pods")
stdout, stderr, err := oc.RunOcCommand("get", resource)
if err != nil {
logging.Debug(stderr)
return &errors.RetriableError{Err: err}
}
logging.Debug(stdout)
return nil
}
return errors.RetryAfter(80, waitForApiServer, time.Second)
Expand Down

0 comments on commit 1ab8711

Please sign in to comment.