Repository: m3db/m3db-operator
Pull request #206 (2020-03-18 22:35:47)

[k8sops] Ensure dbnodes in DNS when bootstrapping
By default Kubernetes will not generate DNS names for a pod if it's not
ready. This sets `publishNotReadyAddresses` on the M3DB service so that
we can look up pod IPs even when they're bootstrapping (and thus send
them writes to be buffered to commitlog).

codecov[bot]: # [Codecov](https://codecov.io/gh/m3db/m3db-operator/pull/206?src=pr&el=h1) Report
> Merging [#206](https://codecov.io/gh/m3db/m3db-operator/pull/206?src=pr&el=desc) into [master](https://codecov.io/gh/m3db/m3db-operator/commit/e967d2329a26ac217d5de3416fc817a17d020364?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/206/graphs/tree.svg?width=650&token=jtHDyWhsto&height=150&src=pr)](https://codecov.io/gh/m3db/m3db-operator/pull/206?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
+ Coverage   75.27%   75.28%   +0.01%     
==========================================
  Files          30       30              
  Lines        2095     2096       +1     
==========================================
+ Hits         1577     1578       +1     
  Misses        391      391              
  Partials      127      127
```


------

[Continue to review full report at Codecov](https://codecov.io/gh/m3db/m3db-operator/pull/206?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/206?src=pr&el=footer). Last update [e967d23...e6b0815](https://codecov.io/gh/m3db/m3db-operator/pull/206?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/pkg/k8sops/m3db/generators.go b/pkg/k8sops/m3db/generators.go
index 1c166ff..c578ab1 100644
--- a/pkg/k8sops/m3db/generators.go
+++ b/pkg/k8sops/m3db/generators.go
@@ -219,6 +219,10 @@ func GenerateM3DBService(cluster *myspec.M3DBCluster) (*v1.Service, error) {
 			Ports:     generateM3DBServicePorts(cluster),
 			ClusterIP: v1.ClusterIPNone,
 			Type:      v1.ServiceTypeClusterIP,
+			// Ensure we still publish dbnode DNS names so that we can look up nodes
+			// while they're bootstrapping. We don't do this for the coordinator
+			// service as we don't want to route unready coordinators.
+			PublishNotReadyAddresses: true,
 		},
 	}, nil
 }


Test patch:
diff --git a/pkg/k8sops/m3db/generators_test.go b/pkg/k8sops/m3db/generators_test.go
index 42397e6..4203fd4 100644
--- a/pkg/k8sops/m3db/generators_test.go
+++ b/pkg/k8sops/m3db/generators_test.go
@@ -495,10 +495,11 @@ func TestGenerateM3DBService(t *testing.T) {
 			},
 		},
 		Spec: v1.ServiceSpec{
-			Selector:  baseLabels,
-			Ports:     generateM3DBServicePorts(cluster),
-			ClusterIP: v1.ClusterIPNone,
-			Type:      v1.ServiceTypeClusterIP,
+			Selector:                 baseLabels,
+			Ports:                    generateM3DBServicePorts(cluster),
+			ClusterIP:                v1.ClusterIPNone,
+			Type:                     v1.ServiceTypeClusterIP,
+			PublishNotReadyAddresses: true,
 		},
 	}