diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 21:06:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 21:06:38 +0000 |
commit | 59a349817c0869e8e0d750884b34256ca4faefca (patch) | |
tree | abb8297dd313e550184f1933a9dc7795a3749c0a /app/assets/javascripts/monitoring/stores | |
parent | 581c10e344d85729e77fce78513819d159289dc5 (diff) | |
download | gitlab-ce-59a349817c0869e8e0d750884b34256ca4faefca.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/monitoring/stores')
-rw-r--r-- | app/assets/javascripts/monitoring/stores/actions.js | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/app/assets/javascripts/monitoring/stores/actions.js b/app/assets/javascripts/monitoring/stores/actions.js index 4db720db6e3..3612e4d173f 100644 --- a/app/assets/javascripts/monitoring/stores/actions.js +++ b/app/assets/javascripts/monitoring/stores/actions.js @@ -4,28 +4,22 @@ import createFlash from '~/flash'; import trackDashboardLoad from '../monitoring_tracking_helper'; import statusCodes from '../../lib/utils/http_status'; import { backOff } from '../../lib/utils/common_utils'; -import { s__, __ } from '../../locale'; +import { s__ } from '../../locale'; -const MAX_REQUESTS = 3; +const TWO_MINUTES = 120000; -export function backOffRequest(makeRequestCallback) { - let requestCounter = 0; +function backOffRequest(makeRequestCallback) { return backOff((next, stop) => { makeRequestCallback() .then(resp => { if (resp.status === statusCodes.NO_CONTENT) { - requestCounter += 1; - if (requestCounter < MAX_REQUESTS) { - next(); - } else { - stop(new Error(__('Failed to connect to the prometheus server'))); - } + next(); } else { stop(resp); } }) .catch(stop); - }); + }, TWO_MINUTES); } export const setGettingStartedEmptyState = ({ commit }) => { @@ -52,11 +46,6 @@ export const receiveMetricsDashboardFailure = ({ commit }, error) => { commit(types.RECEIVE_METRICS_DATA_FAILURE, error); }; -export const requestMetricsData = ({ commit }) => commit(types.REQUEST_METRICS_DATA); -export const receiveMetricsDataSuccess = ({ commit }, data) => - commit(types.RECEIVE_METRICS_DATA_SUCCESS, data); -export const receiveMetricsDataFailure = ({ commit }, error) => - commit(types.RECEIVE_METRICS_DATA_FAILURE, error); export const receiveDeploymentsDataSuccess = ({ commit }, data) => commit(types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS, data); export const receiveDeploymentsDataFailure = ({ commit }) => @@ -149,11 +138,15 @@ export const fetchPrometheusMetrics = ({ state, commit, dispatch }, params) => { }); }); - return Promise.all(promises).then(() => { - if (state.metricsWithData.length === 0) { - commit(types.SET_NO_DATA_EMPTY_STATE); - } - }); + return Promise.all(promises) + .then(() => { + if (state.metricsWithData.length === 0) { + commit(types.SET_NO_DATA_EMPTY_STATE); + } + }) + .catch(() => { + createFlash(s__(`Metrics|There was an error while retrieving metrics`), 'warning'); + }); }; export const fetchDeploymentsData = ({ state, dispatch }) => { |