Skip to content
Open
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
8 changes: 7 additions & 1 deletion test/e2e-ocl/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,13 @@ func streamMachineOSBuilderPodLogsToFile(ctx context.Context, t *testing.T, cs *
LabelSelector: "k8s-app=machine-os-builder",
})

require.NoError(t, err)
if err != nil {
return fmt.Errorf("could not list machine-os-builder pods: %w", err)
}

if len(pods.Items) == 0 {
return fmt.Errorf("no machine-os-builder pods found")
}

mobPod := &pods.Items[0]
return streamPodContainerLogsToFile(ctx, t, cs, mobPod, dirPath)
Expand Down
29 changes: 27 additions & 2 deletions test/e2e-ocl/onclusterlayering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ func runOnClusterLayeringTest(t *testing.T, testOpts onClusterLayeringTestOpts)
// Goroutine so that the rest of the test can continue.
go func() {
err := streamBuildPodLogsToFile(buildPodStreamerCtx, t, cs, startedBuild, podLogsDirPath)
require.NoError(t, err, "expected no error, got %s", err)
assert.NoError(t, err, "expected no error, got %s", err)
}()

// We also want to collect logs from the machine-os-builder pod since they
Expand All @@ -811,7 +811,7 @@ func runOnClusterLayeringTest(t *testing.T, testOpts onClusterLayeringTestOpts)
// blocked.
go func() {
err := streamMachineOSBuilderPodLogsToFile(mobPodStreamerCtx, t, cs, podLogsDirPath)
require.NoError(t, err, "expected no error, got: %s", err)
assert.NoError(t, err, "expected no error, got: %s", err)
}()

// Wait for the build to complete.
Expand Down Expand Up @@ -1000,6 +1000,31 @@ func waitForBuildToComplete(t *testing.T, cs *framework.ClientSet, startedBuild
start := time.Now()

kubeassert := helpers.AssertClientSet(t, cs).WithContext(ctx)

// Check the build status periodically and log it for debugging
debugCancel := make(chan struct{})
defer close(debugCancel)
go func() {
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
select {
case <-debugCancel:
return
case <-ctx.Done():
t.Logf("Context cancelled/timed out while waiting for build %s after %s", startedBuild.Name, time.Since(start))
return
case <-ticker.C:
mosb, err := cs.MachineconfigurationV1Interface.MachineOSBuilds().Get(context.Background(), startedBuild.Name, metav1.GetOptions{})
if err != nil {
t.Logf("Error fetching build status for %s: %v", startedBuild.Name, err)
} else {
t.Logf("Build %s status after %s: %+v", startedBuild.Name, time.Since(start), mosb.Status.Conditions)
}
}
}
}()

kubeassert.Eventually().MachineOSBuildIsSuccessful(startedBuild)
t.Logf("MachineOSBuild %s successful after %s", startedBuild.Name, time.Since(start))
assertBuildObjectsAreDeleted(t, kubeassert.Eventually(), startedBuild)
Expand Down