From db4f50171f39d004bf682104b5d4e4047b7e02c2 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 9 Feb 2022 12:49:15 +0100 Subject: [PATCH 01/21] Provisioning: Ensure that the default value for orgID is set when provisioning datasources to be deleted (#44244) (#45129) Fixes #44243 Signed-off-by: Maicon Costa (cherry picked from commit 8e035412285ccf65c9592c58bf6829dab7aaae84) Co-authored-by: maicon --- .../provisioning/datasources/config_reader.go | 12 ++++++---- .../datasources/config_reader_test.go | 22 +++++++++++++++++++ .../testdata/delete-one/one-datasource.yaml | 3 +++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 pkg/services/provisioning/datasources/testdata/delete-one/one-datasource.yaml diff --git a/pkg/services/provisioning/datasources/config_reader.go b/pkg/services/provisioning/datasources/config_reader.go index d7f37602d30..243c2f726ab 100644 --- a/pkg/services/provisioning/datasources/config_reader.go +++ b/pkg/services/provisioning/datasources/config_reader.go @@ -93,11 +93,11 @@ func (cr *configReader) parseDatasourceConfig(path string, file os.FileInfo) (*c func (cr *configReader) validateDefaultUniqueness(ctx context.Context, datasources []*configs) error { defaultCount := map[int64]int{} for i := range datasources { - if datasources[i].Datasources == nil { - continue - } - for _, ds := range datasources[i].Datasources { + if ds == nil { + continue + } + if ds.OrgID == 0 { ds.OrgID = 1 } @@ -115,6 +115,10 @@ func (cr *configReader) validateDefaultUniqueness(ctx context.Context, datasourc } for _, ds := range datasources[i].DeleteDatasources { + if ds == nil { + continue + } + if ds.OrgID == 0 { ds.OrgID = 1 } diff --git a/pkg/services/provisioning/datasources/config_reader_test.go b/pkg/services/provisioning/datasources/config_reader_test.go index 8db0f53dc0a..769440e25f9 100644 --- a/pkg/services/provisioning/datasources/config_reader_test.go +++ b/pkg/services/provisioning/datasources/config_reader_test.go @@ -18,6 +18,7 @@ var ( twoDatasourcesConfig = "testdata/two-datasources" twoDatasourcesConfigPurgeOthers = "testdata/insert-two-delete-two" + deleteOneDatasource = "testdata/delete-one" doubleDatasourcesConfig = "testdata/double-default" allProperties = "testdata/all-properties" versionZero = "testdata/version-0" @@ -129,6 +130,27 @@ func TestDatasourceAsConfig(t *testing.T) { }) }) + t.Run("Remove one datasource", func(t *testing.T) { + setup() + t.Run("Remove one datasource", func(t *testing.T) { + fakeRepo.loadAll = []*models.DataSource{} + + t.Run("should have removed old datasource", func(t *testing.T) { + dc := newDatasourceProvisioner(logger) + err := dc.applyChanges(context.Background(), deleteOneDatasource) + if err != nil { + t.Fatalf("applyChanges return an error %v", err) + } + + require.Equal(t, 1, len(fakeRepo.deleted)) + // should have set OrgID to 1 + require.Equal(t, fakeRepo.deleted[0].OrgID, int64(1)) + require.Equal(t, 0, len(fakeRepo.inserted)) + require.Equal(t, len(fakeRepo.updated), 0) + }) + }) + }) + t.Run("Two configured datasource and purge others ", func(t *testing.T) { setup() t.Run("two other datasources in database", func(t *testing.T) { diff --git a/pkg/services/provisioning/datasources/testdata/delete-one/one-datasource.yaml b/pkg/services/provisioning/datasources/testdata/delete-one/one-datasource.yaml new file mode 100644 index 00000000000..3ffb62d4e6c --- /dev/null +++ b/pkg/services/provisioning/datasources/testdata/delete-one/one-datasource.yaml @@ -0,0 +1,3 @@ +datasources: [] +delete_datasources: + - name: old-data-source From c79cdf97d9699a908198b8a7f59aab06995b490a Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:41:57 +0100 Subject: [PATCH 02/21] Tempo: Fix visual service graph bug by setting upper bound for failed arc (#45009) (#45155) * Fix visual service graph bug by setting upper bound for failed arc calculation (cherry picked from commit e94b7f45a1b5e550bfa3587b33d6193ef8d2db63) Co-authored-by: Connor Lindsey --- .../datasource/tempo/graphTransform.test.ts | 38 +++++++++++++++++++ .../datasource/tempo/graphTransform.ts | 4 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/tempo/graphTransform.test.ts b/public/app/plugins/datasource/tempo/graphTransform.test.ts index 990088eacae..a6dd5b417cf 100644 --- a/public/app/plugins/datasource/tempo/graphTransform.test.ts +++ b/public/app/plugins/datasource/tempo/graphTransform.test.ts @@ -88,6 +88,31 @@ describe('mapPromMetricsToServiceMap', () => { { name: 'secondaryStat', values: new ArrayVector([1000, 2000]) }, ]); }); + + it('handles invalid failed count', () => { + // If node.failed > node.total, the stat circle will render in the wrong position + // Fixed this by limiting the failed value to the total value + const range = { + from: dateTime('2000-01-01T00:00:00'), + to: dateTime('2000-01-01T00:01:00'), + }; + const { nodes } = mapPromMetricsToServiceMap( + [{ data: [totalsPromMetric, secondsPromMetric, invalidFailedPromMetric] }], + { + ...range, + raw: range, + } + ); + + expect(nodes.fields).toMatchObject([ + { name: 'id', values: new ArrayVector(['db', 'app', 'lb']) }, + { name: 'title', values: new ArrayVector(['db', 'app', 'lb']) }, + { name: 'mainStat', values: new ArrayVector([1000, 2000, NaN]) }, + { name: 'secondaryStat', values: new ArrayVector([0.17, 0.33, NaN]) }, + { name: 'arc__success', values: new ArrayVector([0, 0, 1]) }, + { name: 'arc__failed', values: new ArrayVector([1, 1, 0]) }, + ]); + }); }); const singleSpanResponse = new MutableDataFrame({ @@ -152,3 +177,16 @@ const failedPromMetric = new MutableDataFrame({ { name: 'Value #traces_service_graph_request_failed_total', values: [2, 15] }, ], }); + +const invalidFailedPromMetric = new MutableDataFrame({ + refId: 'traces_service_graph_request_failed_total', + fields: [ + { name: 'Time', values: [1628169788000, 1628169788000] }, + { name: 'client', values: ['app', 'lb'] }, + { name: 'instance', values: ['127.0.0.1:12345', '127.0.0.1:12345'] }, + { name: 'job', values: ['local_scrape', 'local_scrape'] }, + { name: 'server', values: ['db', 'app'] }, + { name: 'tempo_config', values: ['default', 'default'] }, + { name: 'Value #traces_service_graph_request_failed_total', values: [20, 40] }, + ], +}); diff --git a/public/app/plugins/datasource/tempo/graphTransform.ts b/public/app/plugins/datasource/tempo/graphTransform.ts index 9f385f3f443..212fe45fcac 100644 --- a/public/app/plugins/datasource/tempo/graphTransform.ts +++ b/public/app/plugins/datasource/tempo/graphTransform.ts @@ -303,8 +303,8 @@ function convertToDataFrames( // any requests itself. [Fields.mainStat]: node.total ? (node.seconds! / node.total) * 1000 : Number.NaN, // Average response time [Fields.secondaryStat]: node.total ? Math.round((node.total / (rangeMs / 1000)) * 100) / 100 : Number.NaN, // Request per second (to 2 decimals) - [Fields.arc + 'success']: node.total ? (node.total - (node.failed || 0)) / node.total : 1, - [Fields.arc + 'failed']: node.total ? (node.failed || 0) / node.total : 0, + [Fields.arc + 'success']: node.total ? (node.total - Math.min(node.failed || 0, node.total)) / node.total : 1, + [Fields.arc + 'failed']: node.total ? Math.min(node.failed || 0, node.total) / node.total : 0, }); } for (const edgeId of Object.keys(edgesMap)) { From 30d352313886f21bbbe39666de105ff25cac7cbd Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 9 Feb 2022 17:55:11 +0100 Subject: [PATCH 03/21] Release: Bump version to 8.3.6 (#45168) * "Release: Updated versions in package to 8.3.6" * Update yarn.lock Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com> --- lerna.json | 6 ++- package.json | 2 +- packages/grafana-data/package.json | 4 +- packages/grafana-e2e-selectors/package.json | 2 +- packages/grafana-e2e/package.json | 4 +- packages/grafana-runtime/package.json | 8 ++-- packages/grafana-schema/package.json | 2 +- packages/grafana-toolkit/package.json | 6 +-- packages/grafana-ui/package.json | 8 ++-- packages/jaeger-ui-components/package.json | 6 +-- .../internal/input-datasource/package.json | 8 ++-- yarn.lock | 40 +++++++++---------- 12 files changed, 49 insertions(+), 47 deletions(-) diff --git a/lerna.json b/lerna.json index e6b39b11449..1c2210c59fe 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,8 @@ { "npmClient": "yarn", "useWorkspaces": true, - "packages": ["packages/*"], - "version": "8.3.5" + "packages": [ + "packages/*" + ], + "version": "8.3.6" } diff --git a/package.json b/package.json index 7173b4c6e01..a9105f6aedb 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "license": "AGPL-3.0-only", "private": true, "name": "grafana", - "version": "8.3.5", + "version": "8.3.6", "repository": "github:grafana/grafana", "scripts": { "api-tests": "jest --notify --watch --config=devenv/e2e-api-tests/jest.js", diff --git a/packages/grafana-data/package.json b/packages/grafana-data/package.json index 98d2fd9fd99..8a4b99a7248 100644 --- a/packages/grafana-data/package.json +++ b/packages/grafana-data/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/data", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana Data Library", "keywords": [ "typescript" @@ -22,7 +22,7 @@ }, "dependencies": { "@braintree/sanitize-url": "5.0.2", - "@grafana/schema": "8.3.5", + "@grafana/schema": "8.3.6", "@types/d3-interpolate": "^1.4.0", "d3-interpolate": "1.4.0", "date-fns": "2.21.3", diff --git a/packages/grafana-e2e-selectors/package.json b/packages/grafana-e2e-selectors/package.json index 7e3a5d3a7a0..56928a7fb89 100644 --- a/packages/grafana-e2e-selectors/package.json +++ b/packages/grafana-e2e-selectors/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/e2e-selectors", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana End-to-End Test Selectors Library", "keywords": [ "cli", diff --git a/packages/grafana-e2e/package.json b/packages/grafana-e2e/package.json index b4edf56468e..ca6cc347e8f 100644 --- a/packages/grafana-e2e/package.json +++ b/packages/grafana-e2e/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/e2e", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana End-to-End Test Library", "keywords": [ "cli", @@ -49,7 +49,7 @@ "@babel/core": "7.14.6", "@babel/preset-env": "7.14.7", "@cypress/webpack-preprocessor": "5.9.1", - "@grafana/e2e-selectors": "8.3.5", + "@grafana/e2e-selectors": "8.3.6", "@grafana/tsconfig": "^1.0.0-rc1", "@mochajs/json-file-reporter": "^1.2.0", "babel-loader": "8.2.2", diff --git a/packages/grafana-runtime/package.json b/packages/grafana-runtime/package.json index 917d7776aa0..a15a97b1a3b 100644 --- a/packages/grafana-runtime/package.json +++ b/packages/grafana-runtime/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/runtime", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana Runtime Library", "keywords": [ "grafana", @@ -23,9 +23,9 @@ }, "dependencies": { "@emotion/css": "11.1.3", - "@grafana/data": "8.3.5", - "@grafana/e2e-selectors": "8.3.5", - "@grafana/ui": "8.3.5", + "@grafana/data": "8.3.6", + "@grafana/e2e-selectors": "8.3.6", + "@grafana/ui": "8.3.6", "@sentry/browser": "5.25.0", "history": "4.10.1", "lodash": "4.17.21", diff --git a/packages/grafana-schema/package.json b/packages/grafana-schema/package.json index 424e432824e..9517c49d566 100644 --- a/packages/grafana-schema/package.json +++ b/packages/grafana-schema/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/schema", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana Schema Library", "keywords": [ "typescript" diff --git a/packages/grafana-toolkit/package.json b/packages/grafana-toolkit/package.json index 14e2ebbed33..ad5f3a0208f 100644 --- a/packages/grafana-toolkit/package.json +++ b/packages/grafana-toolkit/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/toolkit", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana Toolkit", "keywords": [ "grafana", @@ -28,10 +28,10 @@ "dependencies": { "@babel/core": "7.13.14", "@babel/preset-env": "7.13.12", - "@grafana/data": "8.3.5", + "@grafana/data": "8.3.6", "@grafana/eslint-config": "2.5.1", "@grafana/tsconfig": "^1.0.0-rc1", - "@grafana/ui": "8.3.5", + "@grafana/ui": "8.3.6", "@jest/core": "26.6.3", "@rushstack/eslint-patch": "1.0.6", "@types/command-exists": "^1.2.0", diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index 6297c8c21a0..412cd5c5db3 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -2,7 +2,7 @@ "author": "Grafana Labs", "license": "Apache-2.0", "name": "@grafana/ui", - "version": "8.3.5", + "version": "8.3.6", "description": "Grafana Components Library", "keywords": [ "grafana", @@ -33,9 +33,9 @@ "@emotion/css": "11.1.3", "@emotion/react": "11.1.5", "@grafana/aws-sdk": "0.0.3", - "@grafana/data": "8.3.5", - "@grafana/e2e-selectors": "8.3.5", - "@grafana/schema": "8.3.5", + "@grafana/data": "8.3.6", + "@grafana/e2e-selectors": "8.3.6", + "@grafana/schema": "8.3.6", "@grafana/slate-react": "0.22.10-grafana", "@monaco-editor/react": "4.2.2", "@popperjs/core": "2.5.4", diff --git a/packages/jaeger-ui-components/package.json b/packages/jaeger-ui-components/package.json index 1cf646c184b..d8a6354b960 100644 --- a/packages/jaeger-ui-components/package.json +++ b/packages/jaeger-ui-components/package.json @@ -1,6 +1,6 @@ { "name": "@jaegertracing/jaeger-ui-components", - "version": "8.3.5", + "version": "8.3.6", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", @@ -30,8 +30,8 @@ "dependencies": { "@emotion/css": "11.1.3", "@emotion/react": "11.1.5", - "@grafana/data": "8.3.5", - "@grafana/ui": "8.3.5", + "@grafana/data": "8.3.6", + "@grafana/ui": "8.3.6", "chance": "^1.0.10", "classnames": "^2.2.5", "combokeys": "^3.0.0", diff --git a/plugins-bundled/internal/input-datasource/package.json b/plugins-bundled/internal/input-datasource/package.json index ccc42a3e852..dc56ead7942 100644 --- a/plugins-bundled/internal/input-datasource/package.json +++ b/plugins-bundled/internal/input-datasource/package.json @@ -1,6 +1,6 @@ { "name": "@grafana-plugins/input-datasource", - "version": "8.3.5", + "version": "8.3.6", "description": "Input Datasource", "private": true, "repository": { @@ -24,9 +24,9 @@ "webpack": "5.58.1" }, "dependencies": { - "@grafana/data": "8.3.5", - "@grafana/toolkit": "8.3.5", - "@grafana/ui": "8.3.5", + "@grafana/data": "8.3.6", + "@grafana/toolkit": "8.3.6", + "@grafana/ui": "8.3.6", "jquery": "3.5.1", "react": "17.0.1", "react-dom": "17.0.1", diff --git a/yarn.lock b/yarn.lock index 0d78a81e1cd..d5ae99c8034 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2329,9 +2329,9 @@ __metadata: version: 0.0.0-use.local resolution: "@grafana-plugins/input-datasource@workspace:plugins-bundled/internal/input-datasource" dependencies: - "@grafana/data": 8.3.5 - "@grafana/toolkit": 8.3.5 - "@grafana/ui": 8.3.5 + "@grafana/data": 8.3.6 + "@grafana/toolkit": 8.3.6 + "@grafana/ui": 8.3.6 "@types/jest": 26.0.15 "@types/lodash": 4.14.149 "@types/react": 17.0.30 @@ -2372,12 +2372,12 @@ __metadata: languageName: node linkType: hard -"@grafana/data@8.3.5, @grafana/data@workspace:*, @grafana/data@workspace:packages/grafana-data": +"@grafana/data@8.3.6, @grafana/data@workspace:*, @grafana/data@workspace:packages/grafana-data": version: 0.0.0-use.local resolution: "@grafana/data@workspace:packages/grafana-data" dependencies: "@braintree/sanitize-url": 5.0.2 - "@grafana/schema": 8.3.5 + "@grafana/schema": 8.3.6 "@grafana/tsconfig": ^1.0.0-rc1 "@rollup/plugin-commonjs": 21.0.1 "@rollup/plugin-json": 4.1.0 @@ -2432,7 +2432,7 @@ __metadata: languageName: unknown linkType: soft -"@grafana/e2e-selectors@8.3.5, @grafana/e2e-selectors@workspace:*, @grafana/e2e-selectors@workspace:packages/grafana-e2e-selectors": +"@grafana/e2e-selectors@8.3.6, @grafana/e2e-selectors@workspace:*, @grafana/e2e-selectors@workspace:packages/grafana-e2e-selectors": version: 0.0.0-use.local resolution: "@grafana/e2e-selectors@workspace:packages/grafana-e2e-selectors" dependencies: @@ -2464,7 +2464,7 @@ __metadata: "@babel/core": 7.14.6 "@babel/preset-env": 7.14.7 "@cypress/webpack-preprocessor": 5.9.1 - "@grafana/e2e-selectors": 8.3.5 + "@grafana/e2e-selectors": 8.3.6 "@grafana/tsconfig": ^1.0.0-rc1 "@mochajs/json-file-reporter": ^1.2.0 "@rollup/plugin-commonjs": 21.0.1 @@ -2522,10 +2522,10 @@ __metadata: resolution: "@grafana/runtime@workspace:packages/grafana-runtime" dependencies: "@emotion/css": 11.1.3 - "@grafana/data": 8.3.5 - "@grafana/e2e-selectors": 8.3.5 + "@grafana/data": 8.3.6 + "@grafana/e2e-selectors": 8.3.6 "@grafana/tsconfig": ^1.0.0-rc1 - "@grafana/ui": 8.3.5 + "@grafana/ui": 8.3.6 "@rollup/plugin-commonjs": 21.0.1 "@rollup/plugin-node-resolve": 13.0.6 "@sentry/browser": 5.25.0 @@ -2557,7 +2557,7 @@ __metadata: languageName: unknown linkType: soft -"@grafana/schema@8.3.5, @grafana/schema@workspace:*, @grafana/schema@workspace:packages/grafana-schema": +"@grafana/schema@8.3.6, @grafana/schema@workspace:*, @grafana/schema@workspace:packages/grafana-schema": version: 0.0.0-use.local resolution: "@grafana/schema@workspace:packages/grafana-schema" dependencies: @@ -2607,16 +2607,16 @@ __metadata: languageName: node linkType: hard -"@grafana/toolkit@8.3.5, @grafana/toolkit@workspace:*, @grafana/toolkit@workspace:packages/grafana-toolkit": +"@grafana/toolkit@8.3.6, @grafana/toolkit@workspace:*, @grafana/toolkit@workspace:packages/grafana-toolkit": version: 0.0.0-use.local resolution: "@grafana/toolkit@workspace:packages/grafana-toolkit" dependencies: "@babel/core": 7.13.14 "@babel/preset-env": 7.13.12 - "@grafana/data": 8.3.5 + "@grafana/data": 8.3.6 "@grafana/eslint-config": 2.5.1 "@grafana/tsconfig": ^1.0.0-rc1 - "@grafana/ui": 8.3.5 + "@grafana/ui": 8.3.6 "@jest/core": 26.6.3 "@rushstack/eslint-patch": 1.0.6 "@types/command-exists": ^1.2.0 @@ -2700,7 +2700,7 @@ __metadata: languageName: node linkType: hard -"@grafana/ui@8.3.5, @grafana/ui@workspace:*, @grafana/ui@workspace:packages/grafana-ui": +"@grafana/ui@8.3.6, @grafana/ui@workspace:*, @grafana/ui@workspace:packages/grafana-ui": version: 0.0.0-use.local resolution: "@grafana/ui@workspace:packages/grafana-ui" dependencies: @@ -2708,9 +2708,9 @@ __metadata: "@emotion/css": 11.1.3 "@emotion/react": 11.1.5 "@grafana/aws-sdk": 0.0.3 - "@grafana/data": 8.3.5 - "@grafana/e2e-selectors": 8.3.5 - "@grafana/schema": 8.3.5 + "@grafana/data": 8.3.6 + "@grafana/e2e-selectors": 8.3.6 + "@grafana/schema": 8.3.6 "@grafana/slate-react": 0.22.10-grafana "@grafana/tsconfig": ^1.0.0-rc1 "@mdx-js/react": 1.6.22 @@ -2923,9 +2923,9 @@ __metadata: dependencies: "@emotion/css": 11.1.3 "@emotion/react": 11.1.5 - "@grafana/data": 8.3.5 + "@grafana/data": 8.3.6 "@grafana/tsconfig": ^1.0.0-rc1 - "@grafana/ui": 8.3.5 + "@grafana/ui": 8.3.6 "@types/classnames": ^2.2.7 "@types/deep-freeze": ^0.1.1 "@types/grafana__slate-react": "npm:@types/slate-react@0.22.5" From c6e6309bc5a6443f215a2eaf75a4c3006dba9120 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 9 Feb 2022 18:26:22 +0100 Subject: [PATCH 04/21] Update latest.json (#45171) (#45172) (cherry picked from commit 67423f42a51692cd6e7bd2a81a6c854c068c6546) Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com> --- latest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest.json b/latest.json index c6e1d81072c..d325bb2abf8 100644 --- a/latest.json +++ b/latest.json @@ -1,4 +1,4 @@ { - "stable": "8.3.5", + "stable": "8.3.6", "testing": "8.4.0-beta1" } From 76460e790de80717d086e6cbc55b3487f14ddc07 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 10 Feb 2022 22:12:47 +0100 Subject: [PATCH 05/21] Alerting: support ok state in alert migration (#45264) (#45266) (cherry picked from commit c59567a2369fad11baf903752ca0a18a49e26b95) Co-authored-by: Yuriy Tseretyan --- pkg/services/sqlstore/migrations/ualert/alert_rule.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/services/sqlstore/migrations/ualert/alert_rule.go b/pkg/services/sqlstore/migrations/ualert/alert_rule.go index fcc53586392..57aeefeb2db 100644 --- a/pkg/services/sqlstore/migrations/ualert/alert_rule.go +++ b/pkg/services/sqlstore/migrations/ualert/alert_rule.go @@ -262,6 +262,8 @@ func transExecErr(s string) (string, error) { // Keep last state is translated to error as we now emit a // DatasourceError alert when the state is error return "Error", nil + case "ok": + return "OK", nil } return "", fmt.Errorf("unrecognized Execution Error setting %v", s) } From 3a95cdd78ee6b3988fb8c6fb029e3c6a3da9a7b4 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:50:51 +0100 Subject: [PATCH 06/21] Update geomap.md (#43527) (#45268) (cherry picked from commit d97e74d80f0e6873207c0d89778d1122d6ae9852) Co-authored-by: JJgitGit --- docs/sources/visualizations/geomap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/visualizations/geomap.md b/docs/sources/visualizations/geomap.md index 4124d468d8a..26f4cee798f 100644 --- a/docs/sources/visualizations/geomap.md +++ b/docs/sources/visualizations/geomap.md @@ -70,7 +70,7 @@ The markers layer allows you to display data points as different marker shapes s ![Markers Layer Options](/static/img/docs/geomap-panel/geomap-markers-options-8-1-0.png) -- **Marker Color** configures the color of the marker. The default `Fixed size` keeps all points a single color. There is an alternate option to have multiple colors depending on the data point values and the threshold set at the `Thresholds` section. +- **Marker Color** configures the color of the marker. The default `Single color` keeps all points a single color. There is an alternate option to have multiple colors depending on the data point values and the threshold set at the `Thresholds` section. - **Marker Size** configures the size of the marker. Default is `Fixed size`, making all marker size the same regardless of the data points. However, there is also an option to scale the circles to the corresponding data points. `Min` and `Max` marker size has to be set such that the Marker layer can scale within this range. - **Marker Shape** allows you to choose the shape, icon, or graphic to aid in providing additional visual context to your data. Choose from assets that are included with Grafana such as simple shapes or the Unicon library. You can also specify a URL containing an image asset. The image must be a scalable vector graphic (SVG). - **Fill opacity** configures the transparency of each marker. From 588dc422ab6c9685d024af6460c6f70b01cbb35a Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Fri, 11 Feb 2022 15:59:08 +0100 Subject: [PATCH 07/21] make drone (#45318) Signed-off-by: bergquist Co-authored-by: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com> --- .drone.yml | 14 ++++---------- scripts/drone/steps/lib.star | 8 +++++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.drone.yml b/.drone.yml index 191200e8618..62cffbb7204 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3226,9 +3226,7 @@ steps: - yarn install --immutable depends_on: - clone-enterprise - environment: - GITHUB_TOKEN: - from_secret: github_token + environment: {} image: grafana/build-container:1.4.9 name: initialize - commands: @@ -3533,9 +3531,7 @@ steps: - yarn install --immutable depends_on: - clone-enterprise - environment: - GITHUB_TOKEN: - from_secret: github_token + environment: {} image: grafana/build-container:1.4.9 name: initialize - commands: @@ -3697,9 +3693,7 @@ steps: - yarn install --immutable depends_on: - clone-enterprise - environment: - GITHUB_TOKEN: - from_secret: github_token + environment: {} image: grafana/build-container:1.4.9 name: initialize - commands: @@ -3899,6 +3893,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 1c39a83bdf091e43a83d39be224283c10d9e5a47cde268a1c3c6fd1478531cb4 +hmac: 65c858e5a684c7ea29c5787f1bc81294d74b0e7f6783a05322bb34dbe4bae5c0 ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 0ae3fdc7e6a..72bdd9274d0 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -64,8 +64,12 @@ def initialize_step(edition, platform, ver_mode, is_downstream=False, install_de if ver_mode == 'release': committish = '${DRONE_TAG}' source_commit = ' ${DRONE_TAG}' + environment = { + 'GITHUB_TOKEN': from_secret(github_token), + } elif ver_mode == 'release-branch': committish = '${DRONE_BRANCH}' + environment = {} else: if is_downstream: source_commit = ' $${SOURCE_COMMIT}' @@ -79,9 +83,7 @@ def initialize_step(edition, platform, ver_mode, is_downstream=False, install_de 'depends_on': [ 'clone-enterprise', ], - 'environment': { - 'GITHUB_TOKEN': from_secret(github_token), - }, + 'environment': environment, 'commands': [ 'mv bin/grabpl /tmp/', 'rmdir bin', From 85edf78a464180887acc4e84c3bb2150b6d8fe19 Mon Sep 17 00:00:00 2001 From: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com> Date: Fri, 11 Feb 2022 16:25:31 +0000 Subject: [PATCH 08/21] Build: only specify github-token when needed (#45326) (#45329) (cherry picked from commit 9a7438c720fd0b83cd42d628f9ff27ed318238e7) --- .drone.yml | 8 ++++---- scripts/drone/steps/lib.star | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 62cffbb7204..565a6455db3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3217,7 +3217,7 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise + - /tmp/grabpl init-enterprise /tmp/grafana-enterprise - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -3522,7 +3522,7 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise + - /tmp/grabpl init-enterprise /tmp/grafana-enterprise - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -3684,7 +3684,7 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise + - /tmp/grabpl init-enterprise /tmp/grafana-enterprise - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -3893,6 +3893,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 65c858e5a684c7ea29c5787f1bc81294d74b0e7f6783a05322bb34dbe4bae5c0 +hmac: ccccf712cc34ebea0b3aaab48914f8019624b1838af29ec712e47b1f7bd9a104 ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 72bdd9274d0..ba4865b622e 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -67,13 +67,17 @@ def initialize_step(edition, platform, ver_mode, is_downstream=False, install_de environment = { 'GITHUB_TOKEN': from_secret(github_token), } + token = "--github-token $${GITHUB_TOKEN}" elif ver_mode == 'release-branch': committish = '${DRONE_BRANCH}' environment = {} + token = "" else: + environment = {} if is_downstream: source_commit = ' $${SOURCE_COMMIT}' committish = '${DRONE_COMMIT}' + token = "" steps = [ identify_runner, clone_enterprise(committish), @@ -88,7 +92,7 @@ def initialize_step(edition, platform, ver_mode, is_downstream=False, install_de 'mv bin/grabpl /tmp/', 'rmdir bin', 'mv grafana-enterprise /tmp/', - '/tmp/grabpl init-enterprise --github-token $${{GITHUB_TOKEN}} /tmp/grafana-enterprise{}'.format(source_commit), + '/tmp/grabpl init-enterprise {} /tmp/grafana-enterprise{}'.format(token, source_commit), 'mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json', 'mkdir bin', 'mv /tmp/grabpl bin/' From 26289304f24a68b9a643eb875ab1eb7fcd5df724 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 11 Feb 2022 17:52:01 +0100 Subject: [PATCH 09/21] Alerting: Fix updating notification channels in legacy (#45302) (#45330) The problem here is that without the orgID we ignore the lookup of the existing notification channel just before updating and end up failing the update because there is no channel available. (cherry picked from commit 8bf2e642aa1df706b8a5c1d13c81538c38f0b5b9) Co-authored-by: gotjosh --- pkg/services/alerting/service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/services/alerting/service.go b/pkg/services/alerting/service.go index f691d07a638..44cd632fc82 100644 --- a/pkg/services/alerting/service.go +++ b/pkg/services/alerting/service.go @@ -2,6 +2,7 @@ package alerting import ( "context" + "fmt" "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/models" @@ -74,6 +75,7 @@ func (s *AlertNotificationService) UpdateAlertNotification(ctx context.Context, model := models.AlertNotification{ Id: cmd.Id, + OrgId: cmd.OrgId, Name: cmd.Name, Type: cmd.Type, Settings: cmd.Settings, @@ -134,7 +136,11 @@ func (s *AlertNotificationService) createNotifier(ctx context.Context, model *mo return nil, err } - if query.Result != nil && query.Result.SecureSettings != nil { + if query.Result == nil { + return nil, fmt.Errorf("unable to find the alert notification") + } + + if query.Result.SecureSettings != nil { var err error secureSettingsMap, err = s.EncryptionService.DecryptJsonData(ctx, query.Result.SecureSettings, setting.SecretKey) if err != nil { From 027e345231e516663b2ecfed88620f9c3b8a1316 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 15 Feb 2022 11:04:12 +0100 Subject: [PATCH 10/21] CI: Remove `grafana/drone-grafana-docker` image (#44983) (#45091) * CI: Remove `grafana/drone-grafana-docker` image (#44983) * Remove grafana/drone-grafana-docker image * Rename step * Remove manual gcloud authentication (cherry picked from commit 329b1a1ef3903c7e2c3ec1f286f9b0f00fcd023e) * Add publish command for main * Fix TAG variable parsing * Remove shouldSave from main builds * Reorder dependencies * Update grabpl version (cherry picked from commit 5543ad883dc9f8daf8182753d67e83bdeb1273ff) * Sign drone --- .drone.yml | 229 +++++++++++++++------------ scripts/drone/pipelines/main.star | 7 +- scripts/drone/pipelines/release.star | 34 +--- scripts/drone/steps/lib.star | 65 ++++---- 4 files changed, 176 insertions(+), 159 deletions(-) diff --git a/.drone.yml b/.drone.yml index 565a6455db3..d164fafc4b3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -110,7 +110,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -276,15 +276,18 @@ steps: - package image: grafana/build-container:1.4.9 name: copy-packages-for-docker -- depends_on: +- commands: + - ./bin/grabpl build-docker --edition oss -archs amd64 + depends_on: - copy-packages-for-docker - image: grafana/drone-grafana-docker:0.3.2 + environment: + GCP_KEY: + from_secret: gcp_key + image: google/cloud-sdk name: build-docker-images - settings: - archs: amd64 - dry_run: true - edition: oss - ubuntu: false + volumes: + - name: docker + path: /var/run/docker.sock trigger: event: - pull_request @@ -326,7 +329,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -397,7 +400,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -497,7 +500,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -705,30 +708,66 @@ steps: - package image: grafana/build-container:1.4.9 name: copy-packages-for-docker -- depends_on: +- commands: + - ./bin/grabpl build-docker --edition oss + depends_on: - copy-packages-for-docker - image: grafana/drone-grafana-docker:0.3.2 + environment: + GCP_KEY: + from_secret: gcp_key + image: google/cloud-sdk name: build-docker-images - settings: - dry_run: false - edition: oss - password: - from_secret: docker_password - ubuntu: false - username: - from_secret: docker_user -- depends_on: + volumes: + - name: docker + path: /var/run/docker.sock +- commands: + - ./bin/grabpl build-docker --edition oss --ubuntu + depends_on: - copy-packages-for-docker - image: grafana/drone-grafana-docker:0.3.2 + environment: + GCP_KEY: + from_secret: gcp_key + image: google/cloud-sdk name: build-docker-images-ubuntu - settings: - dry_run: false - edition: oss - password: + volumes: + - name: docker + path: /var/run/docker.sock +- commands: + - ./bin/grabpl artifacts docker publish --dockerhub-repo grafana --base alpine --base + ubuntu --arch amd64 --arch arm64 --arch armv7 + depends_on: + - build-docker-images + - build-docker-images-ubuntu + environment: + DOCKER_PASSWORD: from_secret: docker_password - ubuntu: true - username: - from_secret: docker_user + DOCKER_USER: + from_secret: docker_username + GCP_KEY: + from_secret: gcp_key + image: google/cloud-sdk + name: publish-images-grafana + volumes: + - name: docker + path: /var/run/docker.sock +- commands: + - ./bin/grabpl artifacts docker publish --dockerhub-repo grafana-oss --base alpine + --base ubuntu --arch amd64 --arch arm64 --arch armv7 + depends_on: + - build-docker-images + - build-docker-images-ubuntu + environment: + DOCKER_PASSWORD: + from_secret: docker_password + DOCKER_USER: + from_secret: docker_username + GCP_KEY: + from_secret: gcp_key + image: google/cloud-sdk + name: publish-images-grafana-oss + volumes: + - name: docker + path: /var/run/docker.sock - commands: - ./scripts/circle-release-canary-packages.sh depends_on: @@ -814,7 +853,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -892,7 +931,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -905,10 +944,11 @@ steps: - rm gcpkey.json - cp C:\App\nssm-2.24.zip . - .\grabpl.exe gen-version --build-id $$env:DRONE_BUILD_NUMBER - - .\grabpl.exe windows-installer --edition oss --build-id $$env:DRONE_BUILD_NUMBER + - .\grabpl.exe windows-installer --edition oss --packages-bucket grafana-downloads + --build-id $$env:DRONE_BUILD_NUMBER - $$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0] - - gsutil cp $$fname gs://%PRERELEASE_BUCKET%/artifacts/downloads/oss/main/ - - gsutil cp "$$fname.sha256" gs://%PRERELEASE_BUCKET%/artifacts/downloads/oss/main/ + - gsutil cp $$fname gs://grafana-downloads/oss/main/ + - gsutil cp "$$fname.sha256" gs://grafana-downloads/oss/main/ depends_on: - initialize environment: @@ -946,7 +986,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1029,7 +1069,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1127,8 +1167,6 @@ steps: image: grafana/build-container:1.4.9 name: copy-packages-for-docker - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition oss --shouldSave depends_on: - copy-packages-for-docker @@ -1136,13 +1174,11 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images + name: build-docker-images volumes: - name: docker path: /var/run/docker.sock - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition oss --shouldSave --ubuntu depends_on: - copy-packages-for-docker @@ -1150,7 +1186,7 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images-ubuntu + name: build-docker-images-ubuntu volumes: - name: docker path: /var/run/docker.sock @@ -1212,7 +1248,7 @@ steps: image: grafana/build-container:1.4.9 name: build-storybook - commands: - - ./bin/grabpl upload-cdn --edition oss --bucket "$${PRERELEASE_BUCKET}/artifacts/static-assets" + - ./bin/grabpl upload-cdn --edition oss --bucket "$${PRERELEASE_BUCKET}" depends_on: - grafana-server environment: @@ -1304,7 +1340,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1424,7 +1460,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1508,7 +1544,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1567,7 +1603,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1699,8 +1735,6 @@ steps: image: grafana/build-container:1.4.9 name: copy-packages-for-docker - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition enterprise --shouldSave depends_on: - copy-packages-for-docker @@ -1708,13 +1742,11 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images + name: build-docker-images volumes: - name: docker path: /var/run/docker.sock - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition enterprise --shouldSave --ubuntu depends_on: - copy-packages-for-docker @@ -1722,7 +1754,7 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images-ubuntu + name: build-docker-images-ubuntu volumes: - name: docker path: /var/run/docker.sock @@ -1776,7 +1808,7 @@ steps: image: cypress/included:8.4.1 name: end-to-end-tests-various-suite - commands: - - ./bin/grabpl upload-cdn --edition enterprise --bucket "$${PRERELEASE_BUCKET}/artifacts/static-assets" + - ./bin/grabpl upload-cdn --edition enterprise --bucket "$${PRERELEASE_BUCKET}" depends_on: - package environment: @@ -1819,7 +1851,7 @@ steps: image: grafana/build-container:1.4.9 name: package-enterprise2 - commands: - - ./bin/grabpl upload-cdn --edition enterprise2 --bucket "$${PRERELEASE_BUCKET}/artifacts/static-assets" + - ./bin/grabpl upload-cdn --edition enterprise2 --bucket "$${PRERELEASE_BUCKET}" depends_on: - package-enterprise2 environment: @@ -1877,7 +1909,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2049,7 +2081,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2177,7 +2209,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2252,7 +2284,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2274,8 +2306,8 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --version-tag ${TAG} --dockerhub-repo grafana - --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 + - ./bin/grabpl artifacts docker publish --dockerhub-repo grafana --base alpine --base + ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag ${TAG} depends_on: - fetch-images-oss environment: @@ -2291,8 +2323,8 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --version-tag ${TAG} --dockerhub-repo grafana-oss - --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 + - ./bin/grabpl artifacts docker publish --dockerhub-repo grafana-oss --base alpine + --base ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag ${TAG} depends_on: - fetch-images-oss environment: @@ -2330,7 +2362,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2352,8 +2384,8 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --version-tag ${TAG} --dockerhub-repo grafana-enterprise - --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 + - ./bin/grabpl artifacts docker publish --dockerhub-repo grafana-enterprise --base + alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag ${TAG} depends_on: - fetch-images-enterprise environment: @@ -2391,7 +2423,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2413,8 +2445,8 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --security --version-tag ${TAG} --dockerhub-repo - grafana --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 + - ./bin/grabpl artifacts docker publish --security --dockerhub-repo grafana --base + alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag ${TAG} depends_on: - fetch-images-oss environment: @@ -2430,8 +2462,9 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --security --version-tag ${TAG} --dockerhub-repo - grafana-oss --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 + - ./bin/grabpl artifacts docker publish --security --dockerhub-repo grafana-oss + --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag + ${TAG} depends_on: - fetch-images-oss environment: @@ -2469,7 +2502,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2491,9 +2524,9 @@ steps: - name: docker path: /var/run/docker.sock - commands: - - ./bin/grabpl artifacts docker publish --security --version-tag ${TAG} --dockerhub-repo - grafana-enterprise --base alpine --base ubuntu --arch amd64 --arch arm64 --arch - armv7 + - ./bin/grabpl artifacts docker publish --security --dockerhub-repo grafana-enterprise + --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7 --version-tag + ${TAG} depends_on: - fetch-images-enterprise environment: @@ -2531,7 +2564,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2567,7 +2600,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2614,7 +2647,7 @@ steps: name: initialize - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2662,7 +2695,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2727,7 +2760,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2822,8 +2855,6 @@ steps: image: grafana/build-container:1.4.9 name: copy-packages-for-docker - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition oss --shouldSave depends_on: - copy-packages-for-docker @@ -2831,13 +2862,11 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images + name: build-docker-images volumes: - name: docker path: /var/run/docker.sock - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition oss --shouldSave --ubuntu depends_on: - copy-packages-for-docker @@ -2845,7 +2874,7 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images-ubuntu + name: build-docker-images-ubuntu volumes: - name: docker path: /var/run/docker.sock @@ -2958,7 +2987,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3071,7 +3100,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3148,7 +3177,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3196,7 +3225,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3320,8 +3349,6 @@ steps: image: grafana/build-container:1.4.9 name: copy-packages-for-docker - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition enterprise --shouldSave depends_on: - copy-packages-for-docker @@ -3329,13 +3356,11 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images + name: build-docker-images volumes: - name: docker path: /var/run/docker.sock - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - - gcloud auth activate-service-account --key-file=/tmp/gcpkey.json - ./bin/grabpl build-docker --edition enterprise --shouldSave --ubuntu depends_on: - copy-packages-for-docker @@ -3343,7 +3368,7 @@ steps: GCP_KEY: from_secret: gcp_key image: google/cloud-sdk - name: package-docker-images-ubuntu + name: build-docker-images-ubuntu volumes: - name: docker path: /var/run/docker.sock @@ -3501,7 +3526,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3663,7 +3688,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3781,7 +3806,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.7/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3893,6 +3918,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: ccccf712cc34ebea0b3aaab48914f8019624b1838af29ec712e47b1f7bd9a104 +hmac: 0da106a38545ca721d8db7495f74dfedb04cd4535a43efb5dcbb8a76993f20da ... diff --git a/scripts/drone/pipelines/main.star b/scripts/drone/pipelines/main.star index f93c056ee48..420de691ba7 100644 --- a/scripts/drone/pipelines/main.star +++ b/scripts/drone/pipelines/main.star @@ -20,6 +20,7 @@ load( 'build_frontend_docs_step', 'copy_packages_for_docker_step', 'build_docker_images_step', + 'publish_images_step', 'postgres_integration_tests_step', 'mysql_integration_tests_step', 'redis_integration_tests_step', @@ -107,8 +108,10 @@ def get_steps(edition, is_downstream=False): frontend_metrics_step(edition=edition), build_frontend_docs_step(edition=edition), copy_packages_for_docker_step(), - build_docker_images_step(edition=edition, ver_mode=ver_mode, publish=publish), - build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=publish), + build_docker_images_step(edition=edition, ver_mode=ver_mode, publish=False), + build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=False), + publish_images_step(edition=edition, ver_mode=ver_mode, mode='', docker_repo='grafana', ubuntu=False), + publish_images_step(edition=edition, ver_mode=ver_mode, mode='', docker_repo='grafana-oss', ubuntu=True) ]) if include_enterprise2: diff --git a/scripts/drone/pipelines/release.star b/scripts/drone/pipelines/release.star index b0a1eddabaa..60f8e778e39 100644 --- a/scripts/drone/pipelines/release.star +++ b/scripts/drone/pipelines/release.star @@ -21,7 +21,7 @@ load( 'e2e_tests_step', 'build_storybook_step', 'copy_packages_for_docker_step', - 'package_docker_images_step', + 'build_docker_images_step', 'postgres_integration_tests_step', 'mysql_integration_tests_step', 'redis_integration_tests_step', @@ -34,7 +34,8 @@ load( 'store_packages_step', 'upload_cdn_step', 'validate_scuemata_step', - 'ensure_cuetsified_step' + 'ensure_cuetsified_step', + 'publish_images_step' ) load( @@ -113,27 +114,6 @@ def release_npm_packages_step(): ], } -def publish_images_step(edition, mode, docker_repo): - if mode == 'security': - mode = '--{} '.format(mode) - else: - mode = '' - return { - 'name': 'publish-images-{}'.format(docker_repo), - 'image': 'google/cloud-sdk', - 'environment': { - 'GCP_KEY': from_secret('gcp_key'), - 'DOCKER_USER': from_secret('docker_username'), - 'DOCKER_PASSWORD': from_secret('docker_password'), - }, - 'commands': ['./bin/grabpl artifacts docker publish {}--version-tag ${{TAG}} --dockerhub-repo {} --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7'.format(mode, docker_repo)], - 'depends_on': ['fetch-images-{}'.format(edition)], - 'volumes': [{ - 'name': 'docker', - 'path': '/var/run/docker.sock' - }], - } - def fetch_images_step(edition): return { 'name': 'fetch-images-{}'.format(edition), @@ -155,10 +135,10 @@ def publish_image_steps(version, mode, docker_repo, additional_docker_repo=""): steps = [ download_grabpl_step(), fetch_images_step(version), - publish_images_step(version, mode, docker_repo), + publish_images_step(version, 'release', mode, docker_repo), ] if additional_docker_repo != "": - steps.extend([publish_images_step(version, mode, additional_docker_repo)]) + steps.extend([publish_images_step(version, 'release', mode, additional_docker_repo)]) return steps @@ -220,8 +200,8 @@ def get_steps(edition, ver_mode): build_steps.extend([ package_step(edition=edition, ver_mode=ver_mode, include_enterprise2=include_enterprise2), copy_packages_for_docker_step(), - package_docker_images_step(edition=edition, ver_mode=ver_mode, publish=should_publish), - package_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=should_publish), + build_docker_images_step(edition=edition, ver_mode=ver_mode, publish=True), + build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=True), grafana_server_step(edition=edition), ]) diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index ba4865b622e..3a13a8e3c65 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,9 +1,8 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = 'v2.8.7' +grabpl_version = 'v2.8.9' build_image = 'grafana/build-container:1.4.9' publish_image = 'grafana/grafana-ci-deploy:1.3.1' -grafana_docker_image = 'grafana/drone-grafana-docker:0.3.2' deploy_docker_image = 'us.gcr.io/kubernetes-dev/drone/plugins/deploy-image' alpine_image = 'alpine:3.15' curl_image = 'byrnedo/alpine-curl:0.1.8' @@ -284,8 +283,10 @@ def store_storybook_step(edition, ver_mode): def upload_cdn_step(edition, ver_mode): + src_dir = '' if ver_mode == "release": - bucket = "$${PRERELEASE_BUCKET}/artifacts/static-assets" + bucket = "$${PRERELEASE_BUCKET}" + src_dir = " --src-dir artifacts/static-assets" else: bucket = "grafana-static-assets" @@ -694,8 +695,11 @@ def copy_packages_for_docker_step(): } -def package_docker_images_step(edition, ver_mode, archs=None, ubuntu=False, publish=False): - cmd = './bin/grabpl build-docker --edition {} --shouldSave'.format(edition) +def build_docker_images_step(edition, ver_mode, archs=None, ubuntu=False, publish=False): + cmd = './bin/grabpl build-docker --edition {}'.format(edition) + if publish: + cmd += ' --shouldSave' + ubuntu_sfx = '' if ubuntu: ubuntu_sfx = '-ubuntu' @@ -705,12 +709,10 @@ def package_docker_images_step(edition, ver_mode, archs=None, ubuntu=False, publ cmd += ' -archs {}'.format(','.join(archs)) return { - 'name': 'package-docker-images' + ubuntu_sfx, + 'name': 'build-docker-images' + ubuntu_sfx, 'image': 'google/cloud-sdk', 'depends_on': ['copy-packages-for-docker'], 'commands': [ - 'printenv GCP_KEY | base64 -d > /tmp/gcpkey.json', - 'gcloud auth activate-service-account --key-file=/tmp/gcpkey.json', cmd ], 'volumes': [{ @@ -722,27 +724,34 @@ def package_docker_images_step(edition, ver_mode, archs=None, ubuntu=False, publ }, } -def build_docker_images_step(edition, ver_mode, archs=None, ubuntu=False, publish=False): - ubuntu_sfx = '' - if ubuntu: - ubuntu_sfx = '-ubuntu' +def publish_images_step(edition, ver_mode, mode, docker_repo, ubuntu=False): + if mode == 'security': + mode = '--{} '.format(mode) + else: + mode = '' - settings = { - 'dry_run': not publish, - 'edition': edition, - 'ubuntu': ubuntu, - } + cmd = './bin/grabpl artifacts docker publish {}--dockerhub-repo {} --base alpine --base ubuntu --arch amd64 --arch arm64 --arch armv7'.format(mode, docker_repo) + + if ver_mode == 'release': + deps = ['fetch-images-{}'.format(edition)] + cmd += ' --version-tag ${TAG}' + else: + deps = ['build-docker-images', 'build-docker-images-ubuntu'] - if publish: - settings['username'] = from_secret('docker_user') - settings['password'] = from_secret('docker_password') - if archs: - settings['archs'] = ','.join(archs) return { - 'name': 'build-docker-images' + ubuntu_sfx, - 'image': grafana_docker_image, - 'depends_on': ['copy-packages-for-docker'], - 'settings': settings, + 'name': 'publish-images-{}'.format(docker_repo), + 'image': 'google/cloud-sdk', + 'environment': { + 'GCP_KEY': from_secret('gcp_key'), + 'DOCKER_USER': from_secret('docker_username'), + 'DOCKER_PASSWORD': from_secret('docker_password'), + }, + 'commands': [cmd], + 'depends_on': deps, + 'volumes': [{ + 'name': 'docker', + 'path': '/var/run/docker.sock' + }], } @@ -867,8 +876,6 @@ def upload_packages_step(edition, ver_mode, is_downstream=False): if ver_mode == 'main' and edition in ('enterprise', 'enterprise2') and not is_downstream: return None - packages_bucket = ' --packages-bucket $${PRERELEASE_BUCKET}/artifacts/downloads' + enterprise2_suffix(edition) - if ver_mode == 'release': packages_bucket = '$${{PRERELEASE_BUCKET}}/artifacts/downloads{}'.format(enterprise2_suffix(edition)) cmd = './bin/grabpl upload-packages --edition {} --packages-bucket {}'.format(edition, packages_bucket) @@ -966,6 +973,8 @@ def get_windows_steps(edition, ver_mode, is_downstream=False): dir = 'release' else: dir = 'main' + bucket = 'grafana-downloads' + bucket_part = ' --packages-bucket {}'.format(bucket) if not is_downstream: build_no = 'DRONE_BUILD_NUMBER' else: From 2adf2a1584ba57f59b33ad3415a8c35775362ada Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 15 Feb 2022 13:07:07 +0100 Subject: [PATCH 11/21] [v8.3.x] Bug: Update `upload-cdn` command args (#44979) * CI: Update `GCP_GRAFANA_UPLOAD_KEY` var name (#44303) * Update GCP_KEY var name * Rename GCP_GRAFANA_UPLOAD_KEY for upload-packages * Update grabpl (cherry picked from commit f96a6c10c50df17567885555bdd626788db5b497) * Update upload-cdn command args (#44966) (cherry picked from commit 67225d9cfcd9ca13b3dbf09393cd3c6bfa865078) --- .drone.yml | 47 +++++++++++++++++++----------------- scripts/drone/steps/lib.star | 6 ++--- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.drone.yml b/.drone.yml index d164fafc4b3..3cab367df15 100644 --- a/.drone.yml +++ b/.drone.yml @@ -788,18 +788,18 @@ steps: - end-to-end-tests-smoke-tests-suite - end-to-end-tests-various-suite environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/grafana-ci-deploy:1.3.1 name: upload-packages - commands: - - ./bin/grabpl upload-cdn --edition oss --bucket "grafana-static-assets" + - ./bin/grabpl upload-cdn --edition oss --src-bucket "grafana-static-assets" depends_on: - grafana-server environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1248,11 +1248,12 @@ steps: image: grafana/build-container:1.4.9 name: build-storybook - commands: - - ./bin/grabpl upload-cdn --edition oss --bucket "$${PRERELEASE_BUCKET}" + - ./bin/grabpl upload-cdn --edition oss --src-bucket "$${PRERELEASE_BUCKET}" --src-dir + artifacts/static-assets depends_on: - grafana-server environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1266,7 +1267,7 @@ steps: - end-to-end-tests-smoke-tests-suite - end-to-end-tests-various-suite environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1808,11 +1809,12 @@ steps: image: cypress/included:8.4.1 name: end-to-end-tests-various-suite - commands: - - ./bin/grabpl upload-cdn --edition enterprise --bucket "$${PRERELEASE_BUCKET}" + - ./bin/grabpl upload-cdn --edition enterprise --src-bucket "$${PRERELEASE_BUCKET}" + --src-dir artifacts/static-assets depends_on: - package environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1823,7 +1825,7 @@ steps: depends_on: - package environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1851,11 +1853,12 @@ steps: image: grafana/build-container:1.4.9 name: package-enterprise2 - commands: - - ./bin/grabpl upload-cdn --edition enterprise2 --bucket "$${PRERELEASE_BUCKET}" + - ./bin/grabpl upload-cdn --edition enterprise2 --src-bucket "$${PRERELEASE_BUCKET}" + --src-dir artifacts/static-assets depends_on: - package-enterprise2 environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -1866,7 +1869,7 @@ steps: depends_on: - package-enterprise2 environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -2936,11 +2939,11 @@ steps: image: grafana/build-container:1.4.9 name: build-storybook - commands: - - ./bin/grabpl upload-cdn --edition oss --bucket "grafana-static-assets" + - ./bin/grabpl upload-cdn --edition oss --src-bucket "grafana-static-assets" depends_on: - grafana-server environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -2954,7 +2957,7 @@ steps: - end-to-end-tests-smoke-tests-suite - end-to-end-tests-various-suite environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -3431,11 +3434,11 @@ steps: image: grafana/build-container:1.4.9 name: build-storybook - commands: - - ./bin/grabpl upload-cdn --edition enterprise --bucket "grafana-static-assets" + - ./bin/grabpl upload-cdn --edition enterprise --src-bucket "grafana-static-assets" depends_on: - package environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -3446,7 +3449,7 @@ steps: depends_on: - package environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -3474,11 +3477,11 @@ steps: image: grafana/build-container:1.4.9 name: package-enterprise2 - commands: - - ./bin/grabpl upload-cdn --edition enterprise2 --bucket "grafana-static-assets" + - ./bin/grabpl upload-cdn --edition enterprise2 --src-bucket "grafana-static-assets" depends_on: - package-enterprise2 environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -3489,7 +3492,7 @@ steps: depends_on: - package-enterprise2 environment: - GCP_GRAFANA_UPLOAD_KEY: + GCP_KEY: from_secret: gcp_key PRERELEASE_BUCKET: from_secret: prerelease_bucket @@ -3918,6 +3921,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 0da106a38545ca721d8db7495f74dfedb04cd4535a43efb5dcbb8a76993f20da +hmac: 03249969373db3fdb895c2eb3ffe3024c95d028ae182e016c41f9ab277b9e6a4 ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 3a13a8e3c65..a168aed41fa 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -305,11 +305,11 @@ def upload_cdn_step(edition, ver_mode): 'image': publish_image, 'depends_on': deps, 'environment': { - 'GCP_GRAFANA_UPLOAD_KEY': from_secret('gcp_key'), + 'GCP_KEY': from_secret('gcp_key'), 'PRERELEASE_BUCKET': from_secret(prerelease_bucket) }, 'commands': [ - './bin/grabpl upload-cdn --edition {} --bucket "{}"'.format(edition, bucket), + './bin/grabpl upload-cdn --edition {} --src-bucket "{}"{}'.format(edition, bucket, src_dir), ], } @@ -897,7 +897,7 @@ def upload_packages_step(edition, ver_mode, is_downstream=False): 'image': publish_image, 'depends_on': deps, 'environment': { - 'GCP_GRAFANA_UPLOAD_KEY': from_secret('gcp_key'), + 'GCP_KEY': from_secret('gcp_key'), 'PRERELEASE_BUCKET': from_secret('prerelease_bucket'), }, 'commands': [cmd, ], From c9411b4d57582ebbc0509b597af3b01f5cb71d2a Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 15 Feb 2022 14:08:09 +0100 Subject: [PATCH 12/21] Alerting: do not unescape external AM label values (#45334) (#45393) (cherry picked from commit 651bb773dbf45148127ae404bc46676b9976dcc6) Co-authored-by: Gilles De Mey --- .../alerting/unified/utils/alertmanager.test.ts | 17 ++++++++++++----- .../alerting/unified/utils/alertmanager.ts | 10 +--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/public/app/features/alerting/unified/utils/alertmanager.test.ts b/public/app/features/alerting/unified/utils/alertmanager.test.ts index c5495df3612..e6dc39b1d33 100644 --- a/public/app/features/alerting/unified/utils/alertmanager.test.ts +++ b/public/app/features/alerting/unified/utils/alertmanager.test.ts @@ -31,16 +31,23 @@ describe('Alertmanager utils', () => { }); }); - it('should parse escaped values correctly', () => { - expect(parseMatcher('foo=~"bar\\"baz\\""')).toEqual({ + // Alertmanager has some strict requirements for label values; + // we should not automatically encode or decode any values sent + // and instead let AM return any errors like (matcher value contains unescaped double quote: bar"baz") + // and allow the user to update the values to the correct format + // + // see https://github.com/prometheus/alertmanager/blob/4030e3670b359b8814aa8340ea1144f32b1f5ab3/pkg/labels/parse.go#L55-L99 + // and https://github.com/prometheus/alertmanager/blob/4030e3670b359b8814aa8340ea1144f32b1f5ab3/pkg/labels/parse.go#L101-L178 + it('should not parse escaped values', () => { + expect(parseMatcher('foo="^[a-z0-9-]{1}[a-z0-9-]{0,30}$"')).toEqual({ name: 'foo', - value: 'bar"baz"', - isRegex: true, + value: '"^[a-z0-9-]{1}[a-z0-9-]{0,30}$"', + isRegex: false, isEqual: true, }); expect(parseMatcher('foo=~bar\\"baz\\"')).toEqual({ name: 'foo', - value: 'bar"baz"', + value: 'bar\\"baz\\"', isRegex: true, isEqual: true, }); diff --git a/public/app/features/alerting/unified/utils/alertmanager.ts b/public/app/features/alerting/unified/utils/alertmanager.ts index 634208c161f..304e06b35a0 100644 --- a/public/app/features/alerting/unified/utils/alertmanager.ts +++ b/public/app/features/alerting/unified/utils/alertmanager.ts @@ -92,14 +92,6 @@ const matcherOperators = [ MatcherOperator.equal, ]; -function unescapeMatcherValue(value: string) { - let trimmed = value.trim().replace(/\\"/g, '"'); - if (trimmed.startsWith('"') && trimmed.endsWith('"') && !trimmed.endsWith('\\"')) { - trimmed = trimmed.substr(1, trimmed.length - 2); - } - return trimmed.replace(/\\"/g, '"'); -} - export function parseMatcher(matcher: string): Matcher { const trimmed = matcher.trim(); if (trimmed.startsWith('{') && trimmed.endsWith('}')) { @@ -115,7 +107,7 @@ export function parseMatcher(matcher: string): Matcher { } const [operator, idx] = operatorsFound[0]; const name = trimmed.substr(0, idx).trim(); - const value = unescapeMatcherValue(trimmed.substr(idx + operator.length).trim()); + const value = trimmed.substr(idx + operator.length).trim(); if (!name) { throw new Error(`Invalid matcher: ${trimmed}`); } From 3bcf3f50b716b3dcf5b5d78ef30e2f2b0bf96760 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Wed, 16 Feb 2022 10:54:30 +0200 Subject: [PATCH 13/21] CI: Remove manual `gcloud` authentication (#44986) (#45445) * Remove manual gcloud auth from store-packages * Update grabpl (cherry picked from commit 163b570f5ded71760c1551b87013d1e29ac20839) --- .drone.yml | 69 +++++++++++++++++------------------- scripts/drone/steps/lib.star | 3 +- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3cab367df15..25c10f0c1d5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -110,7 +110,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -329,7 +329,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -400,7 +400,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -500,7 +500,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -853,7 +853,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -931,7 +931,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -986,7 +986,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -999,7 +999,6 @@ steps: image: grafana/build-container:1.4.9 name: initialize - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - ./bin/grabpl store-packages --edition oss --gcp-key /tmp/gcpkey.json --build-id ${DRONE_BUILD_NUMBER} depends_on: @@ -1069,7 +1068,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1341,7 +1340,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1461,7 +1460,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1545,7 +1544,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1604,7 +1603,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1912,7 +1911,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2084,7 +2083,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2212,7 +2211,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2287,7 +2286,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2365,7 +2364,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2426,7 +2425,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2505,7 +2504,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2567,7 +2566,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2603,7 +2602,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2650,7 +2649,7 @@ steps: name: initialize - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2698,12 +2697,11 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - ./bin/grabpl store-packages --edition oss --packages-bucket grafana-downloads --gcp-key /tmp/gcpkey.json ${DRONE_TAG} depends_on: @@ -2722,7 +2720,6 @@ steps: image: grafana/grafana-ci-deploy:1.3.1 name: store-packages-oss - commands: - - printenv GCP_KEY | base64 -d > /tmp/gcpkey.json - ./bin/grabpl store-packages --edition enterprise --packages-bucket grafana-downloads --gcp-key /tmp/gcpkey.json ${DRONE_TAG} depends_on: @@ -2763,7 +2760,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2990,7 +2987,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3103,7 +3100,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3180,7 +3177,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3228,7 +3225,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3529,7 +3526,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3691,7 +3688,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3809,7 +3806,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.8.9/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3921,6 +3918,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 03249969373db3fdb895c2eb3ffe3024c95d028ae182e016c41f9ab277b9e6a4 +hmac: c46c4eca99016c287ca32681b043500470d166f10e7d09f4112adc9f2f4f043d ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index a168aed41fa..6f7b1377ad7 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,6 +1,6 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = 'v2.8.9' +grabpl_version = 'v2.9.0' build_image = 'grafana/build-container:1.4.9' publish_image = 'grafana/grafana-ci-deploy:1.3.1' deploy_docker_image = 'us.gcr.io/kubernetes-dev/drone/plugins/deploy-image' @@ -934,7 +934,6 @@ def store_packages_step(edition, ver_mode, is_downstream=False): 'GPG_KEY_PASSWORD': from_secret('gpg_key_password'), }, 'commands': [ - 'printenv GCP_KEY | base64 -d > /tmp/gcpkey.json', cmd, ], } From d748a2d1e02b2848bc07131d578cf57f2babcbea Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Thu, 17 Feb 2022 16:40:23 +0100 Subject: [PATCH 14/21] Docs: Remove docs publish GitHub action (#45539) --- .github/workflows/publish.yml | 49 ----------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2420921c2fa..00000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: publish_docs - -on: - push: - branches: - - v8.3.x - paths: - - 'docs/sources/**' - - 'packages/grafana-*/**' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - run: git clone --single-branch --no-tags --depth 1 -b master https://grafanabot:${{ secrets.GH_BOT_ACCESS_TOKEN }}@github.com/grafana/website-sync ./.github/actions/website-sync - - name: generate-packages-docs - uses: actions/setup-node@v2.4.1 - id: generate-docs - with: - node-version: '14' - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2.1.6 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - yarn- - - run: yarn install --immutable - - run: ./scripts/ci-reference-docs-build.sh - - name: publish-to-git - uses: ./.github/actions/website-sync - id: publish - with: - repository: grafana/website - branch: master - host: github.com - github_pat: '${{ secrets.GH_BOT_ACCESS_TOKEN }}' - source_folder: docs/sources - target_folder: content/docs/grafana/latest - allow_no_changes: 'true' - - shell: bash - run: | - test -n "${{ steps.publish.outputs.commit_hash }}" - test -n "${{ steps.publish.outputs.working_directory }}" From b48b55dc14a4f22b28fda23ffebd634ec72ea9ea Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Fri, 18 Feb 2022 11:51:40 +0200 Subject: [PATCH 15/21] Update grabpl (#45520) (#45526) (cherry picked from commit af1691dbfb1fa060d44cce1163d7fccd5fc271fb) --- .drone.yml | 66 ++++++++++++++++++------------------ scripts/drone/steps/lib.star | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.drone.yml b/.drone.yml index 25c10f0c1d5..36b1cc55669 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -110,7 +110,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -329,7 +329,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -400,7 +400,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -500,7 +500,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -853,7 +853,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -931,7 +931,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -986,7 +986,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1068,7 +1068,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1340,7 +1340,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1460,7 +1460,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1544,7 +1544,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1603,7 +1603,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1911,7 +1911,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2083,7 +2083,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2211,7 +2211,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2286,7 +2286,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2364,7 +2364,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2425,7 +2425,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2504,7 +2504,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2566,7 +2566,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2602,7 +2602,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2649,7 +2649,7 @@ steps: name: initialize - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2697,7 +2697,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2760,7 +2760,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2987,7 +2987,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3100,7 +3100,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3177,7 +3177,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3225,7 +3225,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3526,7 +3526,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3688,7 +3688,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3806,7 +3806,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.0/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3918,6 +3918,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: c46c4eca99016c287ca32681b043500470d166f10e7d09f4112adc9f2f4f043d +hmac: 3f901be683b7063cb462b0a6e26aaf29ec12d9c634edb9a25cf47f2d3bc52045 ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 6f7b1377ad7..05feebefc95 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,6 +1,6 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = 'v2.9.0' +grabpl_version = 'v2.9.1' build_image = 'grafana/build-container:1.4.9' publish_image = 'grafana/grafana-ci-deploy:1.3.1' deploy_docker_image = 'us.gcr.io/kubernetes-dev/drone/plugins/deploy-image' From b688a9dede397c2662305306a1b384fc616f4305 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Mon, 21 Feb 2022 16:50:16 +0200 Subject: [PATCH 16/21] CI: Introduce docs pipeline (#45454) (#45670) --- .drone.star | 3 +- .drone.yml | 151 ++++++++++++++++++++---------- scripts/drone/pipelines/docs.star | 55 +++++++++++ scripts/drone/pipelines/pr.star | 13 ++- scripts/drone/steps/lib.star | 2 +- 5 files changed, 170 insertions(+), 54 deletions(-) create mode 100644 scripts/drone/pipelines/docs.star diff --git a/.drone.star b/.drone.star index f025f8df415..d2723f88be8 100644 --- a/.drone.star +++ b/.drone.star @@ -6,6 +6,7 @@ load('scripts/drone/pipelines/pr.star', 'pr_pipelines') load('scripts/drone/pipelines/main.star', 'main_pipelines') +load('scripts/drone/pipelines/docs.star', 'docs_pipelines') load('scripts/drone/pipelines/release.star', 'release_pipelines', 'publish_image_pipelines', 'publish_artifacts_pipelines', 'publish_npm_pipelines', 'publish_packages_pipeline') load('scripts/drone/version.star', 'version_branch_pipelines') load('scripts/drone/pipelines/cron.star', 'cronjobs') @@ -13,7 +14,7 @@ load('scripts/drone/vault.star', 'secrets') def main(ctx): edition = 'oss' - return pr_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \ + return pr_pipelines(edition=edition) + docs_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \ publish_image_pipelines('public') + publish_image_pipelines('security') + \ publish_artifacts_pipelines('security') + publish_artifacts_pipelines('public') + \ publish_npm_pipelines('public') + publish_packages_pipeline() + \ diff --git a/.drone.yml b/.drone.yml index 36b1cc55669..19600094d0c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -92,6 +92,9 @@ steps: trigger: event: - pull_request + paths: + exclude: + - docs/** type: docker volumes: - host: @@ -110,7 +113,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -255,20 +258,6 @@ steps: failure: always image: grafana/docker-puppeteer:1.0.0 name: test-a11y-frontend -- commands: - - ./scripts/ci-reference-docs-lint.sh ci - depends_on: - - build-frontend - image: grafana/build-container:1.4.9 - name: build-frontend-docs -- commands: - - mkdir -p /hugo/content/docs/grafana - - cp -r docs/sources/* /hugo/content/docs/grafana/latest/ - - cd /hugo && make prod - depends_on: - - build-frontend-docs - image: grafana/docs-base:latest - name: build-docs-website - commands: - ls dist/*.tar.gz* - cp dist/*.tar.gz* packaging/docker/ @@ -291,6 +280,9 @@ steps: trigger: event: - pull_request + paths: + exclude: + - docs/** type: docker volumes: - host: @@ -329,7 +321,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -376,6 +368,9 @@ steps: trigger: event: - pull_request + paths: + exclude: + - docs/** type: docker volumes: - host: @@ -390,6 +385,68 @@ volumes: --- depends_on: [] kind: pipeline +name: pr-docs +node: + type: no-parallel +platform: + arch: amd64 + os: linux +services: [] +steps: +- commands: + - mkdir -p bin + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - chmod +x bin/grabpl + image: byrnedo/alpine-curl:0.1.8 + name: grabpl +- commands: + - echo $DRONE_RUNNER_NAME + image: alpine:3.15 + name: identify-runner +- commands: + - make gen-go + - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} + - yarn install --immutable + image: grafana/build-container:1.4.9 + name: initialize +- commands: + - ./bin/grabpl build-frontend --jobs 8 --no-install-deps --edition oss --build-id + ${DRONE_BUILD_NUMBER} --no-pull-enterprise + depends_on: + - initialize + environment: + NODE_OPTIONS: --max_old_space_size=8192 + image: grafana/build-container:1.4.9 + name: build-frontend +- commands: + - ./scripts/ci-reference-docs-lint.sh ci + depends_on: + - build-frontend + image: grafana/build-container:1.4.9 + name: build-frontend-docs +- commands: + - mkdir -p /hugo/content/docs/grafana + - cp -r docs/sources/* /hugo/content/docs/grafana/latest/ + - cd /hugo && make prod + depends_on: + - build-frontend-docs + image: grafana/docs-base:latest + name: build-docs-website +trigger: + event: + - pull_request + paths: + include: + - docs/** + - packages/** +type: docker +volumes: +- host: + path: /var/run/docker.sock + name: docker +--- +depends_on: [] +kind: pipeline name: main-test node: type: no-parallel @@ -400,7 +457,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -500,7 +557,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -853,7 +910,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -931,7 +988,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -986,7 +1043,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1068,7 +1125,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1340,7 +1397,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1460,7 +1517,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1544,7 +1601,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1603,7 +1660,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1911,7 +1968,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2083,7 +2140,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2211,7 +2268,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2286,7 +2343,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2364,7 +2421,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2425,7 +2482,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2504,7 +2561,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2566,7 +2623,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2602,7 +2659,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2649,7 +2706,7 @@ steps: name: initialize - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2697,7 +2754,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2760,7 +2817,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2987,7 +3044,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3100,7 +3157,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3177,7 +3234,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3225,7 +3282,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3526,7 +3583,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3688,7 +3745,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3806,7 +3863,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.1/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3918,6 +3975,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 3f901be683b7063cb462b0a6e26aaf29ec12d9c634edb9a25cf47f2d3bc52045 +hmac: 8974ec5a7361f3f45c50c38ef5f28cd51c14d8db34ed3409bf74b864d312632b ... diff --git a/scripts/drone/pipelines/docs.star b/scripts/drone/pipelines/docs.star new file mode 100644 index 00000000000..2bbe1088a26 --- /dev/null +++ b/scripts/drone/pipelines/docs.star @@ -0,0 +1,55 @@ +load( + 'scripts/drone/steps/lib.star', + 'initialize_step', + 'download_grabpl_step', + 'lint_frontend_step', + 'codespell_step', + 'shellcheck_step', + 'build_frontend_step', + 'test_frontend_step', + 'build_storybook_step', + 'build_frontend_docs_step', + 'build_docs_website_step', +) + +load( + 'scripts/drone/services/services.star', + 'integration_test_services', + 'ldap_service', +) + +load( + 'scripts/drone/utils/utils.star', + 'pipeline', +) + +ver_mode = 'pr' + +def docs_pipelines(edition): + steps = [download_grabpl_step()] + initialize_step(edition, platform='linux', ver_mode=ver_mode) + steps.extend([ + build_frontend_step(edition=edition, ver_mode=ver_mode), + ]) + + # Insert remaining steps + steps.extend([ + build_frontend_docs_step(edition=edition), + build_docs_website_step(), + ]) + + trigger = { + 'event': [ + 'pull_request', + ], + 'paths': { + 'include': [ + 'docs/**', + 'packages/**', + ], + }, + } + return [ + pipeline( + name='pr-docs', edition=edition, trigger=trigger, services=[], steps=steps, + ), + ] diff --git a/scripts/drone/pipelines/pr.star b/scripts/drone/pipelines/pr.star index 464cc1a3464..8b9552b6ca4 100644 --- a/scripts/drone/pipelines/pr.star +++ b/scripts/drone/pipelines/pr.star @@ -17,8 +17,6 @@ load( 'grafana_server_step', 'e2e_tests_step', 'build_storybook_step', - 'build_frontend_docs_step', - 'build_docs_website_step', 'copy_packages_for_docker_step', 'build_docker_images_step', 'postgres_integration_tests_step', @@ -96,8 +94,6 @@ def pr_pipelines(edition): e2e_tests_step('various-suite', edition=edition), build_storybook_step(edition=edition, ver_mode=ver_mode), test_a11y_frontend_step(ver_mode=ver_mode, edition=edition), - build_frontend_docs_step(edition=edition), - build_docs_website_step(), copy_packages_for_docker_step(), build_docker_images_step(edition=edition, ver_mode=ver_mode, archs=['amd64',]), ]) @@ -112,7 +108,14 @@ def pr_pipelines(edition): ]) trigger = { - 'event': ['pull_request',], + 'event': [ + 'pull_request', + ], + 'paths': { + 'exclude': [ + 'docs/**', + ], + }, } return [ diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 05feebefc95..08059d83022 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,6 +1,6 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = 'v2.9.1' +grabpl_version = 'v2.9.3' build_image = 'grafana/build-container:1.4.9' publish_image = 'grafana/grafana-ci-deploy:1.3.1' deploy_docker_image = 'us.gcr.io/kubernetes-dev/drone/plugins/deploy-image' From 1db431b5cf08399d2c14e0a7b7d17e67acbb474b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 23 Feb 2022 07:47:09 -0600 Subject: [PATCH 17/21] bump go version to 1.17.7 (#45772) (#45782) (cherry picked from commit b512a3d75faa85ce7877c31523508460890a47eb) Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com> --- Dockerfile | 2 +- Dockerfile.ubuntu | 2 +- scripts/build/ci-build/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e70ed3f1742..44e1179bd6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY emails emails ENV NODE_ENV production RUN yarn build -FROM golang:1.17.6-alpine3.15 as go-builder +FROM golang:1.17.7-alpine3.15 as go-builder RUN apk add --no-cache gcc g++ make diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 256962b373d..4bcf1a82894 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -21,7 +21,7 @@ COPY emails emails ENV NODE_ENV production RUN yarn build -FROM golang:1.17.6 AS go-builder +FROM golang:1.17.7 AS go-builder WORKDIR /src/grafana diff --git a/scripts/build/ci-build/Dockerfile b/scripts/build/ci-build/Dockerfile index dbff90398da..6f56ca72761 100644 --- a/scripts/build/ci-build/Dockerfile +++ b/scripts/build/ci-build/Dockerfile @@ -110,7 +110,7 @@ RUN rm dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz # Use old Debian (this has support into 2022) in order to ensure binary compatibility with older glibc's. FROM debian:stretch-20210208 -ENV GOVERSION=1.17.6 \ +ENV GOVERSION=1.17.7 \ PATH=/usr/local/go/bin:$PATH \ GOPATH=/go \ NODEVERSION=16.13.0-1nodesource1 \ From 6e75734bd57c5d9fc0948f85af5b846f0d7b2a1c Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Mon, 28 Feb 2022 12:25:46 +0200 Subject: [PATCH 18/21] DockerHub: Use `grafana(-oss)-image-tags` to push to `grafana(-oss)-dev` DockerHub repo (#45708) (#45711) * Revert back changes - changes are done on grabpl * Sync drone (cherry picked from commit 3db331402dd5c7f4b6be0dda498a66d4cb8c213a) --- .drone.yml | 68 ++++++++++++++++++------------------ scripts/drone/steps/lib.star | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.drone.yml b/.drone.yml index 19600094d0c..a0b640c43f4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -113,7 +113,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -321,7 +321,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -395,7 +395,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -457,7 +457,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -557,7 +557,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -910,7 +910,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -988,7 +988,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1043,7 +1043,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1125,7 +1125,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1397,7 +1397,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1517,7 +1517,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1601,7 +1601,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1660,7 +1660,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1968,7 +1968,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2140,7 +2140,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2268,7 +2268,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2343,7 +2343,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2421,7 +2421,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2482,7 +2482,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2561,7 +2561,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2623,7 +2623,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2659,7 +2659,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2706,7 +2706,7 @@ steps: name: initialize - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2754,7 +2754,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2817,7 +2817,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3044,7 +3044,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3157,7 +3157,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3234,7 +3234,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3282,7 +3282,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3583,7 +3583,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3745,7 +3745,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3863,7 +3863,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.3/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3975,6 +3975,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 8974ec5a7361f3f45c50c38ef5f28cd51c14d8db34ed3409bf74b864d312632b +hmac: a39cc6926bbf02f091f7867ea09f2f818d83451aa1125955f6993a5bc1bf7c10 ... diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 08059d83022..7b0ae013de7 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,6 +1,6 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = 'v2.9.3' +grabpl_version = 'v2.9.4' build_image = 'grafana/build-container:1.4.9' publish_image = 'grafana/grafana-ci-deploy:1.3.1' deploy_docker_image = 'us.gcr.io/kubernetes-dev/drone/plugins/deploy-image' From 274cd740a572235114949edaa72b74102cba1a7b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:34:26 -0600 Subject: [PATCH 19/21] Middleware: Fix IPv6 host parsing in CSRF check (#45911) (#45983) - Also create tests for this middleware Co-authored-by: Kyle Brandt (cherry picked from commit 06ed5efdf09efeaffa766f0009f5272f05e808c7) Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com> --- pkg/api/http_server.go | 2 +- pkg/middleware/csrf.go | 19 ++++-- pkg/middleware/csrf_test.go | 124 ++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 pkg/middleware/csrf_test.go diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index cfe1cb1cc98..54c3208c044 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -422,7 +422,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() { } m.Use(middleware.Recovery(hs.Cfg)) - m.UseMiddleware(middleware.CSRF(hs.Cfg.LoginCookieName)) + m.UseMiddleware(middleware.CSRF(hs.Cfg.LoginCookieName, hs.log)) hs.mapStatic(m, hs.Cfg.StaticRootPath, "build", "public/build") hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public") diff --git a/pkg/middleware/csrf.go b/pkg/middleware/csrf.go index bc70d09779d..7bce53f5666 100644 --- a/pkg/middleware/csrf.go +++ b/pkg/middleware/csrf.go @@ -4,10 +4,12 @@ import ( "errors" "net/http" "net/url" - "strings" + + "github.com/grafana/grafana/pkg/infra/log" + "github.com/grafana/grafana/pkg/util" ) -func CSRF(loginCookieName string) func(http.Handler) http.Handler { +func CSRF(loginCookieName string, logger log.Logger) func(http.Handler) http.Handler { // As per RFC 7231/4.2.2 these methods are idempotent: // (GET is excluded because it may have side effects in some APIs) safeMethods := []string{"HEAD", "OPTIONS", "TRACE"} @@ -27,12 +29,21 @@ func CSRF(loginCookieName string) func(http.Handler) http.Handler { } } // Otherwise - verify that Origin matches the server origin - host := strings.Split(r.Host, ":")[0] + netAddr, err := util.SplitHostPortDefault(r.Host, "", "0") // we ignore the port + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + origin, err := url.Parse(r.Header.Get("Origin")) - if err != nil || (origin.String() != "" && origin.Hostname() != host) { + if err != nil { + logger.Error("error parsing Origin header", "err", err) + } + if err != nil || netAddr.Host == "" || (origin.String() != "" && origin.Hostname() != netAddr.Host) { http.Error(w, "origin not allowed", http.StatusForbidden) return } + next.ServeHTTP(w, r) }) } diff --git a/pkg/middleware/csrf_test.go b/pkg/middleware/csrf_test.go new file mode 100644 index 00000000000..351810fe7b9 --- /dev/null +++ b/pkg/middleware/csrf_test.go @@ -0,0 +1,124 @@ +package middleware + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/grafana/grafana/pkg/infra/log" + "github.com/stretchr/testify/require" +) + +func TestMiddlewareCSRF(t *testing.T) { + tests := []struct { + name string + cookieName string + method string + origin string + host string + code int + }{ + { + name: "mismatched origin and host is forbidden", + cookieName: "foo", + method: "GET", + origin: "http://notLocalhost", + host: "localhost", + code: http.StatusForbidden, + }, + { + name: "mismatched origin and host is NOT forbidden with a 'Safe Method'", + cookieName: "foo", + method: "TRACE", + origin: "http://notLocalhost", + host: "localhost", + code: http.StatusOK, + }, + { + name: "mismatched origin and host is NOT forbidden without a cookie", + cookieName: "", + method: "GET", + origin: "http://notLocalhost", + host: "localhost", + code: http.StatusOK, + }, + { + name: "malformed host is a bad request", + cookieName: "foo", + method: "GET", + host: "localhost:80:80", + code: http.StatusBadRequest, + }, + { + name: "host works without port", + cookieName: "foo", + method: "GET", + host: "localhost", + origin: "http://localhost", + code: http.StatusOK, + }, + { + name: "port does not have to match", + cookieName: "foo", + method: "GET", + host: "localhost:80", + origin: "http://localhost:3000", + code: http.StatusOK, + }, + { + name: "IPv6 host works with port", + cookieName: "foo", + method: "GET", + host: "[::1]:3000", + origin: "http://[::1]:3000", + code: http.StatusOK, + }, + { + name: "IPv6 host (with longer address) works with port", + cookieName: "foo", + method: "GET", + host: "[2001:db8::1]:3000", + origin: "http://[2001:db8::1]:3000", + code: http.StatusOK, + }, + { + name: "IPv6 host (with longer address) works without port", + cookieName: "foo", + method: "GET", + host: "[2001:db8::1]", + origin: "http://[2001:db8::1]", + code: http.StatusOK, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + rr := csrfScenario(t, tt.cookieName, tt.method, tt.origin, tt.host) + require.Equal(t, tt.code, rr.Code) + }) + } +} + +func csrfScenario(t *testing.T, cookieName, method, origin, host string) *httptest.ResponseRecorder { + req, err := http.NewRequest(method, "/", nil) + if err != nil { + t.Fatal(err) + } + req.AddCookie(&http.Cookie{ + Name: cookieName, + }) + + // Note: Not sure where host header populates req.Host, or how that works. + req.Host = host + req.Header.Set("HOST", host) + + req.Header.Set("ORIGIN", origin) + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + }) + + rr := httptest.NewRecorder() + handler := CSRF(cookieName, log.New("test"))(testHandler) + handler.ServeHTTP(rr, req) + return rr +} From 03e8428caa482884d8317502c7987bc2bbc1b24f Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 28 Feb 2022 16:34:53 -0500 Subject: [PATCH 20/21] BarChart: fix single group rendering (#45953) (#45991) (cherry picked from commit 1c4b20b2686b38dfa2312dd0c36ec7fce777f493) Co-authored-by: Leon Sorokin --- public/app/plugins/panel/barchart/bars.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/panel/barchart/bars.ts b/public/app/plugins/panel/barchart/bars.ts index 83e1532ee70..f92b0b69963 100644 --- a/public/app/plugins/panel/barchart/bars.ts +++ b/public/app/plugins/panel/barchart/bars.ts @@ -91,7 +91,7 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) { // this expands the distr: 2 scale so that the indicies of each data[0] land at the proper justified positions const xRange: Scale.Range = (u, min, max) => { min = 0; - max = u.data[0].length - 1; + max = Math.max(1, u.data[0].length - 1); let pctOffset = 0; @@ -101,13 +101,17 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) { }); // expand scale range by equal amounts on both ends - let rn = max - min; // TODO: clamp to 1? + let rn = max - min; - let upScale = 1 / (1 - pctOffset * 2); - let offset = (upScale * rn - rn) / 2; + if (pctOffset === 0.5) { + min -= rn; + } else { + let upScale = 1 / (1 - pctOffset * 2); + let offset = (upScale * rn - rn) / 2; - min -= offset; - max += offset; + min -= offset; + max += offset; + } return [min, max]; }; From 433ff19f77c0ebbf3bc0332c83007a15f3af7ae2 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 1 Mar 2022 03:11:53 -0500 Subject: [PATCH 21/21] Histogram: auto-skip x tick labels to avoid overlap (#45996) (#46000) (cherry picked from commit b491d6b4dc5c768fa5f24d9e83f5485e0395a6ce) Co-authored-by: Leon Sorokin --- .../app/plugins/panel/histogram/Histogram.tsx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/histogram/Histogram.tsx b/public/app/plugins/panel/histogram/Histogram.tsx index a4b21980c2f..29115ecff96 100644 --- a/public/app/plugins/panel/histogram/Histogram.tsx +++ b/public/app/plugins/panel/histogram/Histogram.tsx @@ -15,7 +15,15 @@ import { getFieldSeriesColor, GrafanaTheme2, } from '@grafana/data'; -import { Themeable2, UPlotConfigBuilder, UPlotChart, VizLayout, PlotLegend } from '@grafana/ui'; +import { + Themeable2, + UPlotConfigBuilder, + UPlotChart, + VizLayout, + PlotLegend, + measureText, + UPLOT_AXIS_FONT_SIZE, +} from '@grafana/ui'; import { histogramBucketSizes, @@ -119,7 +127,20 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => { placement: AxisPlacement.Bottom, incrs: histogramBucketSizes, splits: xSplits, - values: (u: uPlot, vals: any[]) => vals.map(xAxisFormatter), + values: (u: uPlot, splits: any[]) => { + const tickLabels = splits.map(xAxisFormatter); + + const maxWidth = tickLabels.reduce( + (curMax, label) => Math.max(measureText(label, UPLOT_AXIS_FONT_SIZE).width, curMax), + 0 + ); + + const labelSpacing = 10; + const maxCount = u.bbox.width / ((maxWidth + labelSpacing) * devicePixelRatio); + const keepMod = Math.ceil(tickLabels.length / maxCount); + + return tickLabels.map((label, i) => (i % keepMod === 0 ? label : null)); + }, //incrs: () => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((mult) => mult * bucketSize), //splits: config.xSplits, //values: config.xValues,