Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libvirt-e2e: create auth.json file #1964

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cloud-api-adaptor/test/e2e/assessment_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ func (tc *TestCase) Run() {
t.Logf("Expected Pod State: %v", tc.podState)
yamlData, err := yaml.Marshal(pod.Status)
if err != nil {
fmt.Println("Error marshaling pod.Status to YAML: ", err.Error())
t.Logf("Error marshaling pod.Status to YAML: %v", err.Error())
} else {
t.Logf("Current Pod State: %v", string(yamlData))
}
if pod.Status.Phase == v1.PodRunning {
fmt.Printf("Log of the pod %.v \n===================\n", pod.Name)
t.Logf("Log of the pod %.v \n===================\n", pod.Name)
podLogString, _ := GetPodLog(ctx, client, *pod)
fmt.Println(podLogString)
fmt.Printf("===================\n")
t.Log(podLogString)
t.Logf("===================\n")
}
t.Fatal(err)
}
Expand All @@ -295,11 +295,11 @@ func (tc *TestCase) Run() {
t.Fatal(err)
}
clusterIP := WaitForClusterIP(t, client, tc.service)
log.Printf("webserver service is available on cluster IP: %s", clusterIP)
t.Logf("webserver service is available on cluster IP: %s", clusterIP)
}
if tc.extraPods != nil {
for _, extraPod := range tc.extraPods {
fmt.Printf("Provision extra pod %s", extraPod.pod.Name)
t.Logf("Provision extra pod %s", extraPod.pod.Name)
err := ProvisionPod(ctx, client, t, extraPod.pod, extraPod.podState, extraPod.testCommands)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -329,7 +329,7 @@ func (tc *TestCase) Run() {
}
if podLogString != "" {
if strings.Contains(podLogString, tc.expectedPodLogString) {
log.Printf("Output Log from Pod: %s", podLogString)
t.Logf("Output Log from Pod: %s", podLogString)
} else {
t.Errorf("Job Created pod with Invalid log")
}
Expand Down Expand Up @@ -435,7 +435,7 @@ func (tc *TestCase) Run() {
t.Fatal(error)
}
} else if profile != "" {
fmt.Printf("PodVM Created with Instance Type %v", profile)
t.Logf("PodVM Created with Instance Type %v", profile)
if tc.FailReason != "" {
var podlist v1.PodList
var podLogString string
Expand Down
23 changes: 11 additions & 12 deletions src/cloud-api-adaptor/test/e2e/rolling_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"testing"
"time"

log "github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -158,7 +157,7 @@ func DoTestCaaDaemonsetRollingUpdate(t *testing.T, testEnv env.Environment, asse
t.Fatal(err)
}
clusterIP := WaitForClusterIP(t, client, svc)
log.Printf("webserver service is available on cluster IP: %s", clusterIP)
t.Logf("webserver service is available on cluster IP: %s", clusterIP)

// Update verify command
verifyPod.Spec.Containers[0].Command = append(
Expand Down Expand Up @@ -210,25 +209,25 @@ func DoTestCaaDaemonsetRollingUpdate(t *testing.T, testEnv env.Environment, asse
if err = client.Resources().Get(ctx, verifyPodName, E2eNamespace, verifyPod); err != nil {
t.Fatal(err)
}
log.Printf("verify pod status: %s", verifyPod.Status.Phase)
t.Logf("verify pod status: %s", verifyPod.Status.Phase)
if verifyPod.Status.Phase != v1.PodRunning {
clientset, err := kubernetes.NewForConfig(client.RESTConfig())
if err != nil {
log.Printf("Failed to new client set: %v", err)
t.Logf("Failed to new client set: %v", err)
} else {
req := clientset.CoreV1().Pods(E2eNamespace).GetLogs(verifyPodName, &v1.PodLogOptions{})
podLogs, err := req.Stream(ctx)
if err != nil {
log.Printf("Failed to get pod logs: %v", err)
t.Logf("Failed to get pod logs: %v", err)
} else {
defer podLogs.Close()
buf := new(bytes.Buffer)
_, err = io.Copy(buf, podLogs)
if err != nil {
log.Printf("Failed to copy pod logs: %v", err)
t.Logf("Failed to copy pod logs: %v", err)
} else {
podLogString := strings.TrimSpace(buf.String())
log.Printf("verify pod logs: \n%s", podLogString)
t.Logf("verify pod logs: \n%s", podLogString)
}
}
}
Expand Down Expand Up @@ -272,12 +271,12 @@ func waitForCaaDaemonSetUpdated(t *testing.T, client klient.Client, ds *appsv1.D
if err := wait.For(conditions.New(client.Resources()).ResourceMatch(ds, func(object k8s.Object) bool {
dsObj, ok := object.(*appsv1.DaemonSet)
if !ok {
log.Printf("Not a DaemonSet object: %v", object)
t.Logf("Not a DaemonSet object: %v", object)
return false
}

log.Printf("Current CAA DaemonSet UpdatedNumberScheduled: %d", dsObj.Status.UpdatedNumberScheduled)
log.Printf("Current CAA DaemonSet NumberAvailable: %d", dsObj.Status.NumberAvailable)
t.Logf("Current CAA DaemonSet UpdatedNumberScheduled: %d", dsObj.Status.UpdatedNumberScheduled)
t.Logf("Current CAA DaemonSet NumberAvailable: %d", dsObj.Status.NumberAvailable)
return dsObj.Status.UpdatedNumberScheduled == rc && dsObj.Status.NumberAvailable == rc
}), wait.WithTimeout(WAIT_DEPLOYMENT_AVAILABLE_TIMEOUT)); err != nil {
t.Fatal(err)
Expand All @@ -288,11 +287,11 @@ func waitForDeploymentAvailable(t *testing.T, client klient.Client, deployment *
if err := wait.For(conditions.New(client.Resources()).ResourceMatch(deployment, func(object k8s.Object) bool {
deployObj, ok := object.(*appsv1.Deployment)
if !ok {
log.Printf("Not a Deployment object: %v", object)
t.Logf("Not a Deployment object: %v", object)
return false
}

log.Printf("Current deployment available replicas: %d", deployObj.Status.AvailableReplicas)
t.Logf("Current deployment available replicas: %d", deployObj.Status.AvailableReplicas)
return deployObj.Status.AvailableReplicas == rc
}), wait.WithTimeout(WAIT_DEPLOYMENT_AVAILABLE_TIMEOUT)); err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import (
"sigs.k8s.io/e2e-framework/pkg/envconf"
)

const authJSONTemplate string = `{
"auths": {
"quay.io": {
"auth": "%s"
}
}
}`

// LibvirtProvisioner implements the CloudProvisioner interface for Libvirt.
type LibvirtProvisioner struct {
conn *libvirt.Connect // Libvirt connection
Expand Down Expand Up @@ -337,6 +345,16 @@ func (lio *LibvirtInstallOverlay) Edit(ctx context.Context, cfg *envconf.Config,
}
}

if cred := os.Getenv("REGISTRY_CREDENTIAL_ENCODED"); cred != "" {
mkulke marked this conversation as resolved.
Show resolved Hide resolved
authJSON := fmt.Sprintf(authJSONTemplate, cred)
if err := os.WriteFile(filepath.Join(lio.Overlay.ConfigDir, "auth.json"), []byte(authJSON), 0644); err != nil {
return err
}
if err = lio.Overlay.SetKustomizeSecretGeneratorFile("auth-json-secret", "auth.json"); err != nil {
return err
}
}

if err = lio.Overlay.YamlReload(); err != nil {
return err
}
Expand Down
Loading