Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
MacOS committed Feb 25, 2025
2 parents 8a8c733 + 24f9126 commit 8f68131
Show file tree
Hide file tree
Showing 30 changed files with 676 additions and 248 deletions.
12 changes: 8 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4687,9 +4687,9 @@ steps:
path: /github-app
- commands:
- export GITHUB_TOKEN=$(cat /github-app/token)
- 'dagger run --silent /src/grafana-build artifacts -a $${ARTIFACTS} --grafana-ref=$${GRAFANA_REF}
--enterprise-ref=$${ENTERPRISE_REF} --grafana-repo=$${GRAFANA_REPO} --version=$${VERSION} '
- --go-version=1.23.5
- dagger run --silent /src/grafana-build artifacts -a $${ARTIFACTS} --grafana-ref=$${GRAFANA_REF}
--enterprise-ref=$${ENTERPRISE_REF} --grafana-repo=$${GRAFANA_REPO} --version=$${VERSION}
--go-version=1.23.5
depends_on:
- github-app-generate-token
environment:
Expand Down Expand Up @@ -4734,6 +4734,8 @@ steps:
- printenv GCP_KEY_BASE64 | base64 -d > /tmp/key.json
- gcloud auth activate-service-account --key-file=/tmp/key.json
- gcloud storage cp -r dist/* $${UPLOAD_TO}
depends_on:
- rgm-build
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
Expand Down Expand Up @@ -4774,6 +4776,8 @@ volumes:
name: docker
- name: github-app
path: /github-app
- name: github-app
temp: {}
---
clone:
retries: 3
Expand Down Expand Up @@ -5560,6 +5564,6 @@ kind: secret
name: gcr_credentials
---
kind: signature
hmac: 6e01278547a6f0803b7723e5f1e73bd94c572fa4805517232d3897717cee30f6
hmac: 558d477c002eb799c23f6631aafc7df933518e445e59f34ceb989e73f4dc60bc

...
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ The threshold expression allows the comparison between two single values. Availa

- **Is above**: `$A > 5`
- **Is below**: `$B < 3`
- **Is equal to**: `$A == 2`
- **Is not equal to**: `$B =! 4`
- **Is above or equal to**: `$A >= 8`
- **Is below or equal to**: `$B <= 16`
- **Is within range**: `$A > 0 AND $A < 10`
- **Is outside range**: `$B < 0 OR $B > 100`
- **Is within range included**: `$A >= 0 AND $A <= 10`
- **Is outside range included**: `$B <= 0 OR $B >= 100`

A threshold returns `0` when the condition is false and `1` when true.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
"react-highlight-words": "0.21.0",
"react-hook-form": "^7.49.2",
"react-i18next": "^15.0.0",
"react-inlinesvg": "4.1.5",
"react-inlinesvg": "4.2.0",
"react-loading-skeleton": "3.5.0",
"react-moveable": "0.56.0",
"react-redux": "9.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface StandardEditorContext<TOptions, TState = any> {
options?: TOptions;
instanceState?: TState;
isOverride?: boolean;
annotations?: DataFrame[];
}

export interface StandardEditorProps<TValue = any, TSettings = any, TOptions = any, TState = any> {
Expand Down
2 changes: 2 additions & 0 deletions packages/grafana-data/src/types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ export enum FeatureState {
privatePreview = 'private preview',
/** used to mark features that are in public preview with low/medium risk, or as a shared badge for public and private previews */
preview = 'preview',
/** used to mark new GA features */
new = 'new',
}
2 changes: 1 addition & 1 deletion packages/grafana-data/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export interface OptionEditorConfig<TOptions, TSettings = any, TValue = any> {
/**
* Function that enables configuration of when option editor should be shown based on current panel option properties.
*/
showIf?: (currentOptions: TOptions, data?: DataFrame[]) => boolean | undefined;
showIf?: (currentOptions: TOptions, data?: DataFrame[], annotations?: DataFrame[]) => boolean | undefined;
}
2 changes: 1 addition & 1 deletion packages/grafana-data/src/types/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function getDefaultTimeRange(): TimeRange {
}

