2111 Commits

Author SHA1 Message Date
8a05378ef3 apiserver/folders: use exact match on GetFolderByTitle in legacy (#106867)
* apiserver/folders: use exact match on GetFolderByTitle in legacy

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>


---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2025-06-24 17:42:08 -03:00
Jo
06278615fb Fix: Increase login_attempt.ip_address column length for IPv6 support (#107035)
* fix: increase login_attempt.ip_address column length for IPv6 support

- Expand ip_address column from VARCHAR(30) to VARCHAR(50) to accommodate IPv6 addresses
- Add database migration with support for PostgreSQL, MySQL, and SQLite
- Add comprehensive integration tests for various IPv6 address formats
- Resolves 500 errors when login fails over IPv6, now returns proper 401 errors

Fixes #106362

* test: add missing test skip to TestIntegrationIPv6AddressSupport

Skip integration test when running with -short flag to separate unit and integration tests

* Update pkg/services/sqlstore/migrations/login_attempt_mig.go

Co-authored-by: Victor Cinaglia <victor@grafana.com>

* fix missing bracket

* fix: resolve PostgreSQL timestamp overflow in IPv6 test

- Use controlled time mock instead of time.Now() to avoid timestamp conversion issues
- Follow existing test patterns with xormStore and mock time functions
- Add proper Since parameter to GetIPLoginAttemptCount query
- Fixes PostgreSQL error: 'pq: value "-62135596800" is out of range for type integer'

* fix: resolve PostgreSQL UTF-8 encoding error in IPv6 test

Replace string(rune(i)) with fmt.Sprintf to avoid null bytes (0x00)
when i=0, which caused 'invalid byte sequence for encoding UTF8' error

---------

Co-authored-by: Victor Cinaglia <victor@grafana.com>
2025-06-24 16:11:45 +02:00
a8886ad5ec Annotations: Use dashboard uids instead of dashboard ids (#106676) 2025-06-13 13:59:24 -05:00
352aac162c Preferences: Use dashboard uid for the home dashboard (#106666) 2025-06-13 07:10:44 -05:00
edb0865caa Chore: Ensure we save correct default admin user in integration test DB setup (#105752)
* fix helper + amend tests

* fix import + remove unused var

* remove more users

* remove unused code

* update test comment
2025-05-28 11:25:01 +01:00
589046bcdc Alerting: Persist alert instance FiredAt field (#105927)
* Persist alert instance fired at

* Update protos and tests
2025-05-27 10:04:26 +01:00
c4d3eb1cd0 Remove support for Google Spanner database. (#105846)
* Remove support for Google Spanner database.
2025-05-23 11:35:59 +02:00
69e657b296 SQLStore: Add index on is_service_account and last_seen_at columns in user table. (#105727)
Add index on is_service_account and last_seen_at columns in user table.
2025-05-21 17:44:44 +03:00
2cddaf0781 RBAC: Remove dashboard and folder guardians (#104646)
* replace usage of folder guardians with access control evaluators

* remove NewByFolderUID guardian

* bring up to date

* fix test

* more test fixes, and don't fetch the folder before evaluating lib element access

* change what error is returned

* fix alerting test

* try to fix linter errors

* replace the use of newByFolder guardian with direct access control evaluator checks

* remove newByFolder guardian

* get rid of dashboard and folder guardians

* undo unwanted change

* undo unwanted change

* undo unwanted change

* update code owners
2025-05-19 09:48:16 +03:00
6b588f4c93 Migrations: Make sure users uid are set (#104996)
* Migrations: Make sure default admin has a uid

* Account for all users not only id 1

* Add spanner

* Wrong migration to add spanner

* Fix spanner mig
2025-05-07 13:40:32 +02:00
694b9dfe50 Chore: Replace xorm.io/xorm imports (#104458)
* replace xorm.io/xorm imports

* replace xorm from other go.mod files

* clean up workspace

* nolint does not make sense anymore as it is not a module

* try if nolint directive helps

* use nolint:all for xorm

* add more nolints

* try to skip xorm in linter config

* exclude xorm differently

* retrigger ci
2025-05-02 17:13:01 +02:00
e85acf047a Remove use of dialect.LikeStr (#104460)
* Fix TestIntegrationUpdatingProvisionionedDashboards* tests when running on Spanner by fixing case-insensitive search for dashboard title.

* Fix use of case-insensitive LIKE when running on Spanner.

* Fix use of LikeStr in anonstore.

* Fix use of LikeStr in ngalert/store and org/orgimpl.

* Fix use of LikeStr in queryhistory search.

* Fix use of LikeStr in serviceaccounts.

* Fix use of LikeStr in serviceaccounts.

* Fix use of LikeStr in services/team.

* Remove LikeStr method.
2025-05-02 11:23:57 +03:00
a4f6953f27 spanner: skip dasbhoard RBAC e2e tests for spanner (#104043)
* skip dasbhoard RBAC e2e for spanner

* annotations also relying on dashboard find
2025-04-29 15:50:45 -05:00
af59c4eb3e Chore: bump grafana-plugin-sdk-go from v0.275.0 to v0.277.0 (#103971)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2025-04-17 00:32:25 +03:00
047f5edae9 Chore: Add xorm.io/core into xorm (#103700)
* add xorm.io/core into xorm

* update workspace

* format imports

* update workspace
2025-04-16 08:58:50 +02:00
54b8dde1e1 services/user: Fix userimpl tests when running on Spanner. (#103715)
Fix userimpl tests when running on Spanner.
2025-04-11 10:28:21 +02:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
ec2cd53b1a Tempo: Remove traceQLStreaming feature toggle (#103619)
Remove traceQLStreaming feature toggle and migration
2025-04-09 13:57:07 +01:00
4efdef9b9c Switch to using in-mem sequence generator only when explicitly configured in connection string. Move spanner-related functions to pkg/util/spanner. (#103363)
* Switch to using in-mem sequence generator only when explicitly configured in connection string.
Move spanner-related functions to pkg/util/spanner.
2025-04-08 16:36:37 +02:00
68c6e88b00 Support creating temporary Spanner databases for integration tests. (#103347)
* Support creating temporary Spanner databases for integration tests.
2025-04-07 12:15:16 +02:00
10411361e7 Team: Add columns external_uid and is_provisioned to the team table (#103285)
* add columns external_id and is_provisioned to the team table

* generate openapi specs

* rename column to external_uid

* generate open api specs

* increase limit for external_uid to 256
2025-04-04 11:00:14 +03:00
413378dd3a Retry aborted transactions on Spanner. (#103289)
* Retry aborted transactions on Spanner.
2025-04-03 16:26:09 +02:00
f7f28757f6 Skip noop migrations, instead of executing SELECT 0. (#103086)
* Skip noop migrations, instead of executing SELECT 0.
2025-03-31 15:19:32 +02:00
f7af15eb33 Add 5 seconds timeout to queries in DashboardPermissionFilter tests. (#103094) 2025-03-31 14:45:51 +02:00
15e7c3c439 Fix: Change secure_json_data column data type to medium text only MYSQL (#102557)
fix: change secure_json_data type to medium text only MYSQL
2025-03-27 12:59:07 -04:00
d0d7078953 App Platform: Remove mutable globals (#102962)
* App Platform: Remove mutable globals

* chore: clarify why this exists

* fix: support multi-tenant mode

* refactor: call builder providers directly

* CI: Force re-build
2025-03-27 15:46:09 +01:00
e1e1d3fd9f Fix: Prints should always include new lines (#102795)
* CI: Allow Bench conversion to fail

We shouldn't mark PRs and commits as X if they fail to convert logs with Bench.

* Fix: Prints should always include new lines

* fix: remove unused import
2025-03-27 12:27:53 +01:00
d0dbd1d156 spanner: Fix star migration that fills NULL dashboard_uid and org_id fields from dashboard table. (#102768) 2025-03-26 11:15:00 +01:00
5b5f433a26 spanner: Disable running alerting integration tests when using spanner. (#102730)
* Disable running alerting integration tests when using spanner.

* Disable tests for templategroup.
2025-03-26 10:57:55 +01:00
f641ca9284 spanner: use emulator by default when running integration tests with Spanner (#102757)
* spanner: when using GRAFANA_TEST_DB=spanner and no SPANNER_DB, use emulator by default.
2025-03-25 14:08:16 +01:00
00db0cf6e6 Remove dependency from OSS to enterprise packages by moving Spanner functions to xorm. (#102692)
* Remove dependency from OSS to enterprise packages by moving Spanner functions to xorm.
2025-03-24 12:16:12 +01:00
cb532cafef SCIM: Validate provisioned users (#102099)
* Validate authID when user is provisioned

* Add new `user_unique_id` to `user_auth` table

* Validate provisioned user with saml assertion

* Rework `ExternalUID`

* Validate for ExternalUID only

* Enhance verbosity

* Move ExternalUID to saml config

* Rename db variable for externalUID

* Add verbosity to debug ExternalUID

* Assign new error for ExternalUID mismatch

* Add `GetByLoginFn`

* Add new configuration to saml tests

* add validation for empty externalUID
2025-03-24 09:28:51 +01:00
3d53968ecb spanner-annotationsimpls-fixes (#102622)
* Fix DELETE statements.
* Reset sequence generator when truncating tables.
* Quote "at", since it's a keyword in Spanner.
2025-03-21 16:10:51 +01:00
19d1ded3bf spanner: fix TestIntegration_DashboardPermissionFilter (#102603) 2025-03-21 16:04:58 +01:00
4e27ee2ff6 Unified Storage: Add index on dashboard_tag table for dashboard_uid column (#102551)
add index on dashboard_tag table for dashboard_uid column
2025-03-20 16:51:37 -06:00
24ebacb10b Alerting: Add migration to clean up rule versions table (#102484)
* add migration to clean up rule versions
* drop index right before creating a new one.
* fetch only rules which version greater than toKeep
2025-03-20 12:34:36 -04:00
8db050af6b Use in-memory sequence number generator when running integration tests against Spanner emulator. (#102522) 2025-03-20 16:50:50 +01:00
0566ddbf4d Speed up truncation in mysql, postgres and sqlite in integration tests. (#102439)
Speed up truncation in sqlite, mysql and postgres integration tests.
2025-03-19 14:16:20 +01:00
0c58d39e76 Spanner-related fixes (#102376)
* Fix UNION syntax in resourcepermissions package.
* Fix migrations in usermig package to work with Spanner.
* Fix health query.
* Use more connections for integration tests.
* Add test-go-integration-spanner target to run integration tests against Spanner emulator.
* Add test for enterprise.
* Don't delete sequence number for migration_log.id column.

* Only bump max open connections to 20 for Spanner.
Lower integration test timeout.
2025-03-19 12:34:44 +01:00
e39b17d701 Alerting: Remove constraints for uniqueness of rule title (#102067)
* fix having duplicated names in same group in the UI

---------

Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2025-03-18 13:27:44 -04:00
04f20127a2 Revert "Alerting: Add an index to alert_rule_version table on (rule_org_id, rule_uid) (#102347)" (#102368)
This reverts commit 9491fa18957cff5ae7ca986d82d567d66fc402cd.
2025-03-18 14:54:45 +01:00
0bafd4e99d unistore: update spanner ddl to include unistore tables (#102198)
* provision unistore tables

* update the tests to use generated namespace

* update ddl

* update ddl

* clean streams

* missing space

* use engine.db.query
2025-03-18 14:37:11 +01:00
fc9e5110d7 Access: Add migration to remove datasources:drilldown (#102188)
* Add migration to remove datasources:drilldown

* remove role assignments as well

* rename to datasources:drilldown

* remove the role assignments

* made it simple instead

* Update pkg/services/sqlstore/migrations/accesscontrol/datasource_drilldown_removal.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* Update pkg/services/sqlstore/migrations/accesscontrol/datasource_drilldown_removal.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2025-03-18 13:06:30 +02:00
695ac91290 Alerting: Add backend support for keep_firing_for (#100750)
What is this feature?

This PR introduces a new alert rule configuration option, keep_firing_for (Prometheus documentation).

keep_firing_for prevents alerts from resolving immediately after the alert condition returns to normal. Instead, they transition into a "Recovering" state and are not considered resolved by the Alertmanager. Once the recovery period ends (or after the next evaluation if it is bigger than keep_firing_for), the alert transitions to "Normal" if it doesn't start alerting again:

Before                                          

+----------+     +----------+                    
| Alerting |---->|  Normal  |                    
+----------+     +----------+                    

-----
After

+----------+      +------------+     +----------+
| Alerting |----->| Recovering |---->|  Normal  |
+----------+      +------------+     +----------+                                                 

Why do we need this feature?

This feature prevents flapping alerts by adding a recovery period. This helps avoid false resolutions caused by brief alert
2025-03-18 11:24:48 +01:00
9491fa1895 Alerting: Add an index to alert_rule_version table on (rule_org_id, rule_uid) (#102347) 2025-03-18 11:15:55 +01:00
11552e5c57 Speed up truncation of Spanner tables (used in integration tests) (#102278)
Speed up truncation of Spanner tables.
2025-03-17 15:05:01 +01:00
8625a6c131 Export SpannerConnectorConfigToClientOptions function (used by grafana-enterprise). (#102106)
* Export SpannerConnectorConfigToClientOptions function (used by grafana-enterprise).
2025-03-14 10:07:24 +01:00
9264431c81 RBAC: Remove action set feature toggle (#101959)
* remove action set feature toggle

* don't pass feature toggles to action set service instantiation

* linting

* test fixes and frontend clean-up

* fix test
2025-03-13 15:18:23 +00:00
94020aa9cd Config: Remove setting editors_can_admin (#101607)
* Remove editors can admin

* delete file

* add ac_test back

* Add linting ignore

* more static ignore
2025-03-12 16:25:23 +00:00
abe6a3121c spanner: disable recursive queries (#102032) 2025-03-12 15:43:06 +01:00