Skip to content

Commit 9b2b8b7

Browse files
authored
Housekeeping: fix links, remove deprecated labels in examples, use stdlib 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.
1 parent 7bcd5b9 commit 9b2b8b7

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ If you are looking to try out druid then you can use a [Kind](https://kind.sigs.
5555
<source src="https://github.com/user-attachments/assets/cfe0d891-f709-4d7f-b975-4300c6de67e4" type="video/mp4">
5656
</video>
5757

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

6060
## Contributions
6161

docs/monitoring/metrics.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Monitoring
22

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

55
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/).
66

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

9-
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.
9+
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.
1010

1111
## Snapshot Compaction
1212

examples/objstore-emulator/etcd-secret-azurite.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
labels:
5-
garden.sapcloud.io/role: controlplane
65
role: main
76
name: etcd-backup-azurite
87
type: Opaque

examples/objstore-emulator/etcd-secret-localstack.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ data:
99
kind: Secret
1010
metadata:
1111
labels:
12-
garden.sapcloud.io/role: controlplane
1312
role: main
1413
name: etcd-backup-aws
1514
type: Opaque

internal/metrics/metrics.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func GenerateLabelCombinations(labelValues map[string][]string) []map[string]str
5151
output := make([]map[string]string, len(combinations))
5252
for i, combination := range combinations {
5353
labelVals := make(map[string]string, len(labels))
54-
for j := 0; j < len(labels); j++ {
54+
for j := range labels {
5555
labelVals[labels[j]] = combination[j]
5656
}
5757
output[i] = labelVals
@@ -78,15 +78,15 @@ func getCombinations(valuesList [][]string) [][]string {
7878
// Output => [[p,q,1,2],[p,q,3,4],[r,s,1,2],[r,s,3,4]]
7979
func cartesianProduct(a [][]string, b [][]string) [][]string {
8080
output := make([][]string, len(a)*len(b))
81-
for i := 0; i < len(a); i++ {
82-
for j := 0; j < len(b); j++ {
81+
for i := range a {
82+
for j := range b {
8383
arr := make([]string, len(a[i])+len(b[j]))
8484
ctr := 0
85-
for ii := 0; ii < len(a[i]); ii++ {
85+
for ii := range a[i] {
8686
arr[ctr] = a[i][ii]
8787
ctr++
8888
}
89-
for jj := 0; jj < len(b[j]); jj++ {
89+
for jj := range b[j] {
9090
arr[ctr] = b[j][jj]
9191
ctr++
9292
}
@@ -101,7 +101,7 @@ func cartesianProduct(a [][]string, b [][]string) [][]string {
101101
// Ex: [p,q,r] -> [[p],[q],[r]]
102102
func wrapInSlice(s []string) [][]string {
103103
output := make([][]string, len(s))
104-
for i := 0; i < len(output); i++ {
104+
for i := range output {
105105
elem := make([]string, 1)
106106
elem[0] = s[i]
107107
output[i] = elem

test/e2e/utils.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"encoding/json"
1111
"fmt"
12+
"maps"
1213
"os"
1314
"path"
1415
"strings"
@@ -81,14 +82,12 @@ var (
8182
defaultRoleLabelValue = "main"
8283

8384
labels = map[string]string{
84-
"app": "etcd-statefulset",
85-
"garden.sapcloud.io/role": "controlplane",
86-
roleLabelKey: defaultRoleLabelValue,
85+
"app": "etcd-statefulset",
86+
roleLabelKey: defaultRoleLabelValue,
8787
}
8888

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

162161
labelsCopy := make(map[string]string)
163-
for k, v := range labels {
164-
labelsCopy[k] = v
165-
}
162+
maps.Copy(labelsCopy, labels)
166163
labelsCopy[roleLabelKey] = provider.Suffix
167164
etcd.Labels = labelsCopy
168165
etcd.Spec.Selector = &metav1.LabelSelector{
169166
MatchLabels: labelsCopy,
170167
}
171168

172169
stsLabelsCopy := make(map[string]string)
173-
for k, v := range stsLabels {
174-
stsLabelsCopy[k] = v
175-
}
170+
maps.Copy(stsLabelsCopy, stsLabels)
176171
stsLabelsCopy[roleLabelKey] = provider.Suffix
177172
etcd.Spec.Labels = stsLabelsCopy
178173

@@ -680,7 +675,7 @@ func getPurgeLocalSnapstoreJob(storeContainer, storePrefix string) *batchv1.Job
680675
)
681676
}
682677

683-
func populateEtcd(ctx context.Context, logger logr.Logger, kubeconfigPath, namespace, etcdName, podName, containerName, keyPrefix, valuePrefix string, startKeyNo, endKeyNo int, delay time.Duration) error {
678+
func populateEtcd(ctx context.Context, logger logr.Logger, kubeconfigPath, namespace, etcdName, podName, containerName, keyPrefix, valuePrefix string, startKeyNo, endKeyNo int, _ time.Duration) error {
684679
var (
685680
cmd string
686681
stdout string

0 commit comments

Comments
 (0)