/**
* Returns the default realtive time range.
* Returns the default relative time range.
*
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"react-highlight-words": "0.21.0",
"react-hook-form": "^7.49.2",
"react-i18next": "^15.0.0",
"react-inlinesvg": "4.1.5",
"react-inlinesvg": "4.2.0",
"react-loading-skeleton": "3.5.0",
"react-router-dom": "5.3.4",
"react-router-dom-v5-compat": "^6.26.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-ui/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const getStyles = (theme: GrafanaTheme2, color: BadgeColor) => {
border: `1px solid ${borderColor}`,
color: textColor,
fontWeight: theme.typography.fontWeightRegular,
gap: '2px',
gap: theme.spacing(0.5),
fontSize: theme.typography.bodySmall.fontSize,
lineHeight: theme.typography.bodySmall.lineHeight,
alignItems: 'center',
Expand Down
14 changes: 11 additions & 3 deletions packages/grafana-ui/src/components/FeatureBadge/FeatureBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FeatureState } from '@grafana/data';

import { t } from '../../utils/i18n';
import { Badge, BadgeProps } from '../Badge/Badge';

export interface FeatureBadgeProps {
Expand Down Expand Up @@ -30,21 +31,28 @@ function getPanelStateBadgeDisplayModel(featureState: FeatureState): BadgeProps

case FeatureState.experimental:
return {
text: 'Experimental',
text: t('grafana-ui.feature-badge.experimental', 'Experimental'),
icon: 'exclamation-triangle',
color: 'orange',
};

case FeatureState.preview:
return {
text: 'Preview',
text: t('grafana-ui.feature-badge.preview', 'Preview'),
icon: 'rocket',
color: 'blue',
};

case FeatureState.privatePreview:
return {
text: 'Private preview',
text: t('grafana-ui.feature-badge.private-preview', 'Private preview'),
icon: 'rocket',
color: 'blue',
};

case FeatureState.new:
return {
text: t('grafana-ui.feature-badge.new', 'New!'),
icon: 'rocket',
color: 'blue',
};
Expand Down
11 changes: 9 additions & 2 deletions packages/grafana-ui/src/options/builder/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PanelOptionsEditorBuilder } from '@grafana/data';
import { DataFrame, PanelOptionsEditorBuilder } from '@grafana/data';
import { OptionsWithTooltip, TooltipDisplayMode, SortOrder } from '@grafana/schema';

/** @internal */
Expand Down Expand Up @@ -94,6 +94,13 @@ export function addTooltipOptions<T extends OptionsWithTooltip>(
settings: {
integer: true,
},
showIf: (options: T) => options.tooltip?.mode === TooltipDisplayMode.Multi,
showIf: (options: T, data: DataFrame[] | undefined, annotations: DataFrame[] | undefined) => {
return (
options.tooltip?.mode === TooltipDisplayMode.Multi ||
annotations?.some((df) => {
return df.meta?.custom?.resultType === 'exemplar';
})
);
},
});
}
10 changes: 7 additions & 3 deletions pkg/services/authz/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,24 @@ func RegisterRBACAuthZService(
reg prometheus.Registerer,
cache cache.Cache,
exchangeClient authnlib.TokenExchanger,
folderAPIURL string,
cfg RBACServerSettings,
) {
var folderStore store.FolderStore
// FIXME: for now we default to using database read proxy for folders if the api url is not configured.
// we should remove this and the sql implementation once we have verified that is works correctly
if folderAPIURL == "" {
if cfg.Folder.Host == "" {
folderStore = store.NewSQLFolderStore(db, tracer)
} else {
folderStore = store.NewAPIFolderStore(tracer, func(ctx context.Context) (*rest.Config, error) {
return &rest.Config{
Host: folderAPIURL,
Host: cfg.Folder.Host,
WrapTransport: func(rt http.RoundTripper) http.RoundTripper {
return &tokenExhangeRoundTripper{te: exchangeClient, rt: rt}
},
TLSClientConfig: rest.TLSClientConfig{
Insecure: cfg.Folder.Insecure,
CAFile: cfg.Folder.CAFile,
},
QPS: 50,
Burst: 100,
}, nil
Expand Down
13 changes: 13 additions & 0 deletions pkg/services/authz/rbac_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@ func readAuthzClientSettings(cfg *setting.Cfg) (*authzClientSettings, error) {

return s, nil
}

type RBACServerSettings struct {
Folder FolderAPISettings
}

type FolderAPISettings struct {
// Host is hostname for folder api
Host string
// Insecure will skip verification of ceritificates. Should only be used for testing
Insecure bool
// CAFile is a filepath to trusted root certificates for server
CAFile string
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sql
package resource

import (
"encoding/base64"
Expand Down
15 changes: 15 additions & 0 deletions pkg/storage/unified/resource/continue_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package resource

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestContinueToken(t *testing.T) {
token := &ContinueToken{
ResourceVersion: 100,
StartOffset: 50,
}
assert.Equal(t, "eyJvIjo1MCwidiI6MTAwfQ==", token.String())
}
4 changes: 4 additions & 0 deletions pkg/storage/unified/resource/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,10 @@ func (s *server) initWatcher() error {
// pipe all events
v := <-events

if v == nil {
s.log.Error("received nil event")
continue
}
// Skip events during batch updates
if v.PreviousRV < 0 {
continue
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/unified/sql/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ type listIter struct {

// ContinueToken implements resource.ListIterator.
func (l *listIter) ContinueToken() string {
return ContinueToken{ResourceVersion: l.listRV, StartOffset: l.offset}.String()
return resource.ContinueToken{ResourceVersion: l.listRV, StartOffset: l.offset}.String()
}

func (l *listIter) ContinueTokenWithCurrentRV() string {
return ContinueToken{ResourceVersion: l.rv, StartOffset: l.offset}.String()
return resource.ContinueToken{ResourceVersion: l.rv, StartOffset: l.offset}.String()
}

func (l *listIter) Error() error {
Expand Down Expand Up @@ -679,7 +679,7 @@ func (b *backend) listAtRevision(ctx context.Context, req *resource.ListRequest,
// Get the RV
iter := &listIter{listRV: req.ResourceVersion}
if req.NextPageToken != "" {
continueToken, err := GetContinueToken(req.NextPageToken)
continueToken, err := resource.GetContinueToken(req.NextPageToken)
if err != nil {
return 0, fmt.Errorf("get continue token: %w", err)
}
Expand Down Expand Up @@ -737,7 +737,7 @@ func (b *backend) getHistory(ctx context.Context, req *resource.ListRequest, cb

iter := &listIter{}
if req.NextPageToken != "" {
continueToken, err := GetContinueToken(req.NextPageToken)
continueToken, err := resource.GetContinueToken(req.NextPageToken)
if err != nil {
return 0, fmt.Errorf("get continue token: %w", err)
}
Expand Down
25 changes: 17 additions & 8 deletions pkg/storage/unified/sql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ func NewResourceServer(db infraDB.DB, cfg *setting.Cfg,
return nil, err
}

dbCfg := cfg.SectionWithEnvOverrides("database")
// Check in the config if HA is enabled by default we always assume a HA setup.
isHA := dbCfg.Key("high_availability").MustBool(true)
// SQLite is not possible to run in HA, so we set it to false.
databaseType := dbCfg.Key("type").MustString(migrator.SQLite)
if databaseType == migrator.SQLite {
isHA = false
}
isHA := isHighAvailabilityEnabled(cfg.SectionWithEnvOverrides("database"))

store, err := NewBackend(BackendOptions{DBProvider: eDB, Tracer: tracer, IsHA: isHA})
if err != nil {
Expand All @@ -70,3 +63,19 @@ func NewResourceServer(db infraDB.DB, cfg *setting.Cfg,

return rs, nil
}

// isHighAvailabilityEnabled determines if high availability mode should
// be enabled based on database configuration. High availability is enabled
// by default except for SQLite databases.
func isHighAvailabilityEnabled(dbCfg *setting.DynamicSection) bool {
// Check in the config if HA is enabled - by default we always assume a HA setup.
isHA := dbCfg.Key("high_availability").MustBool(true)

// SQLite is not possible to run in HA, so we force it to false.
databaseType := dbCfg.Key("type").String()
if databaseType == migrator.SQLite {
isHA = false
}

return isHA
}
Loading

0 comments on commit 8f68131

Please sign in to comment.