Skip to content

cluster: fix Grafana VM datasource replacement - #2732

Merged
bb7133 merged 1 commit into
pingcap:masterfrom
Defined2014:fix/grafana-vm-test-cluster-datasource
Aug 27, 2026
Merged

cluster: fix Grafana VM datasource replacement#2732
bb7133 merged 1 commit into
pingcap:masterfrom
Defined2014:fix/grafana-vm-test-cluster-datasource

Conversation

@Defined2014

@Defined2014 Defined2014 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

close #xxx

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

Summary by CodeRabbit

  • Bug Fixes

    • Fixed dashboard provisioning so cluster names and datasource references are replaced correctly.
    • Prevented datasource names containing cluster names from being rewritten twice.
    • Ensured dashboard annotations and datasource configurations consistently use the provisioned datasource name.
  • Tests

    • Improved coverage for dashboard provisioning and datasource replacement scenarios.

@ti-chi-bot
ti-chi-bot Bot requested review from breezewish and kaaaaaaang August 27, 2026 02:55
@pingcap-cla-assistant

pingcap-cla-assistant Bot commented Aug 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 12bc07f0-8b0d-4178-b913-4494d49492f1

📥 Commits

Reviewing files that changed from the base of the PR and between 1286447 and eea1b10.

📒 Files selected for processing (1)
  • pkg/cluster/spec/grafana_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Grafana dashboard replacement now processes cluster placeholders before datasource placeholders. Tests model the replacement commands and verify dashboard references resolve to test-cluster-vm without duplicate suffixes.

Changes

Grafana datasource replacement

Layer / File(s) Summary
Placeholder replacement ordering
pkg/cluster/spec/grafana.go
Cluster-name placeholders are replaced before datasource placeholders.
Dashboard replacement validation
pkg/cluster/spec/grafana_test.go
The test models the replacement commands, covers annotation datasource references, and verifies dashboard and datasource configuration values. The test rejects test-cluster-vm-vm.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to eea1b

This PR makes a localized Grafana VM datasource replacement change with accompanying unit-test updates. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: breezewish, kaaaaaaang

Poem

A rabbit checks the dashboard glow
Cluster names now cleanly flow
No doubled suffix trails behind
The datasource stays well-defined
Tests hop through commands with care

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description follows the template and records the unit test and release-note status, but the problem statement uses the placeholder "close #xxx" and the required change summary is empty. Replace "close #xxx" with the relevant issue reference and summary, if applicable. Describe the Grafana datasource replacement bug, the implementation, and how the unit test verifies the fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the Grafana VM datasource replacement fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.33%. Comparing base (9f6ebb7) to head (eea1b10).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2732      +/-   ##
==========================================
- Coverage   42.43%   42.33%   -0.10%     
==========================================
  Files         426      426              
  Lines       47364    47364              
==========================================
- Hits        20096    20050      -46     
- Misses      24570    24614      +44     
- Partials     2698     2700       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot

ti-chi-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@nolouch: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@bb7133 bb7133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The production ordering change fixes the test-cluster-vm-vm rewrite, but the new regression test introduces a deterministic failure on macOS. Please make the test portable before merging.

Comment thread pkg/cluster/spec/grafana_test.go Outdated
}
return nil, nil, nil

output, err := osexec.CommandContext(ctx, "sh", "-c", cmd).CombinedOutput()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P1] Keep this test portable across supported developer platforms. This executes the Linux-targeted dashboard command on the host. On macOS, BSD sed -i requires a backup suffix, unlike GNU sed; the find -exec invocation still exits successfully, all dashboard substitutions remain unchanged, and the assertions below fail. I reproduced this on exact head 6825fcc9 with go test ./pkg/cluster/spec -run 'TestVictoriaMetricsDefaultDatasource|TestGrafanaDatasourceConfig' -count=1 -v. Please avoid executing this GNU-specific remote command directly on Darwin (for example, gate the command-level test to Linux explicitly, or use a portable test helper/mock that preserves and verifies the production command order).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@Defined2014
Defined2014 force-pushed the fix/grafana-vm-test-cluster-datasource branch from 1286447 to eea1b10 Compare August 27, 2026 04:58
bb7133

This comment was marked as outdated.

@ti-chi-bot ti-chi-bot Bot added the lgtm label Aug 27, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-08-27 04:08:42.52293535 +0000 UTC m=+733957.694029451: ✖️🔁 reset by bb7133.
  • 2026-08-27 06:39:29.61693229 +0000 UTC m=+743004.788026448: ☑️ agreed by bb7133.

@Defined2014

Copy link
Copy Markdown
Contributor Author

/approve

@ti-chi-bot

ti-chi-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Defined2014
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Defined2014

Copy link
Copy Markdown
Contributor Author

/merge

@bb7133
bb7133 merged commit 17b30ee into pingcap:master Aug 27, 2026
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants