2092 Commits

Author SHA1 Message Date
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
f3df64b7f4 Pass BOOL values as real types (int/bool) instead of strings to SQL parameters. (#101961)
* Pass BOOL values as real types (int/bool) instead of strings to SQL parameters.

Fixes following integration tests when running with Spanner:
* TestIntegrationDataAccess
    * GetDataSourcesByType/Get_prunable_data_sources
* TestIntegrationUserAuthToken:
    * expires_correctly
    * can_properly_rotate_tokens
    *  keeps_prev_token_valid_for_1_minute_after_it_is_confirmed

* Fix more places where "true" or "false" string was passed as query parameter instead of bool value.

* Removed unit test because it brought unwanted dependencies on xorm into multiple modules.
2025-03-12 15:40:11 +01:00
7dd6f52630 Alerting: Add MissingSeriesEvalsToResolve option to the AlertRule (#101184) 2025-03-11 22:12:06 +01:00
fa809ac417 Fix more LastInsertId calls (#101892)
* Fix more places where LastInsertId is used without proper directive for Spanner.

* Fix tests.
2025-03-11 09:03:03 +01:00
0ce67dad74 Spanner: support for lastInsertId (#101770)
* Support for returning inserted ID in Spanner.
* Convert bytes to string when storing them into text column.
2025-03-10 15:59:06 +01:00
32f651e9aa Spanner: update DB snapshot (#101879)
* Update spanner snapshot to include migrations from grafana-enterprise.

* Move sql dump tool (test) to grafana-enterprise.
2025-03-10 15:58:12 +01:00
fd6a4908f1 Support Spanner's UNION syntax, which needs to be UNION DISTINCT or UNION ALL. (#101768)
* Support Spanner's UNION syntax, which needs to be UNION DISTINCT or UNION ALL.
2025-03-10 12:33:52 +01:00
dc75b454f5 Alerting: Improve performance of the setting GUID during migration (#101800) 2025-03-07 12:28:07 -05:00
32624b3251 Tests: skip failing test TestMigrateToSpannerDialect (#101730)
skip failing test TestMigrateToSpannerDialect
2025-03-06 20:47:37 +02:00
9e690bd620 Spanner support enhancements (#101634)
* Adds ability to run integration tests against spanner (by using GRAFANA_TEST_DB=spanner env variable. SPANNER_DB variable then specifies database to use: spannertest, emulator or string like /projects/<project>/instances/<instance>/databases/<db>)
* Adds feature to migration dialects to create database from a snapshot, instead of running individual migrations.
* Adds first version of Spanner snapshot, prepared from "OSS" migrations.
* Uses generated bit-reversed-positive values instead of auto_increment. (As an experiment)
2025-03-06 16:11:20 +01:00
904d58e936 SQLStore: Introduce new test infra (#101676)
This creates the new testinfra. It is not used anywhere yet.
2025-03-06 11:01:14 +01:00
c1b48cc488 Dashboards: Add apiVersion to dashboard table (#100845) 2025-03-04 07:47:45 +03:00
b7a0aeeb0d SCIM: Disable auto assign organization if the user has been provisioned (#101307)
* Add isProvisioned field to model

* Add new isProvisioned column to migration

* Disable auto assignment to organization if the user is provisioned

* add annotation to user model

* add annotation to user models

* Remove IsProvisioned field from Identity

* Move new field assignenment and add default value

* Update annotations for user query results

* Remove isProvisioned from identity

* Add new column to test

* Resolve user from identity at SyncOrgHook
2025-03-03 17:51:23 +01:00
165bca6417 Chore: Add initial/experimental xorm spanner driver (#101398)
* make it build and start

* run some migrations

* add build tags, remove log

* remove unused code

* revert go.mod changes

* move initialisation into dialect file

* update workspace

* update workspace once again

* clean up dependencies

* further cleanup

* Address some review feedback.

* Fix go.sum.

---------

Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
2025-03-03 17:02:10 +01:00
879b121136 Alerting: Add GUID to alert rule tables (#101321)
* add column guid to alert rule table and rule_guid to rule version table
+ populate the new field with UUID
* update storage and domain models
* patch GUID
* ignore GUID in fingerprint tests
2025-02-28 09:47:25 -05:00
5a40c84568 DualWriter: Support managed DualWriter (#100881) 2025-02-19 17:50:39 +03:00
67be9aeed6 K8s: Search fallback: Support all sort by methods (#100776) 2025-02-18 12:30:11 -06:00
1856d47e47 Remove GetResourceClient hack from unified package. (#100636)
* Remove GetResourceClient hack from unified package.
2025-02-14 12:34:52 +01:00
cb43f4b696 Alerting: Add compressed protobuf-based alert state storage (#99193) 2025-01-27 18:47:33 +01:00
a2097fbc2f Folders: Add user service to folder service implementation (#99518)
Add user service to folder service implementation
2025-01-27 14:29:47 +01:00