Skip to content

Commit

Permalink
another test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xueqzhan committed May 7, 2024
1 parent 2dfe572 commit f371e9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func updateDeploymentENVs(deployment *appsv1.Deployment, deploymentID, serviceCl
func (pna *podNetworkAvalibility) StartCollection(ctx context.Context, adminRESTConfig *rest.Config, recorder monitorapi.RecorderWriter) error {
deploymentID := uuid.New().String()

openshiftTestsImagePullSpec, err := GetOpenshiftTestsImagePullSpec(ctx, adminRESTConfig, pna.payloadImagePullSpec)
openshiftTestsImagePullSpec, err := GetOpenshiftTestsImagePullSpec(ctx, adminRESTConfig, pna.payloadImagePullSpec, nil)
if err != nil {
pna.notSupportedReason = &monitortestframework.NotSupportedError{Reason: fmt.Sprintf("unable to determine openshift-tests image: %v", err)}
return pna.notSupportedReason
Expand Down
49 changes: 22 additions & 27 deletions pkg/monitortests/network/disruptionpodnetwork/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
)

// GetOpenshiftTestsImagePullSpec returns the pull spec or an error.
func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.Config, suggestedPayloadImage string) (string, error) {
// IN ginkgo environment, oc needs to be created before BeforeEach and passed in
func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.Config, suggestedPayloadImage string, oc *exutil.CLI) (string, error) {
if len(suggestedPayloadImage) == 0 {
configClient, err := configclient.NewForConfig(adminRESTConfig)
if err != nil {
Expand All @@ -45,13 +46,16 @@ func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.C
if err := cmd.Run(); err != nil {
logrus.WithError(err).Errorf("unable to determine openshift-tests image through exec: %v", errOut.String())
// Now try the wrapper to see if it makes a difference
var oc = exutil.NewCLI("openshift-tests").AsAdmin()
if oc == nil {
oc = exutil.NewCLIWithoutNamespace("openshift-tests")
}
outStr, err = oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests").Output()
if err != nil {
logrus.WithError(err).Errorf("unable to determine openshift-tests image through oc wrapper with default ps: %v", outStr)

kubeClient := oc.AdminKubeClient()
// Try to use the same pull secret as the cluster under test
imagePullSecret, err := oc.KubeFramework().ClientSet.CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
imagePullSecret, err := kubeClient.CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
if err != nil {
logrus.WithError(err).Errorf("unable to get pull secret from cluster: %v", err)
return "", fmt.Errorf("unable to get pull secret from cluster: %v", err)
Expand All @@ -76,51 +80,39 @@ func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.C
return "", fmt.Errorf("unable to close file: %v", err)
}

outStr, err = oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests", "--pullspecs", "-o", "json", "--registry-config", imagePullFile.Name()).Output()
outStr, err = oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests", "--registry-config", imagePullFile.Name()).Output()
if err != nil {
logrus.WithError(err).Errorf("unable to determine openshift-tests image through oc wrapper with cluster ps")

// What is the mirror mode

return "", fmt.Errorf("unable to determine openshift-tests image oc wrapper with cluster ps: %v", err)
} else {
logrus.Infof("successfully getting image for test with oc wrapper with cluster ps: %s\n", outStr)
}
} else {
logrus.Infof("successfully getting image for test with oc wrapper with default ps: %s\n", outStr)
}

// What is the mirror mode for both clusters

// What is the proxy mode
} else {
outStr = out.String()
}

openshiftTestsImagePullSpec := strings.TrimSpace(outStr)
fmt.Printf("openshift-tests image pull spec is %v\n", openshiftTestsImagePullSpec)

// Test wrapper
// Now try the wrapper to see if it makes a difference
//var oc = exutil.NewCLIWithoutNamespace("openshift-tests").AsAdmin()
var oc = exutil.NewCLIWithoutNamespace("openshift-tests")
/*outStr, err := oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests").Output()
if oc == nil {
oc = exutil.NewCLIWithoutNamespace("openshift-tests")
}
outStr, err := oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests").Output()
if err != nil {
logrus.WithError(err).Errorf("unable to determine openshift-tests image through oc wrapper with default ps: %v", outStr)
} else {
logrus.Infof("successfully getting image for test with oc wrapper with default ps: %s\n", outStr)
}*/

}
kubeClient := oc.AdminKubeClient()
// Try to use the same pull secret as the cluster under test
logrus.Infof("----- oc is %+v", *oc)
kf := oc.KubeFramework()
kf.BeforeEach(ctx)
logrus.Infof("----- kf is %+v", *kf)
cl := kf.ClientSet
logrus.Infof("----- cl is %+v", cl)
core := cl.CoreV1()
logrus.Infof("----- core is %+v", core)
s := core.Secrets("openshift-config")
imagePullSecret, err := s.Get(context.Background(), "pull-secret", metav1.GetOptions{})
//imagePullSecret, err := oc.KubeFramework().ClientSet.CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
imagePullSecret, err := kubeClient.CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
if err != nil {
logrus.WithError(err).Errorf("unable to get pull secret from cluster: %v", err)
return "", fmt.Errorf("unable to get pull secret from cluster: %v", err)
Expand All @@ -145,9 +137,12 @@ func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.C
return "", fmt.Errorf("unable to close file: %v", err)
}

outStr, err = oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests", "--pullspecs", "-o", "json", "--registry-config", imagePullFile.Name()).Output()
outStr, err = oc.Run("adm", "release", "info", suggestedPayloadImage).Args("--image-for=tests", "--registry-config", imagePullFile.Name()).Output()
if err != nil {
logrus.WithError(err).Errorf("unable to determine openshift-tests image through oc wrapper with cluster ps")

// What is the mirror mode

return "", fmt.Errorf("unable to determine openshift-tests image oc wrapper with cluster ps: %v", err)
} else {
logrus.Infof("successfully getting image for test with oc wrapper with cluster ps: %s\n", outStr)
Expand Down
2 changes: 1 addition & 1 deletion test/extended/operators/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
inClusterPKIContent, err := gatherCertsFromPlatformNamespaces(ctx, kubeClient, masters)
o.Expect(err).NotTo(o.HaveOccurred())

openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpec(ctx, oc.AdminConfig(), "")
openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpec(ctx, oc.AdminConfig(), "", oc)
// Skip metal jobs if test image pullspec cannot be determined
if jobType.Platform != "metal" || err == nil {
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down

0 comments on commit f371e9b

Please sign in to comment.