Skip to content

fix(resource_dashboard): force recreate grafana_dashboard if uid changes #2145

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 22 commits into from
Aug 14, 2025

Conversation

paulojmdias
Copy link
Contributor

@paulojmdias paulojmdias commented Apr 24, 2025

Fixes: #2144

  • Tests before the change
❯ TF_ACC=true TF_ACC_OSS=true GRAFANA_URL=http://localhost:3000 GRAFANA_AUTH="anonymous" GRAFANA_VERSION=11.6.1 go test -v ./internal/resources/grafana/ -run TestAccDashboard_uid_unset
=== RUN   TestAccDashboard_uid_unset
=== PAUSE TestAccDashboard_uid_unset
=== CONT  TestAccDashboard_uid_unset
    resource_dashboard_test.go:102: Step 2/3 error: Error running apply: exit status 1

         Error: [POST /dashboards/db][404] postDashboardNotFound {"message":"Dashboard not found","status":"not-found"}

          with grafana_dashboard.test,
          on terraform_plugin_test.tf line 3, in resource "grafana_dashboard" "test":
           3: resource "grafana_dashboard" "test" {

--- FAIL: TestAccDashboard_uid_unset (1.21s)
FAIL
FAIL	github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana	2.357s
FAIL
  • Tests after this change
❯ TF_ACC=true TF_ACC_OSS=true GRAFANA_URL=http://localhost:3000 GRAFANA_AUTH="anonymous" GRAFANA_VERSION=11.6.1 go test -v ./internal/resources/grafana/ -run TestAccDashboard_uid_unset
=== RUN   TestAccDashboard_uid_unset
=== PAUSE TestAccDashboard_uid_unset
=== CONT  TestAccDashboard_uid_unset
--- PASS: TestAccDashboard_uid_unset (2.07s)
PASS
ok  	github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana	2.924s

@paulojmdias paulojmdias requested a review from a team as a code owner April 24, 2025 22:57
Copy link
Contributor

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@paulojmdias
Copy link
Contributor Author

Anyone can review this?

@radiohead
Copy link
Contributor

Anyone can review this?

Hey @paulojmdias! Thank you for sending this PR, I'll take a look!

@paulojmdias
Copy link
Contributor Author

Many thanks @radiohead 🙏

Copy link
Contributor

@radiohead radiohead left a comment

Choose a reason for hiding this comment

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

Looks great, thank you! Sorry, I was busy and it took me a while to find time to review this.

@radiohead radiohead enabled auto-merge (squash) August 13, 2025 14:57
@paulojmdias
Copy link
Contributor Author

Thank you @radiohead! 🙌

I think the failed tests should be related with being a fork branch, but please confirm 🙏

@radiohead
Copy link
Contributor

Thank you @radiohead! 🙌

I think the failed tests should be related with being a fork branch, but please confirm 🙏

Yes, you are correct. I'll get it merged in a bit, since everything works as expected and there aren't any differences in the setup for failing tests, so no need to do anything else from your side.

@dylwylie dylwylie disabled auto-merge August 14, 2025 10:29
@radiohead radiohead enabled auto-merge (squash) August 14, 2025 10:46
@suntala suntala disabled auto-merge August 14, 2025 12:25
@suntala suntala merged commit 4b72ca2 into grafana:main Aug 14, 2025
24 of 31 checks passed
@paulojmdias paulojmdias deleted the fix/2144 branch August 14, 2025 13:01
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.

grafana_dashboard produces 404 error if uid changes
3 participants