Repository: kubernetes-sigs/kueue

Issue:
Log namespace to improve debuggability of  ginkgo tests
<!-- Please only use this template for submitting enhancement requests -->

**What would you like to be added**:

Log the created namspece in BeforeEach for tests which create namespaces. 

We can consider an extra helper like CreateNamespaceWithLog.

**Why is this needed**:

We have a number of flakes recently, and grepping by namespace seems quite efficient to get the logs we want.

However, currently the namespace is not logged for most test failures, so we need to figure out by timestamps, and this is time-consuming.

Example: https://github.com/kubernetes-sigs/kueue/issues/4651, or https://github.com/kubernetes-sigs/kueue/issues/4626 show issues without namespace logged. We can figure out by timestamps, but it is not convenient.



Hints from issue comments:
@mimowo: cc @mszadkow @tenzen-y @mszadkow: /assign

Solution patch:
diff --git a/hack/push-chart.sh b/hack/push-chart.sh
index e69fb2a7a..f483e9519 100755
--- a/hack/push-chart.sh
+++ b/hack/push-chart.sh
@@ -48,9 +48,15 @@ readonly default_image_repo
 # Update the image repo, tag and policy
 ${YQ}  e  ".controllerManager.manager.image.repository = \"${image_repository}\" | .controllerManager.manager.image.tag = \"${chart_version}\" | .controllerManager.manager.image.pullPolicy = \"IfNotPresent\"" -i charts/kueue/values.yaml
 
+# Update the kueueViz images in values.yaml
+${YQ} e ".kueueViz.backend.image = \"${image_repository}/kueue-viz-backend:${chart_version}\" | .kueueViz.frontend.image = \"${image_repository}/kueue-viz-frontend:${chart_version}\"" -i charts/kueue/values.yaml
+
 ${HELM} package --version "${chart_version}" --app-version "${chart_version}" charts/kueue -d "${DEST_CHART_DIR}"
 
 # Revert the image changes
 ${YQ}  e  ".controllerManager.manager.image.repository = \"${default_image_repo}\" | .controllerManager.manager.image.tag = \"main\" | .controllerManager.manager.image.pullPolicy = \"Always\"" -i charts/kueue/values.yaml
 
+# Revert the kueueViz image changes
+${YQ} e ".kueueViz.backend.image = \"us-central1-docker.pkg.dev/k8s-staging-images/kueue/kueue-viz-backend:main-latest\" | .kueueViz.frontend.image = \"us-central1-docker.pkg.dev/k8s-staging-images/kueue/kueue-viz-frontend:main-latest\"" -i charts/kueue/values.yaml
+
 ${HELM} push "bin/kueue-${chart_version}.tgz" "oci://${HELM_CHART_REPO}"



Test patch:
diff --git a/test/integration/singlecluster/scheduler/scheduler_test.go b/test/integration/singlecluster/scheduler/scheduler_test.go
index 5f4f79dc4..af3d822fd 100644
--- a/test/integration/singlecluster/scheduler/scheduler_test.go
+++ b/test/integration/singlecluster/scheduler/scheduler_test.go
@@ -1671,14 +1671,7 @@ var _ = ginkgo.Describe("Scheduler", func() {
 				Cohort(chName).
 				Obj()
 			gomega.Expect(k8sClient.Create(ctx, strictFIFOClusterQ)).Should(gomega.Succeed())
-			matchingNS = &corev1.Namespace{
-				ObjectMeta: metav1.ObjectMeta{
-					GenerateName: "foo-",
-					Labels:       map[string]string{"dep": "eng"},
-				},
-			}
-			ginkgo.By(fmt.Sprintf("Creating namespace: %s", matchingNS.Name))
-			gomega.Expect(k8sClient.Create(ctx, matchingNS)).To(gomega.Succeed())
+			matchingNS = util.CreateNamespaceFromObjectWithLog(ctx, k8sClient, testing.MakeNamespaceWrapper("").GenerateName("foo-").Label("dep", "eng").Obj())
 		})
 
 		ginkgo.AfterEach(func() {
diff --git a/test/util/e2e.go b/test/util/e2e.go
index ce9a43891..93eb61aa7 100644
--- a/test/util/e2e.go
+++ b/test/util/e2e.go
@@ -312,16 +312,16 @@ func GetKuberayTestImage() string {
 
 func CreateNamespaceWithLog(ctx context.Context, k8sClient client.Client, nsName string) *corev1.Namespace {
 	ginkgo.GinkgoHelper()
-	ns := utiltesting.MakeNamespace(nsName)
-	gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed())
-	ginkgo.GinkgoLogr.Info(fmt.Sprintf("Created namespace: %s", ns.Name))
-	return ns
+	return CreateNamespaceFromObjectWithLog(ctx, k8sClient, utiltesting.MakeNamespace(nsName))
 }
 
 func CreateNamespaceFromPrefixWithLog(ctx context.Context, k8sClient client.Client, nsPrefix string) *corev1.Namespace {
 	ginkgo.GinkgoHelper()
-	ns := utiltesting.MakeNamespaceWithGenerateName(nsPrefix)
-	gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed())
+	return CreateNamespaceFromObjectWithLog(ctx, k8sClient, utiltesting.MakeNamespaceWithGenerateName(nsPrefix))
+}
+
+func CreateNamespaceFromObjectWithLog(ctx context.Context, k8sClient client.Client, ns *corev1.Namespace) *corev1.Namespace {
+	gomega.ExpectWithOffset(1, k8sClient.Create(ctx, ns)).To(gomega.Succeed())
 	ginkgo.GinkgoLogr.Info(fmt.Sprintf("Created namespace: %s", ns.Name))
 	return ns
 }