Merge pull request #13828 from influxdata/extract-retry-from-headers
Extract "retry after" from query limit error response headers and reveal to user in notificationspull/13837/head
commit
b4f243c937
|
@ -11,10 +11,7 @@ import {AppState} from 'src/types'
|
|||
import {notify} from 'src/shared/actions/notifications'
|
||||
|
||||
// Constants
|
||||
import {
|
||||
readLimitReached,
|
||||
resourceLimitReached,
|
||||
} from 'src/shared/copy/notifications'
|
||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||
|
||||
// Types
|
||||
import {RemoteDataState} from '@influxdata/clockface'
|
||||
|
@ -182,7 +179,6 @@ export const checkDashboardLimits = () => (
|
|||
|
||||
if (dashboardsCount >= dashboardsMax) {
|
||||
dispatch(setDashboardLimitStatus(LimitStatus.EXCEEDED))
|
||||
dispatch(notify(resourceLimitReached('dashboards')))
|
||||
} else {
|
||||
dispatch(setDashboardLimitStatus(LimitStatus.OK))
|
||||
}
|
||||
|
@ -229,7 +225,6 @@ export const checkTaskLimits = () => async (
|
|||
|
||||
if (tasksCount >= tasksMax) {
|
||||
dispatch(setTaskLimitStatus(LimitStatus.EXCEEDED))
|
||||
dispatch(notify(resourceLimitReached('tasks')))
|
||||
} else {
|
||||
dispatch(setTaskLimitStatus(LimitStatus.OK))
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import {checkQueryResult} from 'src/shared/utils/checkQueryResult'
|
|||
|
||||
// Constants
|
||||
import {RATE_LIMIT_ERROR_STATUS} from 'src/cloud/constants/index'
|
||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||
import {rateLimitReached} from 'src/shared/copy/notifications'
|
||||
import {RATE_LIMIT_ERROR_TEXT} from 'src/cloud/constants'
|
||||
|
||||
// Actions
|
||||
|
@ -172,7 +172,9 @@ class TimeSeries extends Component<Props & WithRouterProps, State> {
|
|||
let errorMessage = get(error, 'message', '')
|
||||
|
||||
if (get(error, 'status') === RATE_LIMIT_ERROR_STATUS) {
|
||||
notify(readLimitReached())
|
||||
const retryAfter = get(error, 'headers.Retry-After')
|
||||
|
||||
notify(rateLimitReached(retryAfter))
|
||||
errorMessage = RATE_LIMIT_ERROR_TEXT
|
||||
}
|
||||
|
||||
|
|
|
@ -406,21 +406,31 @@ export const getBucketsFailed = (): Notification => ({
|
|||
export const writeLimitReached = (): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: `Exceeded write limits.`,
|
||||
duration: TEN_SECONDS,
|
||||
duration: FIVE_SECONDS,
|
||||
type: 'writeLimitReached',
|
||||
})
|
||||
|
||||
export const readLimitReached = (): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: `Exceeded quota for concurrent queries.`,
|
||||
duration: TEN_SECONDS,
|
||||
message: `Exceeded query limits.`,
|
||||
duration: FIVE_SECONDS,
|
||||
type: 'readLimitReached',
|
||||
})
|
||||
|
||||
export const rateLimitReached = (secs?: string): Notification => {
|
||||
const retryText = ` Please try again in ${secs} seconds`
|
||||
return {
|
||||
...defaultErrorNotification,
|
||||
message: `Exceeded rate limits.${secs ? retryText : ''} `,
|
||||
duration: FIVE_SECONDS,
|
||||
type: 'rateLimitReached',
|
||||
}
|
||||
}
|
||||
|
||||
export const resourceLimitReached = (resourceName: string): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: `Oops. It looks like you have reached the maximum number of ${resourceName} allowed as part of your plan. If you would like to upgrade and remove this restriction, reach out to cloudbeta@influxdata.com.`,
|
||||
duration: TEN_SECONDS,
|
||||
duration: FIVE_SECONDS,
|
||||
type: 'resourceLimitReached',
|
||||
})
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import {refreshVariableValues, selectValue} from 'src/variables/actions'
|
|||
import {notify} from 'src/shared/actions/notifications'
|
||||
|
||||
// Constants
|
||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||
import {rateLimitReached} from 'src/shared/copy/notifications'
|
||||
import {RATE_LIMIT_ERROR_STATUS} from 'src/cloud/constants/index'
|
||||
|
||||
// Utils
|
||||
|
@ -129,7 +129,8 @@ export const executeQueries = () => async (dispatch, getState: GetState) => {
|
|||
}
|
||||
|
||||
if (get(e, 'status') === RATE_LIMIT_ERROR_STATUS) {
|
||||
dispatch(notify(readLimitReached()))
|
||||
const retryAfter = get(e, 'headers.Retry-After')
|
||||
dispatch(notify(rateLimitReached(retryAfter)))
|
||||
}
|
||||
|
||||
console.error(e)
|
||||
|
|
Loading…
Reference in New Issue