From 90de23ccc2c194bb704bd8efda8e4c99a57d21e5 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Fri, 30 Aug 2024 12:26:22 -0400 Subject: [PATCH 1/2] `grafana/irm` tilt changes (#4964) Related to https://github.com/grafana/irm/pull/62 --- grafana-plugin/package.json | 2 +- grafana-plugin/playwright.config.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/grafana-plugin/package.json b/grafana-plugin/package.json index 2474ab4722..b90163977d 100644 --- a/grafana-plugin/package.json +++ b/grafana-plugin/package.json @@ -24,7 +24,7 @@ "test:e2e:watch": "yarn test:e2e --ui", "test:e2e-expensive:watch": "yarn test:e2e-expensive --ui", "test:e2e:gen": "yarn playwright codegen http://localhost:3000", - "e2e-show-report": "yarn playwright show-report", + "e2e-show-report": "yarn playwright show-report --port 31000", "generate-types": "cd ./src/network/oncall-api/types-generator && yarn generate", "watch": "NODE_ENV=development webpack -w -c ./webpack.config.ts --env development", "sign": "npx --yes @grafana/sign-plugin@latest", diff --git a/grafana-plugin/playwright.config.ts b/grafana-plugin/playwright.config.ts index 21b75543da..a0aa9d6bb1 100644 --- a/grafana-plugin/playwright.config.ts +++ b/grafana-plugin/playwright.config.ts @@ -27,7 +27,16 @@ export default defineConfig({ /* Maximum time all the tests can run for. */ globalTimeout: 20 * 60 * 1_000, // 20 minutes - reporter: [['html', { open: IS_CI ? 'never' : 'always' }]], + reporter: [ + [ + 'html', + { + open: IS_CI ? 'never' : 'always', + port: 31000, // explicitly specify a port for k8s port forwarding to avoid clashes with Incident and IRM + }, + ], + ['list', { printSteps: true }], + ], /* Maximum time one test can run for. */ timeout: 60_000, From 437620776c4765cb6297d21fd878ee33cd2a3508 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Fri, 30 Aug 2024 10:42:12 -0600 Subject: [PATCH 2/2] Plugin sync logging improvements (#4963) # What this PR does - Fix logging when no error - Add more logging to request errors during sync" ## Which issue(s) this PR closes Related to [issue link here] ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- grafana-plugin/pkg/plugin/sync.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grafana-plugin/pkg/plugin/sync.go b/grafana-plugin/pkg/plugin/sync.go index 249a10f532..72a1c6f636 100644 --- a/grafana-plugin/pkg/plugin/sync.go +++ b/grafana-plugin/pkg/plugin/sync.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "github.com/grafana/grafana-plugin-sdk-go/backend/log" + "io" "net/http" "net/url" "strconv" @@ -83,7 +84,7 @@ func (a *App) doSync(ctx context.Context, forceSend bool) { var cacheAlreadyLocked *SyncCacheAlreadyLocked if errors.As(err, &cacheAlreadyLocked) { log.DefaultLogger.Info("Skipping sync", "message", err) - } else { + } else if err != nil { log.DefaultLogger.Error("Error making sync request", "error", err) } }() @@ -175,6 +176,17 @@ func (a *App) makeSyncRequest(ctx context.Context, forceSend bool) error { } defer res.Body.Close() + if res.StatusCode != http.StatusOK { + bodyBytes, err := io.ReadAll(res.Body) + if err != nil { + log.DefaultLogger.Error("failed to read response body", "error", err, "status", res.StatusCode) + } else { + log.DefaultLogger.Error("sync not ok", "status", res.StatusCode, "message", string(bodyBytes)) + } + } else { + log.DefaultLogger.Info("sync ok", "status", res.StatusCode) + } + a.lastOnCallSync = onCallSync return nil }