Skip to content

Commit b73b126

Browse files
committed
extend error propagation from initializer
1 parent e5bd333 commit b73b126

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/common.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ func inspectTestRun(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
4141
err error
4242
)
4343
if err = c.List(ctx, podList, listOpts); err != nil {
44+
returnErr = err
4445
log.Error(err, "Could not list pods")
4546
return
4647
}
48+
4749
if len(podList.Items) < 1 {
4850
log.Info("No initializing pod found yet")
4951
return
@@ -65,12 +67,14 @@ func inspectTestRun(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
6567
config, err := rest.InClusterConfig()
6668
if err != nil {
6769
log.Error(err, "unable to fetch in-cluster REST config")
70+
returnErr = err
6871
return
6972
}
7073

7174
clientset, err := kubernetes.NewForConfig(config)
7275
if err != nil {
7376
log.Error(err, "unable to get access to clientset")
77+
returnErr = err
7478
return
7579
}
7680
req := clientset.CoreV1().Pods(k6.NamespacedName().Namespace).GetLogs(podList.Items[0].Name, &corev1.PodLogOptions{
@@ -82,12 +86,13 @@ func inspectTestRun(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
8286
podLogs, err := req.Stream(ctx)
8387
if err != nil {
8488
log.Error(err, "unable to stream logs from the pod")
89+
returnErr = err
8590
return
8691
}
8792
defer podLogs.Close()
8893

8994
buf := new(bytes.Buffer)
90-
_, err = io.Copy(buf, podLogs)
95+
_, returnErr = io.Copy(buf, podLogs)
9196
if err != nil {
9297
log.Error(err, "unable to copy logs from the pod")
9398
return

0 commit comments

Comments
 (0)