Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/k8shandler/fluentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func newFluentdPodSpec(cluster *logging.ClusterLogging, proxyConfig *configv1.Pr
// for collection config generation. If first is provided without the latter a
// ClusterLogFowarder with default fields is assumed.
// (See ClusterLoggingRequest#getLogForwarder)
if pipelineSpec.HasDefaultOutput() && cluster.Spec.LogStore != nil {
if pipelineSpec.HasDefaultOutput() && cluster.Spec.LogStore != nil && cluster.Spec.LogStore.ElasticsearchSpec.NodeCount > 0 {
fluentdPodSpec.InitContainers = []v1.Container{
newFluentdInitContainer(cluster),
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/k8shandler/fluentd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ func TestFluentdPodInitContainerWithDefaultForwarding(t *testing.T) {
},
LogStore: &logging.LogStoreSpec{
Type: "elasticsearch",
ElasticsearchSpec: logging.ElasticsearchSpec{
NodeCount: 1,
},
},
},
}
Expand All @@ -302,6 +305,32 @@ func TestFluentdPodInitContainerWithDefaultForwarding(t *testing.T) {
}
}

func TestFluentdPodInitContainerWithZeroESCount(t *testing.T) {
cluster := &logging.ClusterLogging{
Spec: logging.ClusterLoggingSpec{
Collection: &logging.CollectionSpec{
Logs: logging.LogCollectionSpec{
Type: "fluentd",
FluentdSpec: logging.FluentdSpec{},
},
},
LogStore: &logging.LogStoreSpec{
Type: "elasticsearch",
},
},
}

spec := logging.ClusterLogForwarderSpec{
Outputs: []logging.OutputSpec{{Name: "default"}},
}

podSpec := newFluentdPodSpec(cluster, nil, nil, spec)

if len(podSpec.InitContainers) > 0 {
t.Error("Expected pod not define init container")
}
}

func TestFluentdPodNoInitContainerWithOutDefaultForwarding(t *testing.T) {
cluster := &logging.ClusterLogging{
Spec: logging.ClusterLoggingSpec{
Expand Down