Skip to content

Commit

Permalink
OCM-10085 | ci: fix external-auth profile failure and introduce more …
Browse files Browse the repository at this point in the history
…logs
  • Loading branch information
xueli181114 committed Aug 3, 2024
1 parent ea34107 commit 4a997f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
28 changes: 11 additions & 17 deletions tests/utils/config/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"fmt"
"path"
"strings"
"time"

"github.com/openshift/rosa/tests/ci/config"
Expand All @@ -15,6 +14,8 @@ import (
// Only for HCP cluster now
func DeployCilium(ocClient *occli.Client, podCIDR string, hostPrefix string, outputDir string,
kubeconfigFile string) error {
var err error

ciliumVersion := "1.14.5"
yamlFileNames := []string{
"cluster-network-03-cilium-ciliumconfigs-crd.yaml",
Expand All @@ -33,20 +34,13 @@ func DeployCilium(ocClient *occli.Client, podCIDR string, hostPrefix string, out
}

url := "https://raw.githubusercontent.com/isovalent/olm-for-cilium/main/manifests"
for _, n := range yamlFileNames {
stdout, err := ocClient.Run(
fmt.Sprintf("oc apply -f %s/cilium.v%s/%s", url, ciliumVersion, n))
time.Sleep(3 * time.Second)

for _, yamlFile := range yamlFileNames {
_, err = ocClient.Run(
fmt.Sprintf("oc apply -f %s/cilium.v%s/%s", url, ciliumVersion, yamlFile),
3,
)
if err != nil {
if strings.Contains(err.Error(), "Warning") {
stdout, err = ocClient.Run(
fmt.Sprintf("oc apply -f %s/cilium.v%s/%s", url, ciliumVersion, n))
}
if err != nil {
log.Logger.Errorf("%s:%s", stdout, err.Error())
return err
}
return err
}
}

Expand All @@ -58,7 +52,7 @@ func DeployCilium(ocClient *occli.Client, podCIDR string, hostPrefix string, out

resultFile := path.Join(outputDir, "cilium.yaml")

_, _, err := occli.RunCMD(
_, _, err = occli.RunCMD(
fmt.Sprintf("cat %s | sed -e 's/HOSTPREFIX/%v/g' >> %s", fileName, hostPrefix, resultFile))
if err != nil {
return err
Expand All @@ -69,12 +63,12 @@ func DeployCilium(ocClient *occli.Client, podCIDR string, hostPrefix string, out
return err
}

stdout, err := ocClient.Run(fmt.Sprintf("oc apply -f %s --kubeconfig %s", resultFile, kubeconfigFile))
time.Sleep(3 * time.Second)
stdout, err := ocClient.Run(fmt.Sprintf("oc apply -f %s --kubeconfig %s", resultFile, kubeconfigFile), 3)
if err != nil {
log.Logger.Errorf("%s", stdout)
return err
}
time.Sleep(3 * time.Second)

return err
}
Expand Down
44 changes: 24 additions & 20 deletions tests/utils/exec/occli/cmd_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"fmt"
"os/exec"
"strings"
"time"

"github.com/openshift/rosa/tests/utils/log"
)

type Client struct {
Expand All @@ -23,28 +26,26 @@ func NewOCClient(kubePath ...string) *Client {
return ocClient
}

type RunCMDError struct {
Stderr string
Err error
CMD string
}

func (ocClient Client) Run(cmd string, pipeCommands ...string) (stdout string, err error) {

func (ocClient Client) Run(cmd string, retryTimes int, pipeCommands ...string) (stdout string, err error) {
var stderr string
fmt.Println(">> Running CMD: ", cmd)
var pipeCommand string
for _, command := range pipeCommands {
pipeCommand += fmt.Sprintf("|%s", command)
}
cmd = fmt.Sprintf("%s --kubeconfig %s %s", cmd, ocClient.KubePath, pipeCommand)
stdout, stderr, err = RunCMD(cmd)
if err != nil {
t := &RunCMDError{Stderr: stderr, Err: err, CMD: cmd}
err = t.Err
for retryTimes > 0 {
log.Logger.Info("Running CMD: ", cmd)
var pipeCommand string
for _, command := range pipeCommands {
pipeCommand += fmt.Sprintf("|%s", command)
}
cmd = fmt.Sprintf("%s --kubeconfig %s %s", cmd, ocClient.KubePath, pipeCommand)
stdout, stderr, err = RunCMD(cmd)
if err != nil {
log.Logger.Errorf("Got output: %s", stderr)
} else {
stdout = strings.TrimSuffix(stdout, "\n")
log.Logger.Infof("Got output: %s", stdout)
return
}
time.Sleep(3 * time.Second)
retryTimes--
}
stdout = strings.TrimSuffix(stdout, "\n")
fmt.Println(">> Got STDOUT: ", stdout)
return
}

Expand All @@ -57,6 +58,9 @@ func RunCMD(cmd string) (stdout string, stderr string, err error) {
err = CMD.Run()
stdout = strings.TrimPrefix(stdoutput.String(), "\n")
stderr = strings.TrimPrefix(stderroutput.String(), "\n")
if err != nil {
err = fmt.Errorf("%s:%s", err.Error(), stderr)
}
return
}

Expand Down

0 comments on commit 4a997f0

Please sign in to comment.