Commit graph

725 commits

Author SHA1 Message Date
beorn7 0f760f63dd lint: Revamp our linting rules, mostly around doc comments
Several things done here:

- Set `max-issues-per-linter` to 0 so that we actually see all linter
  warnings and not just 50 per linter. (As we also set
  `max-same-issues` to 0, I assume this was the intention from the
  beginning.)

- Stop using the golangci-lint default excludes (by setting
  `exclude-use-default: false`. Those are too generous and don't match
  our style conventions. (I have re-added some of the excludes
  explicitly in this commit. See below.)

- Re-add the `errcheck` exclusion we have used so far via the
  defaults.

- Exclude the signature requirement `govet` has for `Seek` methods
  because we use non-standard `Seek` methods a lot. (But we keep other
  requirements, while the default excludes completely disabled the
  check for common method segnatures.)

- Exclude warnings about missing doc comments on exported symbols. (We
  used to be pretty adamant about doc comments, but stopped that at
  some point in the past. By now, we have about 500 missing doc
  comments. We may consider reintroducing this check, but that's
  outside of the scope of this commit. The default excludes of
  golangci-lint essentially ignore doc comments completely.)

- By stop using the default excludes, we now get warnings back on
  malformed doc comments. That's the most impactful change in this
  commit. It does not enforce doc comments (again), but _if_ there is
  a doc comment, it has to have the recommended form. (Most of the
  changes in this commit are fixing this form.)

- Improve wording/spelling of some comments in .golangci.yml, and
  remove an outdated comment.

- Leave `package-comments` inactive, but add a TODO asking if we
  should change that.

- Add a new sub-linter `comment-spacings` (and fix corresponding
  comments), which avoids missing spaces after the leading `//`.

Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 17:36:11 +02:00
Arve Knudsen 3a78e76282 Upgrade golangci-lint to v1.60.1
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2024-08-18 12:13:25 +02:00
cuiweiyuan 1800af54f0 chore: fix some function names
Signed-off-by: cuiweiyuan <cuiweiyuan@aliyun.com>
2024-08-15 13:57:21 +08:00
Bryan Boreham 79a0ba9d64
Merge pull request #13503 from tylitianrui/chore/remove_redundance
remove redundant code
2024-07-30 12:44:03 +01:00
Bryan Boreham ce3bd4abea Update for Docker deprecation
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-07-17 17:03:32 +01:00
Paulo Dias f4b1fcb73e
discovery: add support for gathering flavor name in Openstack discovery (#14312)
* feat: add support for gathering flavor name in Openstack discovery

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>

* Update instance.go

Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
Signed-off-by: Paulo Dias <44772900+paulojmdias@users.noreply.github.com>

* Update configuration.md

Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
Signed-off-by: Paulo Dias <44772900+paulojmdias@users.noreply.github.com>

* fix: fix linting

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>

* fix: fix instance type

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>

* Update docs/configuration/configuration.md

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Paulo Dias <44772900+paulojmdias@users.noreply.github.com>

---------

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <44772900+paulojmdias@users.noreply.github.com>
Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2024-06-30 19:18:18 +02:00
Bryan Boreham c5040c5ea9
Merge pull request #10490 from DrAuYueng/fix-docker-sd-service-missing
[ENHANCEMENT] Docker SD: add MatchFirstNetwork for containers with multiple networks

Fixes docker sd service misssing in shared mode and deduplicate targets by network
2024-06-26 12:33:50 +01:00
Arve Knudsen d902116b41 Fix various linting errors
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2024-06-24 16:11:53 -07:00
unknown 0d25931049 rebase main and adjust the configuration
Signed-off-by: ouyang1204@gmail.com <ouyang1204@gmail.com>
2024-06-21 19:10:18 +08:00
akunszt 2aaf99dd0a
discovery: aws: expose Primary IPv6 addresses as label, partially fixes #7406 (#14156)
* discovery: aws: expose Primary IPv6 addresses as label

Add __meta_ec2_primary_ipv6_addresses label. This label contains the
Primary IPv6 address for every ENI attached to the EC2 instance. It is
ordered by the DeviceIndex and the missing elements (interface without
Primary IPv6 address) are kept in the list.

---------

Signed-off-by: Arpad Kunszt <akunszt@hiya.com>
Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
2024-06-20 14:36:20 +01:00
machine424 94d28cd6cf chore(notifier): add a reproducer for https://github.com/prometheus/prometheus/issues/13676
to show "targets groups update" starvation when the notifications queue is full and an Alertmanager
is down.

The existing `TestHangingNotifier` that was added in https://github.com/prometheus/prometheus/pull/10948 doesn't really reflect the reality as the SD changes are manually fed into `syncCh` in a continuous way, whereas in reality, updates are only resent every `updatert`.

The test added here sets up an SD manager and links it to the notifier. The SD changes will be triggered by that manager as it's done in reality.

Signed-off-by: machine424 <ayoubmrini424@gmail.com>

Co-authored-by: Ethan Hunter <ehunter@hudson-trading.com>
2024-06-19 09:43:52 +02:00
György Krajcsovits b18e2d3ef6 Format linter pragma correctly
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-06-05 16:50:09 +02:00
György Krajcsovits 180059e6fa Update scaleway-sdk-go and silence deprecation warnings
This reverts commit 777daea86e.
2024-06-05 16:37:58 +02:00
György Krajcsovits 0ee4cf8d94 Update Go dependencies for 2.53
Ran "make update-all-go-deps" , but do not bump go version and remove
toolchain clause from go.mod


Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-06-04 18:02:21 +02:00
Arthur Silva Sens d73537ccc0
Merge branch 'main' into resolveconflicts-2.52.1 2024-05-31 09:36:17 -03:00
David Andruczyk 851f68d1cc BUGFIX: Need seperate listOptions structs since linodego writes into them for pagination
Signed-off-by: David Andruczyk <dandrucz@akamai.com>
2024-05-27 17:19:58 +00:00
Oleksandr Redko f10c3454e9 Enable perfsprint linter and fix up code
Signed-off-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
2024-05-15 17:51:05 +03:00
Julien ed4e50e792
Merge pull request #13992 from heckler1/heckler1/discovery-client-go
discovery(k8s): Only register client-go metrics adapters when needed
2024-04-29 11:18:49 +02:00
Heyoxe f7e923c3bb
fix(scaleway-sd): use public IPs if no private IP present (#13941)
* fix(scaleway-sd): use public IPs if no private IP present
* tests(scaleway-sd): add instance  with routed public ip and no private ip

---------

Signed-off-by: Heyoxe <32708033+Heyoxe@users.noreply.github.com>
2024-04-27 15:01:30 +01:00
Stephen Heckler 31a4217784 discovery(k8s): Only register client-go metrics adapters when needed
Previously the metrics adapters for client-go were registered in an init function.
This resulted in clobbering default metrics providers when these packages are imported
into an application that leverages the default client-go metrics registry.

Instead, let's only register these adapters when requested.

Signed-off-by: Stephen Heckler <sheckler@cloudflare.com>
2024-04-25 12:33:29 -05:00
Simon Pasquier 7704cde4ea
discovery(k8s): add metadata labels to endpointslices
This commit adds 2 new metadata labels for the endpointslice role:
* `__meta_kubernetes_endpointslice_endpoint_node_name`
* `__meta_kubernetes_endpointslice_endpoint_zone`

The latter is only present when the `discovery.k8s.io/v1` API group is
available.

I also updated the configuration doc and added an entry for the
`__meta_kubernetes_endpointslice_endpoint_hostname` label which was
missing.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-04-17 11:20:19 +02:00
Matthieu MOREL 6f595c6762
golangci-lint: enable whitespace linter (#13905)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-04-11 09:27:54 +01:00
Bryan Boreham 594b317ecc
Merge pull request #13898 from hanghuge/main
[DOCS] Fix unavailable link to Kubernetes docs
2024-04-10 11:52:12 +01:00
Matthieu MOREL d496687c8e golangci-lint: enable usestdlibvars linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-04-08 19:26:23 +00:00
hanghuge c14a158d03 Signed-off-by: hanghuge <cmoman@outlook.com>
Fix unavailable link

Signed-off-by: hanghuge <cmoman@outlook.com>
2024-04-08 18:44:22 +08:00
David Ashpole bbfc72b4e2
support unregistering discovery manager metrics (#13896)
Signed-off-by: David Ashpole <dashpole@google.com>
2024-04-05 16:19:07 +02:00
dandrucz 38b75bc0d7
Linode IPv6 Range support, Optional region filtering, Missing fields in Documentation fixed (#13774)
* Add support for discovering Linode IPv6 ranges associated with linodes.
* Add optional but recommended region filtering (faster queries, more relevant information).
* Added missing fields in configuration.md, updated linode test cases.
* Convert to TableDrivenTests as per tjhop request.

Signed-off-by: David Andruczyk <dandrucz@akamai.com>
2024-04-05 09:31:59 +01:00
Bryan Boreham 8799581b24
Merge pull request #13554 from machine424/k8s-failures
discovery(k8s): add metric prometheus_sd_kubernetes_failures_total
2024-04-04 10:43:44 +01:00
Bryan Boreham c6a42f8891
Merge pull request #13741 from bboreham/azure-test-labels
Azure Discovery tests: Add test for mapping VMs to labels
2024-03-27 11:36:17 +01:00
sellskin ff15b17400 remove code that will not be executed
Signed-off-by: sellskin <mydesk@yeah.net>
2024-03-25 12:18:33 +08:00
Jan-Otto Kröpke 302e151de8
{discovery,remote_write}/azure: Support default SDK authentication (#13099)
* discovery/azure: Offer default SDK authentication

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-03-16 11:06:57 +00:00
Bryan Boreham ab9c544ec7 Azure Discovery tests: Add test for VMToLabelSet
Test fails due to bug in code on main.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-03-12 15:04:09 +00:00
Bryan Boreham 5f2c0c5283 Azure Discovery tests: mock the azure client interface
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-03-12 15:04:09 +00:00
Bryan Boreham 4e24e5b1d1 Refactor: Azure Discovery: introduce an interface for the client
So we can mock it.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-03-12 15:04:09 +00:00
Bryan Boreham b8d428b753 Refactor: Azure Discovery: extract function to generate labelSet
This should make it easier to test.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-03-12 15:04:04 +00:00
michaelact eea6ab1cdd
[BUGFIX] Azure SD: Fix 'error: parameter virtualMachineScaleSetName cannot be empty' (#13702)
Erroneous code was introduced during a merge-back-to-main at #13399.

Signed-off-by: michaelact <86778470+michaelact@users.noreply.github.com>
2024-03-08 15:19:39 +00:00
machine424 0e81ab44a2
discovery(k8s): add a metric to track failed requests, failures will still be logged.
Signed-off-by: machine424 <ayoubmrini424@gmail.com>
2024-02-28 19:55:46 +01:00
Björn Rabenstein dbb4055633
Merge pull request #13593 from machine424/no-index
discovery: kubernetes: Avoid creating unnecessary Kubernetes indexers…
2024-02-27 10:48:37 +01:00
Augustin Husson 9738e48a7d
Merge pull request #13629 from prometheus/release-2.50
merge back release 2.50
2024-02-22 11:07:52 +01:00
machine424 92544c00bf
discovery: kubernetes: Avoid creating unnecessary Kubernetes indexers in RoleEndpointSlice
This was due to a missing "return", see https://github.com/prometheus/prometheus/pull/13554#discussion_r1490965817

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
2024-02-16 14:29:28 +01:00
Darshan Chaudhary 0e8a2e44a4
Azure SD: check for nil before accessing and dereferencing (#13578)
Signed-off-by: darshanime <deathbullet@gmail.com>
2024-02-14 17:59:01 +01:00
Bryan Boreham 6005ac6f9d
Merge pull request #9311 from Creatone/creatone/use-testify-3
tests: Move from t.Errorf and others. (Part 3)
2024-02-05 18:48:59 +01:00
Bryan Boreham 857138d3ce review feedback
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-02-04 15:52:50 +01:00
Bryan Boreham b17f88b7fb consul sd tests: don't call FailNow from a background goroutine
This is not allowed by the Go test framework.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-02-01 15:15:48 +00:00
Bryan Boreham 46008fdecd lint
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2024-02-01 14:57:11 +00:00
Ayoub Mrini 581d8d86b4
Pod status changes not discovered by Kube Endpoints SD (#13337)
* fix(discovery/kubernetes/endpoints): react to changes on Pods because some modifications can occur on them without triggering an update on the related Endpoints (The Pod phase changing from Pending to Running e.g.).

---------

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
Co-authored-by: Guillermo Sanchez Gavier <gsanchez@newrelic.com>
2024-02-01 12:34:37 +00:00
Paweł Szulik 7f24efccdb Refactor discovery tests to use testify.
Signed-off-by: Paweł Szulik <paul.szulik@gmail.com>
2024-01-31 16:42:11 +00:00
tyltr b538919258 remove redundant code
Signed-off-by: tyltr <tylitianrui@126.com>
2024-01-31 20:27:23 +08:00
Julien Pivotto 960b6266e2
Merge pull request #13447 from ptodev/update-puppetdb-metric-label
Change metric label for Puppet SD from 'http' to 'puppetdb'
2024-01-26 15:40:15 +01:00
Augustin Husson 9a9e73b34a
update all go dependencies (#13438)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
2024-01-24 16:53:32 +01:00