Repository: m3db/m3db-operator
Pull request #196 (2020-02-14 15:29:33)

Apply annotations to pods in created StatefulSets
The StatefulSet template was not applying annotations to pods since it was not part of the pod template. This adds the same annotations to the pod.

codecov[bot]: # [Codecov](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=h1) Report
> Merging [#196](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=desc) into [master](https://codecov.io/gh/m3db/m3db-operator/commit/bf5714421007bd8771f164ae41e0725742e7a0ab?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.


[![Impacted file tree graph](https://codecov.io/gh/m3db/m3db-operator/pull/196/graphs/tree.svg?width=650&token=jtHDyWhsto&height=150&src=pr)](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #196      +/-   ##
==========================================
+ Coverage   75.17%   75.19%   +0.01%     
==========================================
  Files          30       30              
  Lines        2087     2088       +1     
==========================================
+ Hits         1569     1570       +1     
  Misses        391      391              
  Partials      127      127
```


------

[Continue to review full report at Codecov](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=footer). Last update [bf57144...d5a357c](https://codecov.io/gh/m3db/m3db-operator/pull/196?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/pkg/k8sops/m3db/statefulset.go b/pkg/k8sops/m3db/statefulset.go
index da182b0..d58f5af 100644
--- a/pkg/k8sops/m3db/statefulset.go
+++ b/pkg/k8sops/m3db/statefulset.go
@@ -118,7 +118,8 @@ func NewBaseStatefulSet(ssName, isolationGroup string, cluster *myspec.M3DBClust
 			Replicas: &ic,
 			Template: v1.PodTemplateSpec{
 				ObjectMeta: metav1.ObjectMeta{
-					Labels: objLabels,
+					Labels:      objLabels,
+					Annotations: objAnnotations,
 				},
 				Spec: v1.PodSpec{
 					PriorityClassName: cluster.Spec.PriorityClassName,


Test patch:
diff --git a/pkg/k8sops/m3db/generators_test.go b/pkg/k8sops/m3db/generators_test.go
index b523c7a..3f0c2cc 100644
--- a/pkg/k8sops/m3db/generators_test.go
+++ b/pkg/k8sops/m3db/generators_test.go
@@ -35,10 +35,10 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/util/intstr"
+	"k8s.io/utils/pointer"
 
 	crdutils "github.com/ant31/crd-validation/pkg"
 	"github.com/stretchr/testify/assert"
-	"k8s.io/utils/pointer"
 )
 
 func TestGenerateCRD(t *testing.T) {
@@ -139,7 +139,8 @@ func TestGenerateStatefulSet(t *testing.T) {
 			Replicas: instanceAmount,
 			Template: v1.PodTemplateSpec{
 				ObjectMeta: metav1.ObjectMeta{
-					Labels: labels,
+					Labels:      labels,
+					Annotations: annotations.BaseAnnotations(fixture),
 				},
 				Spec: v1.PodSpec{
 					PriorityClassName: "m3db-priority",