@oondemand/oon-core-back 0.7.19 → 0.7.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/middlewares/error.js +14 -0
- package/src/delivery/runtime.js +23 -3
package/package.json
CHANGED
|
@@ -75,6 +75,20 @@ const errorMiddleware = (error, req, res, next) => {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// Erro comum com statusCode 4xx explícito (ex.: "Token inválido ou
|
|
79
|
+
// expirado." com 401): responde com esse status em vez de virar 500, para
|
|
80
|
+
// o cliente poder voltar ao login.
|
|
81
|
+
if (Number.isInteger(error.statusCode) && error.statusCode >= 400 && error.statusCode < 500) {
|
|
82
|
+
const code = typeof error.code === "string" && error.code ? error.code : `HTTP_${error.statusCode}`;
|
|
83
|
+
const message = String(error.message || "Requisição recusada.");
|
|
84
|
+
return helpers.sendErrorResponse({
|
|
85
|
+
res,
|
|
86
|
+
statusCode: error.statusCode,
|
|
87
|
+
error: { code, message, ...(requestId ? { requestId } : {}) },
|
|
88
|
+
message,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
78
92
|
const databaseFailure = databaseError(error);
|
|
79
93
|
if (databaseFailure) {
|
|
80
94
|
const { statusCode, ...details } = databaseFailure;
|
package/src/delivery/runtime.js
CHANGED
|
@@ -280,6 +280,27 @@ spec:
|
|
|
280
280
|
${customDomainIngress({ context, infra })}`;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
/**
|
|
284
|
+
* F4.6: sem domínios ativos, o Ingress dos domínios personalizados sai. O
|
|
285
|
+
* publisher não tem permissão de delete (contrato do oon-k8s-infra), então
|
|
286
|
+
* só tenta remover quando o Ingress existe; se o cluster recusar, avisa e
|
|
287
|
+
* segue, e a remoção fica para quem administra o cluster.
|
|
288
|
+
*/
|
|
289
|
+
function removeStaleCustomDomainIngress(context, run = kubectl) {
|
|
290
|
+
if (customDomains(context).length) return "domains";
|
|
291
|
+
const name = `${context.appCode}-custom`;
|
|
292
|
+
const found = run(["-n", context.namespace, "get", "ingress", name, "--ignore-not-found", "-o", "name"], { capture: true });
|
|
293
|
+
if (!found) return "absent";
|
|
294
|
+
try {
|
|
295
|
+
run(["-n", context.namespace, "delete", "ingress", name], { capture: true });
|
|
296
|
+
return "deleted";
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if (!/forbidden/i.test(error.message)) throw error;
|
|
299
|
+
console.warn(`[oon-delivery] Ingress ${context.namespace}/${name} sem domínio ativo não pôde ser removido (sem permissão de delete). Remova-o manualmente.`);
|
|
300
|
+
return "kept";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
283
304
|
function copyPullSecret(namespace, infra) {
|
|
284
305
|
const source = infra.REGISTRY_PULL_SECRET_NAME || "ghcr-oon";
|
|
285
306
|
try {
|
|
@@ -389,8 +410,7 @@ function deployRuntime({ context, infra, imageDigest, resourceProfile = "small"
|
|
|
389
410
|
copyPullSecret(context.namespace, infra);
|
|
390
411
|
const imageRef = `${context.imageRepository}@${imageDigest}`;
|
|
391
412
|
applyYaml(runtimeManifest({ context, infra, imageRef, profile: resourceProfile }));
|
|
392
|
-
|
|
393
|
-
if (!customDomains(context).length) kubectl(["-n", context.namespace, "delete", "ingress", `${context.appCode}-custom`, "--ignore-not-found"]);
|
|
413
|
+
removeStaleCustomDomainIngress(context);
|
|
394
414
|
kubectl(["-n", context.namespace, "rollout", "status", `deployment/${context.appCode}`, "--timeout=10m"]);
|
|
395
415
|
return { infraVersion: infra.INFRA_SCHEMA_VERSION, imageRef };
|
|
396
416
|
}
|
|
@@ -433,4 +453,4 @@ async function activateMember(context) {
|
|
|
433
453
|
return data;
|
|
434
454
|
}
|
|
435
455
|
|
|
436
|
-
module.exports = { supportsSecretsV1: true, RESOURCE_PROFILES, MAX_REPLICAS, replicaCount, PERFORMANCE_MODES, performanceMode, MAX_CUSTOM_DOMAINS, customDomains, namespaceQuota, randomSecret, dnsLabel, kubernetesLabelValue, provisionMongo, validateMongoUri, baselineManifest, runtimeManifest, provisionRuntime, deployRuntime, waitHttp, activateMember };
|
|
456
|
+
module.exports = { supportsSecretsV1: true, RESOURCE_PROFILES, MAX_REPLICAS, replicaCount, PERFORMANCE_MODES, performanceMode, MAX_CUSTOM_DOMAINS, customDomains, namespaceQuota, randomSecret, dnsLabel, kubernetesLabelValue, provisionMongo, validateMongoUri, baselineManifest, runtimeManifest, provisionRuntime, deployRuntime, removeStaleCustomDomainIngress, waitHttp, activateMember };
|