Skip to content

Commit

Permalink
Loki microservices Tanka: fix error during manifest generation (grafa…
Browse files Browse the repository at this point in the history
…na#9362)

**What this PR does / why we need it**:
Fixes an error on the ServiceMonitor generated when
```
memberlist_ring_enabled: true,
create_service_monitor: true,
```
It also adds some checks on `memberlist.libsonnet` to avoid generating
invalid kubernetes manifests.

**Which issue(s) this PR fixes**:
Fixes grafana#9361
  • Loading branch information
irizzant authored and Mohamed-Amine Bouqsimi committed May 4, 2023
1 parent 53dadd3 commit e12dea6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions production/ksonnet/loki/memberlist.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

compactor_statefulset+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
distributor_deployment+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
index_gateway_statefulset+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
index_gateway_statefulset+: if !$._config.memberlist_ring_enabled || !$._config.use_index_gateway then {} else gossipLabel,
ingester_statefulset: if $._config.multi_zone_ingester_enabled && !$._config.multi_zone_ingester_migration_enabled then {} else
(super.ingester_statefulset + if !$._config.memberlist_ring_enabled then {} else gossipLabel),
ingester_zone_a_statefulset+:
Expand All @@ -136,7 +136,7 @@
if $._config.multi_zone_ingester_enabled && $._config.memberlist_ring_enabled
then gossipLabel
else {},
query_scheduler_deployment+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
query_scheduler_deployment+: if !$._config.memberlist_ring_enabled || !$._config.query_scheduler_enabled then {} else gossipLabel,
ruler_deployment+: if !$._config.memberlist_ring_enabled || !$._config.ruler_enabled || $._config.stateful_rulers then {} else gossipLabel,
ruler_statefulset+: if !$._config.memberlist_ring_enabled || !$._config.ruler_enabled || !$._config.stateful_rulers then {} else gossipLabel,
// Headless service (= no assigned IP, DNS returns all targets instead) pointing to gossip network members.
Expand Down
2 changes: 1 addition & 1 deletion production/ksonnet/loki/servicemonitor.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
values: [
this[name].spec.selector.name
for name in std.objectFields(this)
if std.isObject(this[name]) && std.objectHas(this[name], 'kind') && this[name].kind == 'Service'
if std.isObject(this[name]) && std.objectHas(this[name], 'kind') && this[name].kind == 'Service' && std.objectHasAll(this[name].spec.selector, 'name')
],
}],
},
Expand Down

0 comments on commit e12dea6

Please sign in to comment.