Skip to content

Commit

Permalink
Merge pull request #137938 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.3-137897

release-24.3: roachprod/promhelper: remove `node` and `tenant` labels
  • Loading branch information
srosenberg authored Dec 23, 2024
2 parents ed595e2 + 07d3597 commit 4345c16
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions pkg/roachprod/promhelperclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"

"github.com/cockroachdb/cockroach/pkg/roachprod/config"
Expand Down Expand Up @@ -192,10 +191,10 @@ type NodeInfo struct {
// createClusterConfigFile creates the cluster config file per node
func buildCreateRequest(nodes map[int]*NodeInfo, insecure bool) (io.Reader, error) {
configs := make([]*CCParams, 0)
for i, n := range nodes {
for _, n := range nodes {
params := &CCParams{
Targets: []string{n.Target},
Labels: map[string]string{"node": strconv.Itoa(i)},
Labels: map[string]string{},
}
// custom labels - this can override the default labels if needed
for n, v := range n.CustomLabels {
Expand Down
13 changes: 7 additions & 6 deletions pkg/roachprod/promhelperclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -66,11 +65,13 @@ func TestUpdatePrometheusTargets(t *testing.T) {
require.Nil(t, yaml.UnmarshalStrict([]byte(ir.Config), &configs))
require.Len(t, configs, 2)
for _, c := range configs {
nodeID, err := strconv.Atoi(c.Labels["node"])
require.NoError(t, err)
require.Equal(t, nodeInfos[nodeID].Target, c.Targets[0])
for k, v := range nodeInfos[nodeID].CustomLabels {
require.Equal(t, v, c.Labels[k])
if c.Targets[0] == "n1" {
require.Empty(t, nodeInfos[1].CustomLabels)
} else {
require.Equal(t, "n3", c.Targets[0])
for k, v := range nodeInfos[3].CustomLabels {
require.Equal(t, v, c.Labels[k])
}
}
}
return &http.Response{
Expand Down
1 change: 0 additions & 1 deletion pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ func createLabels(v vm.VM) map[string]string {
"host_ip": v.PrivateIP,
"project": v.Project,
"zone": v.Zone,
"tenant": install.SystemInterfaceName,
"job": "cockroachdb",
}
match := regionRegEx.FindStringSubmatch(v.Zone)
Expand Down

0 comments on commit 4345c16

Please sign in to comment.