diff --git a/ui/src/kapacitor/actions/view/index.js b/ui/src/kapacitor/actions/view/index.js index ad5cee6f2..c5bccdcc7 100644 --- a/ui/src/kapacitor/actions/view/index.js +++ b/ui/src/kapacitor/actions/view/index.js @@ -108,13 +108,14 @@ export const fetchRules = kapacitor => async dispatch => { export const fetchFluxTasks = kapacitor => async dispatch => { try { - const { - data: {tasks}, - } = await getFluxTasks(kapacitor) + const tasks = await getFluxTasks(kapacitor) dispatch({type: 'LOAD_FLUX_TASKS', payload: {tasks}}) } catch (error) { dispatch({type: 'LOAD_FLUX_TASKS', payload: {tasks: null}}) - dispatch(errorThrown(error)) + // dispatch an error unless flux tasks are disabled/not supported + if (error.status !== 404) { + dispatch(errorThrown(error)) + } } } diff --git a/ui/src/kapacitor/apis/index.js b/ui/src/kapacitor/apis/index.js index eeec53081..e9b815bcd 100644 --- a/ui/src/kapacitor/apis/index.js +++ b/ui/src/kapacitor/apis/index.js @@ -1,5 +1,5 @@ import AJAX from 'utils/ajax' -import {cloneDeep, get} from 'lodash' +import {cloneDeep, get, values} from 'lodash' const outRule = rule => { // fit into range @@ -66,11 +66,35 @@ export const getRules = kapacitor => { }) } -export const getFluxTasks = kapacitor => { - return AJAX({ - method: 'GET', - url: kapacitor.links.proxy + '?path=/kapacitor/v1/api/v2/tasks?limit=500', - }) +export const getFluxTasks = async kapacitor => { + const taskIds = {} + let lastID = '' + for (;;) { + const { + data: {tasks}, + } = await AJAX({ + method: 'GET', + url: + kapacitor.links.proxy + + `?path=/kapacitor/v1/api/v2/tasks?limit=500&after=${lastID}`, + }) + if (!tasks || !tasks.length) { + break + } + lastID = tasks[tasks.length - 1].id + let noNewData = true + tasks.forEach(x => { + if (taskIds[x.id]) { + return + } + noNewData = false + taskIds[x.id] = x + }) + if (noNewData) { + break + } + } + return values(taskIds).sort((a, b) => a.name.localeCompare(b.name)) } export const getRule = async (kapacitor, ruleID) => { diff --git a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx index b2c908669..15f15dc38 100644 --- a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx +++ b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx @@ -181,7 +181,6 @@ export class KapacitorRulesPage extends PureComponent { await this.props.fetchFluxTasks(kapacitor) await pingKapacitor(kapacitor) } catch (error) { - console.error(error) this.props.notify(notifyKapacitorConnectionFailed()) } }