Skip to content

Commit

Permalink
fix: continue to connect after a failure
Browse files Browse the repository at this point in the history
  • Loading branch information
alitari committed Sep 3, 2018
1 parent cf3d372 commit dc6150d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ func newBackend(context contextType) *backendType {
}

response, err := client.Do(req)
tracelog.Printf("rest call: %s %s , response status: %s", httpMethod, url, response.Status)
if err == nil {
tracelog.Printf("rest call: %s %s , response status: %s", httpMethod, url, response.Status)
}

return response, err
},
Expand Down
30 changes: 17 additions & 13 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ func (c *configType) createContexts() *configType {
mess := fmt.Sprintf("try connecting context '%s', cluster: '%s' ...", ct.Name, cluster.Name)
fmt.Println(mess)
infolog.Print(mess)
var skip = false
if ct.user.token == "<no value>" {
fmt.Print("retrieving token from secret ...")
infolog.Print("retrieving token from secret ...")
Expand All @@ -837,23 +838,26 @@ func (c *configType) createContexts() *configType {
mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error())
fmt.Println(mess)
warninglog.Print(mess)
break
skip = true
}
}
err = c.isAvailable(ct)
if err != nil {
mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error())
if !skip {
err = c.isAvailable(ct)
if err != nil {
mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error())
fmt.Println(mess)
warninglog.Print(mess)
skip = true
}
}
if !skip {
colorIndex := len(cs) % 4
ct.color = contextColors[colorIndex]
cs = append(cs, ct)
mess = fmt.Sprintf("created context no %d with name '%s' ", i+1, ct.Name)
fmt.Println(mess)
warninglog.Print(mess)
break
infolog.Print(mess)
}

colorIndex := len(cs) % 4
ct.color = contextColors[colorIndex]
cs = append(cs, ct)
mess = fmt.Sprintf("created context no %d with name '%s' ", i+1, ct.Name)
fmt.Println(mess)
infolog.Print(mess)
}
if len(cs) == 0 {
fatalStderrlog.Fatalf("No contexts created for configfile '%s'. See logfile '%s' for details.", c.configFile, *logFilePath)
Expand Down

0 comments on commit dc6150d

Please sign in to comment.