diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 15:08:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 15:08:11 +0000 |
commit | 4d5ee2b81486df708e04a0e32ec2ea58b0e5ed5e (patch) | |
tree | c87cf8b3e06000eb71f3bd18c86489d3ff8e214a /app/assets/javascripts/clusters_list | |
parent | 90c9981395b282f28919a755979d380aae5dcf73 (diff) | |
download | gitlab-ce-4d5ee2b81486df708e04a0e32ec2ea58b0e5ed5e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/clusters_list')
-rw-r--r-- | app/assets/javascripts/clusters_list/components/clusters.vue | 22 | ||||
-rw-r--r-- | app/assets/javascripts/clusters_list/constants.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/clusters_list/store/actions.js | 49 |
3 files changed, 60 insertions, 13 deletions
diff --git a/app/assets/javascripts/clusters_list/components/clusters.vue b/app/assets/javascripts/clusters_list/components/clusters.vue index 0b98f9c0101..9b1c45a3a49 100644 --- a/app/assets/javascripts/clusters_list/components/clusters.vue +++ b/app/assets/javascripts/clusters_list/components/clusters.vue @@ -43,17 +43,17 @@ export default { key: 'environment_scope', label: __('Environment scope'), }, - // Wait for backend to send these fields - // { - // key: 'size', - // label: __('Size'), - // }, + { + key: 'node_size', + label: __('Nodes'), + }, + // Fields are missing calculation methods and not ready to display // { - // key: 'cpu', + // key: 'node_cpu', // label: __('Total cores (vCPUs)'), // }, // { - // key: 'memory', + // key: 'node_memory', // label: __('Total memory (GB)'), // }, { @@ -111,6 +111,14 @@ export default { ></div> </div> </template> + + <template #cell(node_size)="{ item }"> + <span v-if="item.nodes">{{ item.nodes.length }}</span> + <small v-else class="gl-font-sm gl-font-style-italic gl-text-gray-400">{{ + __('Unknown') + }}</small> + </template> + <template #cell(cluster_type)="{value}"> <gl-badge variant="light"> {{ value }} diff --git a/app/assets/javascripts/clusters_list/constants.js b/app/assets/javascripts/clusters_list/constants.js index eebcaa086f9..077bf0b8925 100644 --- a/app/assets/javascripts/clusters_list/constants.js +++ b/app/assets/javascripts/clusters_list/constants.js @@ -6,6 +6,8 @@ export const CLUSTER_TYPES = { instance_type: __('Instance'), }; +export const MAX_REQUESTS = 3; + export const STATUSES = { default: { className: 'bg-white', title: __('Unknown') }, disabled: { className: 'disabled', title: __('Disabled') }, diff --git a/app/assets/javascripts/clusters_list/store/actions.js b/app/assets/javascripts/clusters_list/store/actions.js index 919625f69b4..5245c307c8c 100644 --- a/app/assets/javascripts/clusters_list/store/actions.js +++ b/app/assets/javascripts/clusters_list/store/actions.js @@ -2,10 +2,23 @@ import Poll from '~/lib/utils/poll'; import axios from '~/lib/utils/axios_utils'; import flash from '~/flash'; import { __ } from '~/locale'; +import { MAX_REQUESTS } from '../constants'; import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils'; +import * as Sentry from '@sentry/browser'; import * as types from './mutation_types'; +const allNodesPresent = (clusters, retryCount) => { + /* + Nodes are coming from external Kubernetes clusters. + They may fail for reasons GitLab cannot control. + MAX_REQUESTS will ensure this poll stops at some point. + */ + return retryCount > MAX_REQUESTS || clusters.every(cluster => cluster.nodes != null); +}; + export const fetchClusters = ({ state, commit }) => { + let retryCount = 0; + const poll = new Poll({ resource: { fetchClusters: paginatedEndPoint => axios.get(paginatedEndPoint), @@ -13,16 +26,40 @@ export const fetchClusters = ({ state, commit }) => { data: `${state.endpoint}?page=${state.page}`, method: 'fetchClusters', successCallback: ({ data, headers }) => { - if (data.clusters) { - const normalizedHeaders = normalizeHeaders(headers); - const paginationInformation = parseIntPagination(normalizedHeaders); + retryCount += 1; + + try { + if (data.clusters) { + const normalizedHeaders = normalizeHeaders(headers); + const paginationInformation = parseIntPagination(normalizedHeaders); + + commit(types.SET_CLUSTERS_DATA, { data, paginationInformation }); + commit(types.SET_LOADING_STATE, false); - commit(types.SET_CLUSTERS_DATA, { data, paginationInformation }); - commit(types.SET_LOADING_STATE, false); + if (allNodesPresent(data.clusters, retryCount)) { + poll.stop(); + } + } + } catch (error) { poll.stop(); + + Sentry.withScope(scope => { + scope.setTag('javascript_clusters_list', 'fetchClustersSuccessCallback'); + Sentry.captureException(error); + }); } }, - errorCallback: () => flash(__('An error occurred while loading clusters')), + errorCallback: response => { + poll.stop(); + + commit(types.SET_LOADING_STATE, false); + flash(__('Clusters|An error occurred while loading clusters')); + + Sentry.withScope(scope => { + scope.setTag('javascript_clusters_list', 'fetchClustersErrorCallback'); + Sentry.captureException(response); + }); + }, }); poll.makeRequest(); |