Skip to content

Commit

Permalink
Housekeeping: fix links, remove deprecated labels in examples, use st…
Browse files Browse the repository at this point in the history
…dlib `maps.Copy`, etc (#1013)

* Fix ambiguous markdown link, add missing links in `docs/monitoring/metrics.md`.

* Remove deprecated labels from examples and tests.

* Use `maps.Copy()`; replace `< len()` loops with `range` loops.
  • Loading branch information
renormalize authored Mar 5, 2025
1 parent 7bcd5b9 commit 9b2b8b7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ If you are looking to try out druid then you can use a [Kind](https://kind.sigs.
<source src="https://github.com/user-attachments/assets/cfe0d891-f709-4d7f-b975-4300c6de67e4" type="video/mp4">
</video>

For detailed documentation, see our `/docs` folder. Please find the [index](README.md) here.
For detailed documentation, see our `/docs` folder. Please find the [index](./README.md) here.

## Contributions

Expand Down
6 changes: 3 additions & 3 deletions docs/monitoring/metrics.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Monitoring

etcd-druid uses [Prometheus][prometheus] for metrics reporting. The metrics can be used for real-time monitoring and debugging of compaction jobs.
etcd-druid uses [Prometheus](https://prometheus.io/) for metrics reporting. The metrics can be used for real-time monitoring and debugging of compaction jobs.

The simplest way to see the available metrics is to cURL the metrics endpoint `/metrics`. The format is described [here](http://prometheus.io/docs/instrumenting/exposition_formats/).

Follow the [Prometheus getting started doc][prometheus-getting-started] to spin up a Prometheus server to collect etcd metrics.
Follow the [Prometheus getting started doc](https://prometheus.io/docs/prometheus/latest/getting_started/) to spin up a Prometheus server to collect etcd metrics.

The naming of metrics follows the suggested [Prometheus best practices][prometheus-naming]. All compaction related metrics are put under namespace `etcddruid` and the respective subsystems.
The naming of metrics follows the suggested [Prometheus best practices](https://prometheus.io/docs/practices/naming/). All compaction related metrics are put under namespace `etcddruid` and the respective subsystems.

## Snapshot Compaction

Expand Down
1 change: 0 additions & 1 deletion examples/objstore-emulator/etcd-secret-azurite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Secret
metadata:
labels:
garden.sapcloud.io/role: controlplane
role: main
name: etcd-backup-azurite
type: Opaque
Expand Down
1 change: 0 additions & 1 deletion examples/objstore-emulator/etcd-secret-localstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ data:
kind: Secret
metadata:
labels:
garden.sapcloud.io/role: controlplane
role: main
name: etcd-backup-aws
type: Opaque
12 changes: 6 additions & 6 deletions internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func GenerateLabelCombinations(labelValues map[string][]string) []map[string]str
output := make([]map[string]string, len(combinations))
for i, combination := range combinations {
labelVals := make(map[string]string, len(labels))
for j := 0; j < len(labels); j++ {
for j := range labels {
labelVals[labels[j]] = combination[j]
}
output[i] = labelVals
Expand All @@ -78,15 +78,15 @@ func getCombinations(valuesList [][]string) [][]string {
// Output => [[p,q,1,2],[p,q,3,4],[r,s,1,2],[r,s,3,4]]
func cartesianProduct(a [][]string, b [][]string) [][]string {
output := make([][]string, len(a)*len(b))
for i := 0; i < len(a); i++ {
for j := 0; j < len(b); j++ {
for i := range a {
for j := range b {
arr := make([]string, len(a[i])+len(b[j]))
ctr := 0
for ii := 0; ii < len(a[i]); ii++ {
for ii := range a[i] {
arr[ctr] = a[i][ii]
ctr++
}
for jj := 0; jj < len(b[j]); jj++ {
for jj := range b[j] {
arr[ctr] = b[j][jj]
ctr++
}
Expand All @@ -101,7 +101,7 @@ func cartesianProduct(a [][]string, b [][]string) [][]string {
// Ex: [p,q,r] -> [[p],[q],[r]]
func wrapInSlice(s []string) [][]string {
output := make([][]string, len(s))
for i := 0; i < len(output); i++ {
for i := range output {
elem := make([]string, 1)
elem[0] = s[i]
output[i] = elem
Expand Down
17 changes: 6 additions & 11 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
"encoding/json"
"fmt"
"maps"
"os"
"path"
"strings"
Expand Down Expand Up @@ -81,14 +82,12 @@ var (
defaultRoleLabelValue = "main"

labels = map[string]string{
"app": "etcd-statefulset",
"garden.sapcloud.io/role": "controlplane",
roleLabelKey: defaultRoleLabelValue,
"app": "etcd-statefulset",
roleLabelKey: defaultRoleLabelValue,
}

stsLabels = map[string]string{
"app": "etcd-statefulset",
"garden.sapcloud.io/role": "controlplane",
roleLabelKey: defaultRoleLabelValue,
"networking.gardener.cloud/to-dns": "allowed",
"networking.gardener.cloud/to-private-networks": "allowed",
Expand Down Expand Up @@ -160,19 +159,15 @@ func getDefaultEtcd(name, namespace, container, prefix string, provider TestProv
etcd.Spec.Annotations = stsAnnotations

labelsCopy := make(map[string]string)
for k, v := range labels {
labelsCopy[k] = v
}
maps.Copy(labelsCopy, labels)
labelsCopy[roleLabelKey] = provider.Suffix
etcd.Labels = labelsCopy
etcd.Spec.Selector = &metav1.LabelSelector{
MatchLabels: labelsCopy,
}

stsLabelsCopy := make(map[string]string)
for k, v := range stsLabels {
stsLabelsCopy[k] = v
}
maps.Copy(stsLabelsCopy, stsLabels)
stsLabelsCopy[roleLabelKey] = provider.Suffix
etcd.Spec.Labels = stsLabelsCopy

Expand Down Expand Up @@ -680,7 +675,7 @@ func getPurgeLocalSnapstoreJob(storeContainer, storePrefix string) *batchv1.Job
)
}

func populateEtcd(ctx context.Context, logger logr.Logger, kubeconfigPath, namespace, etcdName, podName, containerName, keyPrefix, valuePrefix string, startKeyNo, endKeyNo int, delay time.Duration) error {
func populateEtcd(ctx context.Context, logger logr.Logger, kubeconfigPath, namespace, etcdName, podName, containerName, keyPrefix, valuePrefix string, startKeyNo, endKeyNo int, _ time.Duration) error {
var (
cmd string
stdout string
Expand Down

0 comments on commit 9b2b8b7

Please sign in to comment.