diff --git a/conf/defaults.ini b/conf/defaults.ini index a12fccf8467..b5ec8efc511 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -246,7 +246,7 @@ reporting_distributor = grafana-labs # for new versions of grafana. The check is used # in some UI views to notify that a grafana update exists. # This option does not cause any auto updates, nor send any information -# only a GET request to https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the latest version. +# only a GET request to https://grafana.com/api/grafana/versions/stable to get the latest version. check_for_updates = true # Set to false to disable all checks to https://grafana.com diff --git a/conf/sample.ini b/conf/sample.ini index ad9a28410fd..0533731c558 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -253,7 +253,7 @@ # for new versions of grafana. The check is used # in some UI views to notify that a grafana update exists. # This option does not cause any auto updates, nor send any information -# only a GET request to https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the latest version. +# only a GET request to https://grafana.com/api/grafana/versions/stable to get the latest version. ;check_for_updates = true # Set to false to disable all checks to https://grafana.com diff --git a/latest.json b/latest.json index 6d1632424b5..8186768eabb 100644 --- a/latest.json +++ b/latest.json @@ -1,4 +1,5 @@ { + "__message": "This file is now deprecated, and will be removed in a future release. No further updates should be made to this file", "stable": "10.2.3", "testing": "10.2.3" } diff --git a/pkg/services/updatechecker/grafana.go b/pkg/services/updatechecker/grafana.go index 006fc0be575..5a56d886c7d 100644 --- a/pkg/services/updatechecker/grafana.go +++ b/pkg/services/updatechecker/grafana.go @@ -20,7 +20,7 @@ import ( "github.com/grafana/grafana/pkg/setting" ) -const grafanaLatestJSONURL = "https://raw.githubusercontent.com/grafana/grafana/main/latest.json" +const grafanaStableVersionURL = "https://grafana.com/api/grafana/versions/stable" type GrafanaService struct { hasUpdate bool @@ -92,13 +92,13 @@ func (s *GrafanaService) instrumentedCheckForUpdates(ctx context.Context) { func (s *GrafanaService) checkForUpdates(ctx context.Context) error { ctxLogger := s.log.FromContext(ctx) ctxLogger.Debug("Checking for updates") - req, err := http.NewRequestWithContext(ctx, http.MethodGet, grafanaLatestJSONURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, grafanaStableVersionURL, nil) if err != nil { return err } resp, err := s.httpClient.Do(req) if err != nil { - return fmt.Errorf("failed to get latest.json repo from github.com: %w", err) + return fmt.Errorf("failed to get stable version from grafana.com: %w", err) } defer func() { if err := resp.Body.Close(); err != nil { @@ -107,27 +107,24 @@ func (s *GrafanaService) checkForUpdates(ctx context.Context) error { }() body, err := io.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("update check failed, reading response from github.com: %w", err) + return fmt.Errorf("update check failed, reading response from grafana.com: %w", err) } - type latestJSON struct { - Stable string `json:"stable"` - Testing string `json:"testing"` + type grafanaVersionJSON struct { + Version string `json:"version"` } - var latest latestJSON + var latest grafanaVersionJSON err = json.Unmarshal(body, &latest) if err != nil { - return fmt.Errorf("failed to unmarshal latest.json: %w", err) + return fmt.Errorf("failed to unmarshal response from grafana.com: %w", err) } s.mutex.Lock() defer s.mutex.Unlock() - if strings.Contains(s.grafanaVersion, "-") { - s.latestVersion = latest.Testing - s.hasUpdate = !strings.HasPrefix(s.grafanaVersion, latest.Testing) - } else { - s.latestVersion = latest.Stable - s.hasUpdate = latest.Stable != s.grafanaVersion + // only check for updates in stable versions + if !strings.Contains(s.grafanaVersion, "-") { + s.latestVersion = latest.Version + s.hasUpdate = latest.Version != s.grafanaVersion } currVersion, err1 := version.NewVersion(s.grafanaVersion)