Skip to content

Commit

Permalink
Phase out deprecated "any" selector for prometheus (#274)
Browse files Browse the repository at this point in the history
The client-go update might have caused some prometheus CRD keys to
become deprecated:

```
 W1211 22:57:47.332524       1 warnings.go:70] unknown field "spec.podMonitorNamespaceSelector.any"                                                     │
│ W1211 22:57:47.332547       1 warnings.go:70] unknown field "spec.podMonitorSelector.any"                                                              │
│ W1211 22:57:47.332551       1 warnings.go:70] unknown field "spec.ruleNamespaceSelector.any"                                                           │
│ W1211 22:57:47.332555       1 warnings.go:70] unknown field "spec.serviceMonitorNamespaceSelector.any"                                                 │
│ W1211 22:57:47.332558       1 warnings.go:70] unknown field "spec.serviceMonitorSelector.any"                                                          │
│ W1211 22:57:55.074526       1 warnings.go:70] unknown field "spec.podMonitorNamespaceSelector.any"                                                     │
│ W1211 22:57:55.074561       1 warnings.go:70] unknown field "spec.podMonitorSelector.any"                                                              │
│ W1211 22:57:55.074567       1 warnings.go:70] unknown field "spec.ruleNamespaceSelector.any"                                                           │
│ W1211 22:57:55.074572       1 warnings.go:70] unknown field "spec.serviceMonitorNamespaceSelector.any"                                                 │
│ W1211 22:57:55.074577       1 warnings.go:70] unknown field "spec.serviceMonitorSelector.any"
```

It's a little strange because looking at the CRDs, the any field [is
still
supported](https://github.com/prometheus-community/helm-charts/blob/e698c26417128aca0de24170f3155894aa881d4c/charts/kube-prometheus-stack/charts/crds/crds/crd-podmonitors.yaml#L88).

Well, but on the `prometheus` CRD that we're actually using, it doesn't
look like it [was ever
supported](https://github.com/prometheus-community/helm-charts/blob/e698c26417128aca0de24170f3155894aa881d4c/charts/kube-prometheus-stack/charts/crds/crds/crd-prometheuses.yaml).

Indeed, even in our internal replication, the "any" field isn't there:
https://github.com/googlecloudrobotics/core/blob/7772ffdec00289a98edb9757beb716923dde3003/third_party/kube-prometheus-stack/01-crds.yaml

Regardless, I moved to using an inverse match on an expression that
really shouldn't exist to approximate a universal "any" match instead.

Green **postsubmit** here:
https://github.com/googlecloudrobotics/core/actions/runs/7174582208

Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon authored Dec 13, 2023
1 parent 64de101 commit 66567e6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 10 deletions.
34 changes: 29 additions & 5 deletions src/app_charts/prometheus/prometheus-cloud.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,40 @@ prometheus:
prometheusSpec:
# Pick up all service monitors across all namespaces.
serviceMonitorNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
serviceMonitorSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

# Pick up all pod monitors across all namespaces.
podMonitorNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
podMonitorSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

# Pick up all rules across all namespaces.
ruleNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
ruleSelector:
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

externalUrl: "https://${CLOUD_ROBOTICS_DOMAIN}/prometheus/"
retention: "${RETENTION_TIME}"
retentionSize: "${RETENTION_SIZE}"
Expand Down
34 changes: 29 additions & 5 deletions src/app_charts/prometheus/prometheus-robot.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,40 @@ prometheus:
prometheusSpec:
# Pick up all service monitors across all namespaces.
serviceMonitorNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
serviceMonitorSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

# Pick up all pod monitors across all namespaces.
podMonitorNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
podMonitorSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

# Pick up all rules across all namespaces.
ruleNamespaceSelector:
any: true
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"
ruleSelector:
# Inverse selector selects everything
matchExpressions:
- key: "non-existent-label-for-universal-matching"
operator: "DoesNotExist"

logLevel: warn
# Historical data is limited to the lower of `retention` and
# `retentionSize`. This doesn't include the WAL (~3h of data) and the
Expand Down

0 comments on commit 66567e6

Please sign in to comment.