Skip to content

Commit 96282ca

Browse files
authored
Default Pod annotations should be a local variable (#5947) (#5948)
Fixes a bug where the default ES Pod annotations were stored in a global map. It may lead to operator crash or unexpected reconciliations and Pod annotations.
1 parent 1191d2b commit 96282ca

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pkg/controller/elasticsearch/nodespec/defaults.go

-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1313

1414
commonv1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/common/v1"
15-
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/annotation"
1615
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/defaults"
1716
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/label"
1817
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/settings"
@@ -40,11 +39,6 @@ var (
4039
corev1.ResourceMemory: DefaultMemoryLimits,
4140
},
4241
}
43-
44-
// DefaultAnnotations are the default annotations for the Elasticsearch pods
45-
DefaultAnnotations = map[string]string{
46-
annotation.FilebeatModuleAnnotation: "elasticsearch",
47-
}
4842
)
4943

5044
// DefaultEnvVars are environment variables injected into Elasticsearch pods.

pkg/controller/elasticsearch/nodespec/podspec.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/types"
1515

1616
esv1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/elasticsearch/v1"
17+
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/annotation"
1718
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/container"
1819
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/defaults"
1920
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/hash"
@@ -174,7 +175,9 @@ func buildAnnotations(
174175
scriptsVersion string,
175176
) map[string]string {
176177
// start from our defaults
177-
annotations := DefaultAnnotations
178+
annotations := map[string]string{
179+
annotation.FilebeatModuleAnnotation: "elasticsearch",
180+
}
178181

179182
configHash := fnv.New32a()
180183
// hash of the ES config to rotate the pod on config changes

0 commit comments

Comments
 (0)