Handle connectivity diagnostics failures
Build and Deploy Gateway / build-and-push (push) Successful in 13s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-07 20:58:18 +03:00
parent 12375006d3
commit 0c376c72aa
6 changed files with 30 additions and 11 deletions
+9 -3
View File
@@ -1,7 +1,7 @@
import http from 'node:http';
import { HarborError } from '../shared/errors.js';
function request(socketPath, pathname, method = 'GET', body = null) {
function request(socketPath, pathname, method = 'GET', body = null, timeoutMs = 6000) {
return new Promise((resolve, reject) => {
const encoded = body == null ? null : JSON.stringify(body);
const req = http.request({
@@ -29,7 +29,7 @@ function request(socketPath, pathname, method = 'GET', body = null) {
});
});
req.on('error', reject);
req.setTimeout(6000, () => req.destroy(new Error('Dataplane не ответил за 6 секунд')));
req.setTimeout(timeoutMs, () => req.destroy(new Error(`Dataplane не ответил за ${Math.ceil(timeoutMs / 1000)} секунд`)));
req.end(encoded);
});
}
@@ -56,7 +56,13 @@ export function createDataplaneClient(socketPath, send = request) {
observeTraffic: () => send(socketPath, '/device-traffic', 'GET'),
observeDevicePolicy: () => send(socketPath, '/device-policy', 'GET'),
applyDevicePolicies: (devices) => send(socketPath, '/device-policy', 'PUT', { devices }),
runConnectivityDiagnostics: () => send(socketPath, '/diagnostics/connectivity', 'POST'),
runConnectivityDiagnostics: async () => {
try {
return await send(socketPath, '/diagnostics/connectivity', 'POST', null, 15_000);
} catch (cause) {
throw new HarborError('DIAGNOSTICS_FAILED', { cause });
}
},
apply: () => update('/apply', 'POST'),
restart: () => update('/restart', 'POST'),
stop: () => update('/stop', 'POST'),
+1
View File
@@ -13,6 +13,7 @@ export const ERROR_DEFINITIONS = Object.freeze({
DEVICE_NOT_FOUND: { status: 404, message: 'Устройство больше недоступно.', retryable: false },
DEVICE_IDENTITY_AMBIGUOUS: { status: 409, message: 'Gateway не может безопасно применить маршрут к этому устройству.', retryable: true },
DEVICE_POLICY_APPLY_FAILED: { status: 503, message: 'Не удалось применить маршрут устройства.', retryable: true },
DIAGNOSTICS_FAILED: { status: 503, message: 'Не удалось проверить маршруты. Попробуйте ещё раз.', retryable: true },
CONFIG_INVALID: { status: 422, message: 'Конфигурация VPN недействительна.', retryable: false },
PROCESS_START_FAILED: { status: 503, message: 'Не удалось запустить VPN-процесс.', retryable: true },
OPERATION_IN_PROGRESS: { status: 409, message: 'Другая операция ещё выполняется.', retryable: true },
+3 -3
View File
@@ -1,7 +1,7 @@
export const HARBOR_VERSIONS = Object.freeze({
macClient: '0.15.0',
gatewayClient: '0.16.0',
gatewayBackend: '0.16.0',
macClient: '0.15.1',
gatewayClient: '0.16.1',
gatewayBackend: '0.16.1',
});
export function parseVersion(value) {