Allow disabling recovery interval

This commit is contained in:
oleksandr.shostak@consultic.com 2026-01-14 10:11:56 +02:00
parent c3e936f2bc
commit 01b5724224
3 changed files with 27 additions and 13 deletions

View File

@ -1083,9 +1083,10 @@ class Monitor extends BeanModel {
if (this.downRetryInterval > 0) {
beatInterval = this.downRetryInterval;
}
const intervalNote = this.downRetryInterval > 0 ? " (recovery)" : "";
log.warn(
"monitor",
`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type} | Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`
`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds${intervalNote} | Type: ${this.type} | Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`
);
}
@ -1710,11 +1711,14 @@ class Monitor extends BeanModel {
throw new Error(`Retry interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);
}
if (this.downRetryInterval > MAX_INTERVAL_SECOND) {
throw new Error(`Down retry interval cannot be more than ${MAX_INTERVAL_SECOND} seconds`);
}
if (this.downRetryInterval < MIN_INTERVAL_SECOND) {
throw new Error(`Down retry interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);
const downRetryInterval = Number(this.downRetryInterval);
if (downRetryInterval !== 0) {
if (downRetryInterval > MAX_INTERVAL_SECOND) {
throw new Error(`Down retry interval cannot be more than ${MAX_INTERVAL_SECOND} seconds`);
}
if (downRetryInterval < MIN_INTERVAL_SECOND) {
throw new Error(`Down retry interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);
}
}
if (this.response_max_length !== undefined) {

View File

@ -85,6 +85,8 @@
"checkEverySecond": "Check every {0} seconds",
"retryCheckEverySecond": "Retry every {0} seconds",
"downCheckEverySecond": "Check every {0} seconds while down",
"downRetryIntervalDisabled": "Use heartbeat interval when down",
"downRetryIntervalDescription": "Set to 0 to use the heartbeat interval while the monitor is down.",
"resendEveryXTimes": "Resend every {0} times",
"resendDisabled": "Resend disabled",
"retriesDescription": "Maximum retries before the service is marked as down and a notification is sent",

View File

@ -1188,7 +1188,10 @@
<div class="my-3">
<label for="down-retry-interval" class="form-label">
{{ $t("Recovery Check Interval") }}
<span>({{ $t("downCheckEverySecond", [monitor.downRetryInterval]) }})</span>
<span v-if="monitor.downRetryInterval > 0">
({{ $t("downCheckEverySecond", [monitor.downRetryInterval]) }})
</span>
<span v-else>({{ $t("downRetryIntervalDisabled") }})</span>
</label>
<input
id="down-retry-interval"
@ -1196,11 +1199,14 @@
type="number"
class="form-control"
required
:min="minInterval"
min="0"
step="1"
@focus="lowIntervalConfirmation.editedValue = true"
/>
<div v-if="monitor.downRetryInterval < 20" class="form-text">
<div class="form-text">
{{ $t("downRetryIntervalDescription") }}
</div>
<div v-if="monitor.downRetryInterval > 0 && monitor.downRetryInterval < 20" class="form-text">
{{ $t("minimumIntervalWarning") }}
</div>
</div>
@ -2277,7 +2283,7 @@ const monitorDefaults = {
interval: 60,
humanReadableInterval: timeDurationFormatter.secondsToHumanReadableFormat(60),
retryInterval: 60,
downRetryInterval: 60,
downRetryInterval: 0,
resendInterval: 0,
maxretries: 0,
retryOnlyOnStatusCodeFailure: false,
@ -2927,8 +2933,8 @@ message HealthCheckResponse {
if (this.monitor.retryInterval === 0) {
this.monitor.retryInterval = this.monitor.interval;
}
if (!this.monitor.downRetryInterval) {
this.monitor.downRetryInterval = this.monitor.interval;
if (this.monitor.downRetryInterval === undefined || this.monitor.downRetryInterval === null) {
this.monitor.downRetryInterval = 0;
}
// Handling for monitors that are missing/zeroed timeout
if (!this.monitor.timeout) {
@ -3108,7 +3114,9 @@ message HealthCheckResponse {
// do this if the interval value has changed since last save.
if (
this.lowIntervalConfirmation.editedValue &&
(this.monitor.interval < 20 || this.monitor.retryInterval < 20 || this.monitor.downRetryInterval < 20) &&
(this.monitor.interval < 20 ||
this.monitor.retryInterval < 20 ||
(this.monitor.downRetryInterval > 0 && this.monitor.downRetryInterval < 20)) &&
!this.lowIntervalConfirmation.confirmed
) {
// The dialog will then re-call submit