Skip to content

fix(metrics): populate dest_server label (#23246) #23269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025

Conversation

crenshaw-dev
Copy link
Member

@crenshaw-dev crenshaw-dev commented Jun 5, 2025

#21189 simplified app controller behavior by avoiding inferring the app spec.destination.server field when not populated by the user. The refactor replaces that inference with logic that explicitly loads the destination server URL when it's needed.

The original PR missed some spots. One spot was the places where the inferred server URL was used for metrics.

This PR adds logic to populate the server URL for metrics. The costs are complexity and potential performance loss.

When encountering an error getting the server URL, I'm opting to log a warning and push the metric. I think having a metric with an unpopulated label is better than no metric at all.

Testing:

I switched the metrics tests from server-based to name-based destination, and that caused 4 metrics tests to fail, reproducing the issue. I also reproduced the issue locally with these:

curl localhost:8086/metrics | grep dest_server
curl localhost:8086/metrics | grep argocd_app_info

The changes fix the unit tests and the manual test.

Fixes #23246

@crenshaw-dev crenshaw-dev requested a review from a team as a code owner June 5, 2025 02:31
Copy link

bunnyshell bot commented Jun 5, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@crenshaw-dev crenshaw-dev marked this pull request as draft June 5, 2025 03:05
@crenshaw-dev
Copy link
Member Author

Marked as draft because I need to work on the tests

Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@0e95193). Learn more about missing BASE report.
Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
controller/metrics/metrics.go 85.71% 2 Missing and 1 partial ⚠️
cmd/argocd/commands/admin/app.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #23269   +/-   ##
=========================================
  Coverage          ?   59.96%           
=========================================
  Files             ?      342           
  Lines             ?    58573           
  Branches          ?        0           
=========================================
  Hits              ?    35125           
  Misses            ?    20609           
  Partials          ?     2839           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crenshaw-dev crenshaw-dev force-pushed the fix-dest-cluster-label branch from bd4c240 to 2104ea2 Compare June 5, 2025 15:14
@crenshaw-dev crenshaw-dev force-pushed the fix-dest-cluster-label branch from 2104ea2 to d4ba3dc Compare June 6, 2025 15:58
Signed-off-by: Michael Crenshaw <[email protected]>
@@ -40,7 +44,7 @@ metadata:
spec:
destination:
namespace: dummy-namespace
server: https://localhost:6443
name: cluster1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the test apps to destination name to force the logic that calculates dest_server based on name.

@crenshaw-dev
Copy link
Member Author

/cherry-pick release-3.0

@crenshaw-dev crenshaw-dev marked this pull request as ready for review June 6, 2025 16:18
@crenshaw-dev crenshaw-dev merged commit 36f91a0 into argoproj:master Jun 6, 2025
31 checks passed
Copy link

Cherry-pick failed with Merge error 36f91a0231efe959ed229b553a82ea7cae56673c into temp-cherry-pick-d6bcbe-release-3.0

crenshaw-dev added a commit that referenced this pull request Jun 6, 2025
philippemerle pushed a commit to philippemerle/argoproj-argo-cd that referenced this pull request Jun 7, 2025
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

argocd_app_reconcile_count{dest_server} missing in 3.0.5
2 participants