Skip to content

Commit

Permalink
Fix: deal with route not match
Browse files Browse the repository at this point in the history
Signed-off-by: harlee-x <hailin097@sina.com>
  • Loading branch information
harlee-x committed Apr 30, 2024
1 parent 1891dba commit 2331f71
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions pkg/apiserver/domain/service/web_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"kdp-oam-operator/pkg/apiserver/infrastructure/clients"
"kdp-oam-operator/pkg/utils"
"kdp-oam-operator/pkg/utils/log"
"net/http"
"os"
"strings"
"text/template"
Expand Down Expand Up @@ -186,37 +185,14 @@ func (w webTerminalServiceImpl) OpenTerminal(ctx context.Context, kubeConfigSecr
time.Sleep(500 * time.Millisecond)
}

// get terminal and url
// get terminal
terminal, err := w.GetExecTerminal(ctx, TerminalName, TerminalNameSpace, 0)
if err != nil {
return nil, err
}

// Define counter
count := 0
// deal with no route match
for {
url, _, _, err := GetTerminalData(terminal)
if err != nil {
log.Logger.Errorf(fmt.Sprintf("get terminal url by response err: %s", err.Error()))
return nil, err
}
statusCode, err := utils.GetStatusCode(url)
if err != nil {
log.Logger.Errorf(fmt.Sprintf("get terminal url status err: %s", err.Error()))
return nil, err
}
log.Logger.Infof(fmt.Sprintf("check terminal url:%s response status:%d", url, statusCode))
if statusCode == http.StatusOK {
break
}
if count > 10 {
break
}
count++
time.Sleep(500 * time.Millisecond)
}

// deal with ingress route not match
time.Sleep(1500 * time.Millisecond)
return terminal, nil
}

Expand Down

0 comments on commit 2331f71

Please sign in to comment.