Skip to content

Commit 2cb07a1

Browse files
authored
Merge pull request #787 from grafana/krajo/merge-upstream
Sync upstream at current HEAD af2a1cb
2 parents aa96f2e + e31dc94 commit 2cb07a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1737
-1041
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2020
- name: Install Go
21-
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
21+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
2222
with:
2323
go-version: 1.23.x
2424
- name: Install snmp_exporter/generator dependencies

.github/workflows/ui_build_and_release.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,9 @@ var (
14291429

14301430
// OTLPConfig is the configuration for writing to the OTLP endpoint.
14311431
type OTLPConfig struct {
1432-
PromoteResourceAttributes []string `yaml:"promote_resource_attributes,omitempty"`
1433-
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
1432+
PromoteResourceAttributes []string `yaml:"promote_resource_attributes,omitempty"`
1433+
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
1434+
KeepIdentifyingResourceAttributes bool `yaml:"keep_identifying_resource_attributes,omitempty"`
14341435
}
14351436

14361437
// UnmarshalYAML implements the yaml.Unmarshaler interface.

config/config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,20 @@ func TestOTLPSanitizeResourceAttributes(t *testing.T) {
15541554
})
15551555
}
15561556

1557+
func TestOTLPAllowServiceNameInTargetInfo(t *testing.T) {
1558+
t.Run("good config", func(t *testing.T) {
1559+
want, err := LoadFile(filepath.Join("testdata", "otlp_allow_keep_identifying_resource_attributes.good.yml"), false, promslog.NewNopLogger())
1560+
require.NoError(t, err)
1561+
1562+
out, err := yaml.Marshal(want)
1563+
require.NoError(t, err)
1564+
var got Config
1565+
require.NoError(t, yaml.UnmarshalStrict(out, &got))
1566+
1567+
require.True(t, got.OTLPConfig.KeepIdentifyingResourceAttributes)
1568+
})
1569+
}
1570+
15571571
func TestOTLPAllowUTF8(t *testing.T) {
15581572
t.Run("good config", func(t *testing.T) {
15591573
fpath := filepath.Join("testdata", "otlp_allow_utf8.good.yml")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
otlp:
2+
keep_identifying_resource_attributes: true

discovery/consul/consul.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (d *Discovery) shouldWatch(name string, tags []string) bool {
241241
return d.shouldWatchFromName(name) && d.shouldWatchFromTags(tags)
242242
}
243243

244-
// shouldWatch returns whether the service of the given name should be watched based on its name.
244+
// shouldWatchFromName returns whether the service of the given name should be watched based on its name.
245245
func (d *Discovery) shouldWatchFromName(name string) bool {
246246
// If there's no fixed set of watched services, we watch everything.
247247
if len(d.watchedServices) == 0 {
@@ -256,7 +256,7 @@ func (d *Discovery) shouldWatchFromName(name string) bool {
256256
return false
257257
}
258258

259-
// shouldWatch returns whether the service of the given name should be watched based on its tags.
259+
// shouldWatchFromTags returns whether the service of the given name should be watched based on its tags.
260260
// This gets called when the user doesn't specify a list of services in order to avoid watching
261261
// *all* services. Details in https://github.com/prometheus/prometheus/pull/3814
262262
func (d *Discovery) shouldWatchFromTags(tags []string) bool {

discovery/kubernetes/endpoints_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func makeEndpoints() *v1.Endpoints {
9797
}
9898

9999
func TestEndpointsDiscoveryBeforeRun(t *testing.T) {
100+
t.Parallel()
100101
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{})
101102

102103
k8sDiscoveryTest{
@@ -151,6 +152,7 @@ func TestEndpointsDiscoveryBeforeRun(t *testing.T) {
151152
}
152153

153154
func TestEndpointsDiscoveryAdd(t *testing.T) {
155+
t.Parallel()
154156
obj := &v1.Pod{
155157
ObjectMeta: metav1.ObjectMeta{
156158
Name: "testpod",
@@ -276,6 +278,7 @@ func TestEndpointsDiscoveryAdd(t *testing.T) {
276278
}
277279

278280
func TestEndpointsDiscoveryDelete(t *testing.T) {
281+
t.Parallel()
279282
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{}, makeEndpoints())
280283

281284
k8sDiscoveryTest{
@@ -294,6 +297,7 @@ func TestEndpointsDiscoveryDelete(t *testing.T) {
294297
}
295298

296299
func TestEndpointsDiscoveryUpdate(t *testing.T) {
300+
t.Parallel()
297301
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{}, makeEndpoints())
298302

299303
k8sDiscoveryTest{
@@ -365,6 +369,7 @@ func TestEndpointsDiscoveryUpdate(t *testing.T) {
365369
}
366370

367371
func TestEndpointsDiscoveryEmptySubsets(t *testing.T) {
372+
t.Parallel()
368373
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{}, makeEndpoints())
369374

370375
k8sDiscoveryTest{
@@ -393,6 +398,7 @@ func TestEndpointsDiscoveryEmptySubsets(t *testing.T) {
393398
}
394399

395400
func TestEndpointsDiscoveryWithService(t *testing.T) {
401+
t.Parallel()
396402
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{}, makeEndpoints())
397403

398404
k8sDiscoveryTest{
@@ -458,6 +464,7 @@ func TestEndpointsDiscoveryWithService(t *testing.T) {
458464
}
459465

460466
func TestEndpointsDiscoveryWithServiceUpdate(t *testing.T) {
467+
t.Parallel()
461468
n, c := makeDiscovery(RoleEndpoint, NamespaceDiscovery{}, makeEndpoints())
462469

463470
k8sDiscoveryTest{
@@ -538,6 +545,7 @@ func TestEndpointsDiscoveryWithServiceUpdate(t *testing.T) {
538545
}
539546

540547
func TestEndpointsDiscoveryWithNodeMetadata(t *testing.T) {
548+
t.Parallel()
541549
metadataConfig := AttachMetadataConfig{Node: true}
542550
nodeLabels1 := map[string]string{"az": "us-east1"}
543551
nodeLabels2 := map[string]string{"az": "us-west2"}
@@ -611,6 +619,7 @@ func TestEndpointsDiscoveryWithNodeMetadata(t *testing.T) {
611619
}
612620

613621
func TestEndpointsDiscoveryWithUpdatedNodeMetadata(t *testing.T) {
622+
t.Parallel()
614623
nodeLabels1 := map[string]string{"az": "us-east1"}
615624
nodeLabels2 := map[string]string{"az": "us-west2"}
616625
node1 := makeNode("foobar", "", "", nodeLabels1, nil)
@@ -688,6 +697,7 @@ func TestEndpointsDiscoveryWithUpdatedNodeMetadata(t *testing.T) {
688697
}
689698

690699
func TestEndpointsDiscoveryNamespaces(t *testing.T) {
700+
t.Parallel()
691701
epOne := makeEndpoints()
692702
epOne.Namespace = "ns1"
693703
objs := []runtime.Object{
@@ -839,6 +849,7 @@ func TestEndpointsDiscoveryNamespaces(t *testing.T) {
839849
}
840850

841851
func TestEndpointsDiscoveryOwnNamespace(t *testing.T) {
852+
t.Parallel()
842853
epOne := makeEndpoints()
843854
epOne.Namespace = "own-ns"
844855

@@ -933,6 +944,7 @@ func TestEndpointsDiscoveryOwnNamespace(t *testing.T) {
933944
}
934945

935946
func TestEndpointsDiscoveryEmptyPodStatus(t *testing.T) {
947+
t.Parallel()
936948
ep := makeEndpoints()
937949
ep.Namespace = "ns"
938950

@@ -978,6 +990,7 @@ func TestEndpointsDiscoveryEmptyPodStatus(t *testing.T) {
978990
// TestEndpointsDiscoveryUpdatePod makes sure that Endpoints discovery detects underlying Pods changes.
979991
// See https://github.com/prometheus/prometheus/issues/11305 for more details.
980992
func TestEndpointsDiscoveryUpdatePod(t *testing.T) {
993+
t.Parallel()
981994
pod := &v1.Pod{
982995
ObjectMeta: metav1.ObjectMeta{
983996
Name: "testpod",
@@ -1097,6 +1110,7 @@ func TestEndpointsDiscoveryUpdatePod(t *testing.T) {
10971110
}
10981111

10991112
func TestEndpointsDiscoverySidecarContainer(t *testing.T) {
1113+
t.Parallel()
11001114
objs := []runtime.Object{
11011115
&v1.Endpoints{
11021116
ObjectMeta: metav1.ObjectMeta{

discovery/kubernetes/endpointslice_adaptor_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
)
2222

2323
func Test_EndpointSliceAdaptor_v1(t *testing.T) {
24+
t.Parallel()
2425
endpointSlice := makeEndpointSliceV1()
2526
adaptor := newEndpointSliceAdaptorFromV1(endpointSlice)
2627

discovery/kubernetes/endpointslice_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func makeEndpointSliceV1() *v1.EndpointSlice {
114114
}
115115

116116
func TestEndpointSliceDiscoveryBeforeRun(t *testing.T) {
117+
t.Parallel()
117118
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}})
118119

119120
k8sDiscoveryTest{
@@ -195,6 +196,7 @@ func TestEndpointSliceDiscoveryBeforeRun(t *testing.T) {
195196
}
196197

197198
func TestEndpointSliceDiscoveryAdd(t *testing.T) {
199+
t.Parallel()
198200
obj := &corev1.Pod{
199201
ObjectMeta: metav1.ObjectMeta{
200202
Name: "testpod",
@@ -322,6 +324,7 @@ func TestEndpointSliceDiscoveryAdd(t *testing.T) {
322324
}
323325

324326
func TestEndpointSliceDiscoveryDelete(t *testing.T) {
327+
t.Parallel()
325328
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}}, makeEndpointSliceV1())
326329

327330
k8sDiscoveryTest{
@@ -340,6 +343,7 @@ func TestEndpointSliceDiscoveryDelete(t *testing.T) {
340343
}
341344

342345
func TestEndpointSliceDiscoveryUpdate(t *testing.T) {
346+
t.Parallel()
343347
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}}, makeEndpointSliceV1())
344348

345349
k8sDiscoveryTest{
@@ -396,6 +400,7 @@ func TestEndpointSliceDiscoveryUpdate(t *testing.T) {
396400
}
397401

398402
func TestEndpointSliceDiscoveryEmptyEndpoints(t *testing.T) {
403+
t.Parallel()
399404
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}}, makeEndpointSliceV1())
400405

401406
k8sDiscoveryTest{
@@ -424,6 +429,7 @@ func TestEndpointSliceDiscoveryEmptyEndpoints(t *testing.T) {
424429
}
425430

426431
func TestEndpointSliceDiscoveryWithService(t *testing.T) {
432+
t.Parallel()
427433
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}}, makeEndpointSliceV1())
428434

429435
k8sDiscoveryTest{
@@ -516,6 +522,7 @@ func TestEndpointSliceDiscoveryWithService(t *testing.T) {
516522
}
517523

518524
func TestEndpointSliceDiscoveryWithServiceUpdate(t *testing.T) {
525+
t.Parallel()
519526
n, c := makeDiscovery(RoleEndpointSlice, NamespaceDiscovery{Names: []string{"default"}}, makeEndpointSliceV1())
520527

521528
k8sDiscoveryTest{
@@ -623,6 +630,7 @@ func TestEndpointSliceDiscoveryWithServiceUpdate(t *testing.T) {
623630
}
624631

625632
func TestEndpointsSlicesDiscoveryWithNodeMetadata(t *testing.T) {
633+
t.Parallel()
626634
metadataConfig := AttachMetadataConfig{Node: true}
627635
nodeLabels1 := map[string]string{"az": "us-east1"}
628636
nodeLabels2 := map[string]string{"az": "us-west2"}
@@ -722,6 +730,7 @@ func TestEndpointsSlicesDiscoveryWithNodeMetadata(t *testing.T) {
722730
}
723731

724732
func TestEndpointsSlicesDiscoveryWithUpdatedNodeMetadata(t *testing.T) {
733+
t.Parallel()
725734
metadataConfig := AttachMetadataConfig{Node: true}
726735
nodeLabels1 := map[string]string{"az": "us-east1"}
727736
nodeLabels2 := map[string]string{"az": "us-west2"}
@@ -827,6 +836,7 @@ func TestEndpointsSlicesDiscoveryWithUpdatedNodeMetadata(t *testing.T) {
827836
}
828837

829838
func TestEndpointSliceDiscoveryNamespaces(t *testing.T) {
839+
t.Parallel()
830840
epOne := makeEndpointSliceV1()
831841
epOne.Namespace = "ns1"
832842
objs := []runtime.Object{
@@ -1003,6 +1013,7 @@ func TestEndpointSliceDiscoveryNamespaces(t *testing.T) {
10031013
}
10041014

10051015
func TestEndpointSliceDiscoveryOwnNamespace(t *testing.T) {
1016+
t.Parallel()
10061017
epOne := makeEndpointSliceV1()
10071018
epOne.Namespace = "own-ns"
10081019

@@ -1123,6 +1134,7 @@ func TestEndpointSliceDiscoveryOwnNamespace(t *testing.T) {
11231134
}
11241135

11251136
func TestEndpointSliceDiscoveryEmptyPodStatus(t *testing.T) {
1137+
t.Parallel()
11261138
ep := makeEndpointSliceV1()
11271139
ep.Namespace = "ns"
11281140

@@ -1169,6 +1181,7 @@ func TestEndpointSliceDiscoveryEmptyPodStatus(t *testing.T) {
11691181
// sets up indexing for the main Kube informer only when needed.
11701182
// See: https://github.com/prometheus/prometheus/pull/13554#discussion_r1490965817
11711183
func TestEndpointSliceInfIndexersCount(t *testing.T) {
1184+
t.Parallel()
11721185
tests := []struct {
11731186
name string
11741187
withNodeMetadata bool
@@ -1179,6 +1192,7 @@ func TestEndpointSliceInfIndexersCount(t *testing.T) {
11791192

11801193
for _, tc := range tests {
11811194
t.Run(tc.name, func(t *testing.T) {
1195+
t.Parallel()
11821196
var (
11831197
n *Discovery
11841198
mainInfIndexersCount int
@@ -1204,6 +1218,7 @@ func TestEndpointSliceInfIndexersCount(t *testing.T) {
12041218
}
12051219

12061220
func TestEndpointSliceDiscoverySidecarContainer(t *testing.T) {
1221+
t.Parallel()
12071222
objs := []runtime.Object{
12081223
&v1.EndpointSlice{
12091224
ObjectMeta: metav1.ObjectMeta{

discovery/kubernetes/ingress_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func expectedTargetGroups(ns string, tls TLSMode) map[string]*targetgroup.Group
144144
}
145145

146146
func TestIngressDiscoveryAdd(t *testing.T) {
147+
t.Parallel()
147148
n, c := makeDiscovery(RoleIngress, NamespaceDiscovery{Names: []string{"default"}})
148149

149150
k8sDiscoveryTest{
@@ -158,6 +159,7 @@ func TestIngressDiscoveryAdd(t *testing.T) {
158159
}
159160

160161
func TestIngressDiscoveryAddTLS(t *testing.T) {
162+
t.Parallel()
161163
n, c := makeDiscovery(RoleIngress, NamespaceDiscovery{Names: []string{"default"}})
162164

163165
k8sDiscoveryTest{
@@ -172,6 +174,7 @@ func TestIngressDiscoveryAddTLS(t *testing.T) {
172174
}
173175

174176
func TestIngressDiscoveryAddMixed(t *testing.T) {
177+
t.Parallel()
175178
n, c := makeDiscovery(RoleIngress, NamespaceDiscovery{Names: []string{"default"}})
176179

177180
k8sDiscoveryTest{
@@ -186,6 +189,7 @@ func TestIngressDiscoveryAddMixed(t *testing.T) {
186189
}
187190

188191
func TestIngressDiscoveryNamespaces(t *testing.T) {
192+
t.Parallel()
189193
n, c := makeDiscovery(RoleIngress, NamespaceDiscovery{Names: []string{"ns1", "ns2"}})
190194

191195
expected := expectedTargetGroups("ns1", TLSNo)
@@ -207,6 +211,7 @@ func TestIngressDiscoveryNamespaces(t *testing.T) {
207211
}
208212

209213
func TestIngressDiscoveryOwnNamespace(t *testing.T) {
214+
t.Parallel()
210215
n, c := makeDiscovery(RoleIngress, NamespaceDiscovery{IncludeOwnNamespace: true})
211216

212217
expected := expectedTargetGroups("own-ns", TLSNo)

0 commit comments

Comments
 (0)