From 33a3eb19ed8471d014364babdce3efbf273e720c Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Fri, 20 Sep 2024 13:38:20 +0200 Subject: [PATCH] Fix the get logs from Pod set --- e2e/fixtures/factory.go | 8 -------- e2e/fixtures/fdb_operator_client.go | 6 ------ e2e/test_operator/operator_test.go | 4 ++++ internal/kubernetes/kubernetes.go | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/e2e/fixtures/factory.go b/e2e/fixtures/factory.go index f0072191..03d1354a 100644 --- a/e2e/fixtures/factory.go +++ b/e2e/fixtures/factory.go @@ -528,14 +528,6 @@ func (factory *Factory) UploadFile( dst) } -// GetLogsFromPod returns the logs for the provided Pod and container -func (factory *Factory) GetLogsFromPod(pod *corev1.Pod, container string) string { - logs, err := kubeHelper.GetLogsFromPod(context.Background(), factory.GetControllerRuntimeClient(), factory.getConfig(), pod, container, pointer.Int64(pod.CreationTimestamp.Unix())) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - - return logs -} - // GetLogsForPod will fetch the logs for the specified Pod and container since the provided seconds. func (factory *Factory) GetLogsForPod(pod *corev1.Pod, container string, since *int64) string { logs, err := kubeHelper.GetLogsFromPod(context.Background(), factory.GetControllerRuntimeClient(), factory.getConfig(), pod, container, since) diff --git a/e2e/fixtures/fdb_operator_client.go b/e2e/fixtures/fdb_operator_client.go index 543ebbfe..ea1de670 100644 --- a/e2e/fixtures/fdb_operator_client.go +++ b/e2e/fixtures/fdb_operator_client.go @@ -86,12 +86,6 @@ rules: - update - patch - delete -- apiGroups: - - "" - resources: - - pods/exec - verbs: - - create - apiGroups: - apps.foundationdb.org resources: diff --git a/e2e/test_operator/operator_test.go b/e2e/test_operator/operator_test.go index 8cbb360b..3d213b22 100644 --- a/e2e/test_operator/operator_test.go +++ b/e2e/test_operator/operator_test.go @@ -85,6 +85,10 @@ var _ = BeforeSuite(func() { factory.GetClusterOptions()..., ) + // Make sure that the test suite is able to fetch logs from Pods. + operatorPod := factory.RandomPickOnePod(factory.GetOperatorPods(fdbCluster.Namespace()).Items) + Expect(factory.GetLogsForPod(&operatorPod, "manager", nil)).NotTo(BeEmpty()) + //Load some data async into the cluster. We will only block as long as the Job is created. factory.CreateDataLoaderIfAbsent(fdbCluster) diff --git a/internal/kubernetes/kubernetes.go b/internal/kubernetes/kubernetes.go index 4613693b..67fbadba 100644 --- a/internal/kubernetes/kubernetes.go +++ b/internal/kubernetes/kubernetes.go @@ -245,7 +245,7 @@ func GetLogsFromPod( return "", err } - req := restClient.Post(). + req := restClient.Get(). Resource("pods"). Namespace(pod.Namespace). Name(pod.Name).