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

Check fluentd deployment befure running cluster logging e2e tests #43559

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/e2e/cluster_logging_es.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ var _ = framework.KubeDescribe("Cluster level logging using Elasticsearch [Featu
err = esLogsProvider.EnsureWorking()
framework.ExpectNoError(err, "Elasticsearch is not working")

err = ensureSingleFluentdOnEachNode(f, esLogsProvider.FluentdApplicationName())
framework.ExpectNoError(err, "Fluentd deployed incorrectly")

By("Running synthetic logger")
pod := createLoggingPod(f, podName, 10*60, 10*time.Minute)
defer f.PodClient().Delete(podName, &meta_v1.DeleteOptions{})
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/cluster_logging_gcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ var _ = framework.KubeDescribe("Cluster level logging using GCL", func() {
err = gclLogsProvider.EnsureWorking()
framework.ExpectNoError(err, "GCL is not working")

err = ensureSingleFluentdOnEachNode(f, gclLogsProvider.FluentdApplicationName())
framework.ExpectNoError(err, "Fluentd deployed incorrectly")

By("Running synthetic logger")
pod := createLoggingPod(f, podName, 10*60, 10*time.Minute)
defer f.PodClient().Delete(podName, &meta_v1.DeleteOptions{})
Expand Down
25 changes: 25 additions & 0 deletions test/e2e/cluster_logging_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,31 @@ func getMissingLinesCount(logsProvider logsProvider, pod *loggingPod) (int, erro
return pod.ExpectedLinesNumber - len(pod.Occurrences), nil
}

func ensureSingleFluentdOnEachNode(f *framework.Framework, fluentdApplicationName string) error {
fluentdPodList, err := getFluentdPods(f, fluentdApplicationName)
if err != nil {
return err
}

fluentdPodsPerNode := make(map[string]int)
for _, fluentdPod := range fluentdPodList.Items {
fluentdPodsPerNode[fluentdPod.Spec.NodeName]++
}

nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
for _, node := range nodeList.Items {
fluentdPodCount, ok := fluentdPodsPerNode[node.Name]

if !ok {
return fmt.Errorf("node %s doesn't have fluentd instance", node.Name)
} else if fluentdPodCount != 1 {
return fmt.Errorf("node %s contains %d fluentd instaces, expected exactly one", node.Name, fluentdPodCount)
}
}

return nil
}

func getFluentdPods(f *framework.Framework, fluentdApplicationName string) (*api_v1.PodList, error) {
label := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": fluentdApplicationName}))
options := meta_v1.ListOptions{LabelSelector: label.String()}
Expand Down