fix: finalize HWLAB v03 platform DB bridge
This commit is contained in:
+130
-36
@@ -402,7 +402,14 @@ function runNodeEndpointBridge(options: ReturnType<typeof parseNodeScopedDelegat
|
||||
const beforeIgnored = fields.beforeEndpointsIgnoreUpdates === "yes" || fields.beforeEndpointSliceIgnoreUpdates === "yes";
|
||||
const afterExcluded = fields.afterEndpointResourcesExcluded === "yes";
|
||||
const afterIgnored = fields.afterEndpointsIgnoreUpdates === "yes" || fields.afterEndpointSliceIgnoreUpdates === "yes";
|
||||
const ok = result.exitCode === 0 && !afterExcluded && !afterIgnored;
|
||||
const beforeExtraEndpointSlices = splitWhitespaceField(fields.beforeExtraEndpointSliceNames);
|
||||
const afterExtraEndpointSlices = splitWhitespaceField(fields.afterExtraEndpointSliceNames);
|
||||
const beforeLegacyEndpoints = fields.beforeLegacyEndpointsExists === "yes";
|
||||
const afterLegacyEndpoints = fields.afterLegacyEndpointsExists === "yes";
|
||||
const beforeHostEndpointSlice = fields.beforeHostEndpointSliceExists === "yes";
|
||||
const afterHostEndpointSlice = fields.afterHostEndpointSliceExists === "yes";
|
||||
const bridgeReady = !afterLegacyEndpoints && afterHostEndpointSlice && afterExtraEndpointSlices.length === 0;
|
||||
const ok = result.exitCode === 0 && !afterExcluded && !afterIgnored && bridgeReady;
|
||||
return {
|
||||
ok: dryRun ? result.exitCode === 0 : ok,
|
||||
command: "hwlab nodes control-plane allow-endpoint-bridge",
|
||||
@@ -419,21 +426,32 @@ function runNodeEndpointBridge(options: ReturnType<typeof parseNodeScopedDelegat
|
||||
endpointResourcesExcluded: beforeExcluded,
|
||||
endpointsIgnoreUpdates: fields.beforeEndpointsIgnoreUpdates === "yes",
|
||||
endpointSliceIgnoreUpdates: fields.beforeEndpointSliceIgnoreUpdates === "yes",
|
||||
legacyEndpointsExist: beforeLegacyEndpoints,
|
||||
hostEndpointSliceExists: beforeHostEndpointSlice,
|
||||
extraEndpointSlices: beforeExtraEndpointSlices,
|
||||
},
|
||||
after: {
|
||||
endpointResourcesExcluded: afterExcluded,
|
||||
endpointsIgnoreUpdates: fields.afterEndpointsIgnoreUpdates === "yes",
|
||||
endpointSliceIgnoreUpdates: fields.afterEndpointSliceIgnoreUpdates === "yes",
|
||||
legacyEndpointsExist: afterLegacyEndpoints,
|
||||
hostEndpointSliceExists: afterHostEndpointSlice,
|
||||
extraEndpointSlices: afterExtraEndpointSlices,
|
||||
},
|
||||
runtimeNamespace: fields.runtimeNamespace || `hwlab-${options.lane}`,
|
||||
platformService: fields.platformService || "g14-platform-postgres",
|
||||
hostEndpointSlice: fields.hostEndpointSlice || "g14-platform-postgres-host",
|
||||
patchExitCode: numericField(fields.patchExitCode),
|
||||
rolloutRestartExitCode: numericField(fields.rolloutRestartExitCode),
|
||||
rolloutStatusExitCode: numericField(fields.rolloutStatusExitCode),
|
||||
deleteLegacyEndpointsExitCode: numericField(fields.deleteLegacyEndpointsExitCode),
|
||||
deleteExtraEndpointSlicesExitCode: numericField(fields.deleteExtraEndpointSlicesExitCode),
|
||||
refreshExitCode: numericField(fields.refreshExitCode),
|
||||
exitCode: result.exitCode,
|
||||
stderr: result.exitCode === 0 ? "" : result.stderr.trim().slice(0, 2000),
|
||||
summary: !afterExcluded && !afterIgnored
|
||||
? "Argo tracks HWLAB external Postgres EndpointSlice resources"
|
||||
: "Argo still excludes or ignores HWLAB external Postgres EndpointSlice resources",
|
||||
summary: !afterExcluded && !afterIgnored && bridgeReady
|
||||
? "Argo tracks HWLAB external Postgres EndpointSlice and no legacy Endpoints remain"
|
||||
: "Argo endpoint bridge is not in final Service plus EndpointSlice shape",
|
||||
},
|
||||
result: compactCommandResult(result),
|
||||
};
|
||||
@@ -441,34 +459,59 @@ function runNodeEndpointBridge(options: ReturnType<typeof parseNodeScopedDelegat
|
||||
|
||||
function endpointBridgeScript(options: { lane: HwlabRuntimeLane; dryRun: boolean }): string {
|
||||
const application = `hwlab-node-${options.lane}`;
|
||||
const runtimeNamespace = `hwlab-${options.lane}`;
|
||||
return [
|
||||
"set +e",
|
||||
"namespace=argocd",
|
||||
`runtime_namespace=${shellQuote(runtimeNamespace)}`,
|
||||
"configmap=argocd-cm",
|
||||
`application=${shellQuote(application)}`,
|
||||
`dry_run=${shellQuote(options.dryRun ? "true" : "false")}`,
|
||||
"platform_service=g14-platform-postgres",
|
||||
"host_endpointslice=g14-platform-postgres-host",
|
||||
"preset=endpoint-bridge-resource-tracking",
|
||||
"cm_data() { kubectl -n \"$namespace\" get configmap \"$configmap\" -o \"go-template={{ index .data \\\"$1\\\" }}\" 2>/dev/null || true; }",
|
||||
"cm_has_key() { kubectl -n \"$namespace\" get configmap \"$configmap\" -o jsonpath=\"{.data.$1}\" >/tmp/hwlab-argocd-cm-key.out 2>/dev/null && [ -s /tmp/hwlab-argocd-cm-key.out ] && printf yes || printf no; }",
|
||||
"cm_has_key() { value=$(cm_data \"$1\"); [ -n \"$value\" ] && [ \"$value\" != \"<no value>\" ] && printf yes || printf no; }",
|
||||
"endpoint_resources_excluded() { exclusions=$(cm_data resource.exclusions); printf '%s' \"$exclusions\" | grep -Eq '(^|[[:space:]])(Endpoints|EndpointSlice)([[:space:]]|$)' && printf yes || printf no; }",
|
||||
"resource_exists() { kubectl -n \"$runtime_namespace\" get \"$1\" \"$2\" >/dev/null 2>&1 && printf yes || printf no; }",
|
||||
"extra_endpoint_slices() { kubectl -n \"$runtime_namespace\" get endpointslice -l \"kubernetes.io/service-name=$platform_service\" -o name 2>/dev/null | sed \"/\\/$host_endpointslice$/d\" | tr '\\n' ' ' | sed 's/[[:space:]]*$//'; }",
|
||||
"wait_runtime_bridge_clean() {",
|
||||
" for _ in $(seq 1 30); do",
|
||||
" current_legacy=$(resource_exists endpoints \"$platform_service\")",
|
||||
" current_extra=$(extra_endpoint_slices)",
|
||||
" current_host=$(resource_exists endpointslice \"$host_endpointslice\")",
|
||||
" if [ \"$current_legacy\" != yes ] && [ -z \"$current_extra\" ] && [ \"$current_host\" = yes ]; then return 0; fi",
|
||||
" sleep 2",
|
||||
" done",
|
||||
" return 1",
|
||||
"}",
|
||||
"before_endpoint_resources_excluded=$(endpoint_resources_excluded)",
|
||||
"before_endpoints_ignore_updates=$(cm_has_key 'resource\\.customizations\\.ignoreResourceUpdates\\.Endpoints')",
|
||||
"before_endpoint_slice_ignore_updates=$(cm_has_key 'resource\\.customizations\\.ignoreResourceUpdates\\.discovery\\.k8s\\.io_EndpointSlice')",
|
||||
"before_endpoints_ignore_updates=$(cm_has_key 'resource.customizations.ignoreResourceUpdates.Endpoints')",
|
||||
"before_endpoint_slice_ignore_updates=$(cm_has_key 'resource.customizations.ignoreResourceUpdates.discovery.k8s.io_EndpointSlice')",
|
||||
"before_legacy_endpoints_exists=$(resource_exists endpoints \"$platform_service\")",
|
||||
"before_host_endpointslice_exists=$(resource_exists endpointslice \"$host_endpointslice\")",
|
||||
"before_extra_endpoint_slice_names=$(extra_endpoint_slices)",
|
||||
"needs_argo_update=false",
|
||||
"if [ \"$before_endpoint_resources_excluded\" = yes ] || [ \"$before_endpoints_ignore_updates\" = yes ] || [ \"$before_endpoint_slice_ignore_updates\" = yes ]; then needs_argo_update=true; fi",
|
||||
"needs_runtime_cleanup=false",
|
||||
"if [ \"$before_legacy_endpoints_exists\" = yes ] || [ -n \"$before_extra_endpoint_slice_names\" ]; then needs_runtime_cleanup=true; fi",
|
||||
"action=observed",
|
||||
"mutation=false",
|
||||
"patch_exit=",
|
||||
"rollout_restart_exit=",
|
||||
"rollout_status_exit=",
|
||||
"delete_legacy_endpoints_exit=",
|
||||
"delete_extra_endpointslices_exit=",
|
||||
"refresh_exit=",
|
||||
"needs_update=false",
|
||||
"if [ \"$before_endpoint_resources_excluded\" = yes ] || [ \"$before_endpoints_ignore_updates\" = yes ] || [ \"$before_endpoint_slice_ignore_updates\" = yes ]; then needs_update=true; fi",
|
||||
"if [ \"$dry_run\" = true ]; then",
|
||||
" if [ \"$needs_update\" = true ]; then action=would-remove-old-endpoint-exclusions; else action=kept; fi",
|
||||
"elif [ \"$needs_update\" = false ]; then",
|
||||
" action=kept",
|
||||
" if [ \"$needs_argo_update\" = true ] && [ \"$needs_runtime_cleanup\" = true ]; then action=would-remove-old-endpoint-exclusions-and-legacy-endpoints",
|
||||
" elif [ \"$needs_argo_update\" = true ]; then action=would-remove-old-endpoint-exclusions",
|
||||
" elif [ \"$needs_runtime_cleanup\" = true ]; then action=would-remove-legacy-endpoints",
|
||||
" else action=kept; fi",
|
||||
"else",
|
||||
" patch_file=$(mktemp /tmp/hwlab-argocd-endpoint-bridge.XXXXXX.json)",
|
||||
" python3 - <<'PY' >\"$patch_file\"",
|
||||
" if [ \"$needs_argo_update\" = true ]; then",
|
||||
" patch_file=$(mktemp /tmp/hwlab-argocd-endpoint-bridge.XXXXXX.json)",
|
||||
" python3 - <<'PY' >\"$patch_file\"",
|
||||
"import json",
|
||||
"desired = '''### Internal Kubernetes resources excluded to reduce watch volume",
|
||||
"- apiGroups:",
|
||||
@@ -526,32 +569,58 @@ function endpointBridgeScript(options: { lane: HwlabRuntimeLane; dryRun: boolean
|
||||
" }",
|
||||
"}))",
|
||||
"PY",
|
||||
" kubectl -n \"$namespace\" patch configmap \"$configmap\" --type merge --patch-file \"$patch_file\" >/tmp/hwlab-argocd-endpoint-bridge-patch.out 2>/tmp/hwlab-argocd-endpoint-bridge-patch.err",
|
||||
" patch_exit=$?",
|
||||
" rm -f \"$patch_file\"",
|
||||
" if [ \"$patch_exit\" -eq 0 ]; then",
|
||||
" kubectl -n \"$namespace\" rollout restart statefulset/argocd-application-controller >/tmp/hwlab-argocd-endpoint-bridge-rollout-restart.out 2>/tmp/hwlab-argocd-endpoint-bridge-rollout-restart.err",
|
||||
" rollout_restart_exit=$?",
|
||||
" if [ \"$rollout_restart_exit\" -eq 0 ]; then",
|
||||
" kubectl -n \"$namespace\" rollout status statefulset/argocd-application-controller --timeout=180s >/tmp/hwlab-argocd-endpoint-bridge-rollout-status.out 2>/tmp/hwlab-argocd-endpoint-bridge-rollout-status.err",
|
||||
" rollout_status_exit=$?",
|
||||
" kubectl -n \"$namespace\" patch configmap \"$configmap\" --type merge --patch-file \"$patch_file\" >/tmp/hwlab-argocd-endpoint-bridge-patch.out 2>/tmp/hwlab-argocd-endpoint-bridge-patch.err",
|
||||
" patch_exit=$?",
|
||||
" rm -f \"$patch_file\"",
|
||||
" if [ \"$patch_exit\" -eq 0 ]; then",
|
||||
" kubectl -n \"$namespace\" rollout restart statefulset/argocd-application-controller >/tmp/hwlab-argocd-endpoint-bridge-rollout-restart.out 2>/tmp/hwlab-argocd-endpoint-bridge-rollout-restart.err",
|
||||
" rollout_restart_exit=$?",
|
||||
" if [ \"$rollout_restart_exit\" -eq 0 ]; then",
|
||||
" kubectl -n \"$namespace\" rollout status statefulset/argocd-application-controller --timeout=180s >/tmp/hwlab-argocd-endpoint-bridge-rollout-status.out 2>/tmp/hwlab-argocd-endpoint-bridge-rollout-status.err",
|
||||
" rollout_status_exit=$?",
|
||||
" fi",
|
||||
" fi",
|
||||
" kubectl -n \"$namespace\" annotate application \"$application\" argocd.argoproj.io/refresh=hard --overwrite >/tmp/hwlab-argocd-endpoint-bridge-refresh.out 2>/tmp/hwlab-argocd-endpoint-bridge-refresh.err",
|
||||
" refresh_exit=$?",
|
||||
" if [ \"$rollout_restart_exit\" -ne 0 ]; then action=rollout-restart-failed",
|
||||
" elif [ \"$rollout_status_exit\" -ne 0 ]; then action=rollout-status-failed",
|
||||
" elif [ \"$refresh_exit\" -ne 0 ]; then action=refresh-failed",
|
||||
" else action=removed-old-endpoint-exclusions; mutation=true; fi",
|
||||
" fi",
|
||||
" if [ -n \"$patch_exit\" ] && [ \"$patch_exit\" != 0 ]; then action=patch-failed",
|
||||
" elif [ -n \"$rollout_restart_exit\" ] && [ \"$rollout_restart_exit\" != 0 ]; then action=rollout-restart-failed",
|
||||
" elif [ -n \"$rollout_status_exit\" ] && [ \"$rollout_status_exit\" != 0 ]; then action=rollout-status-failed",
|
||||
" else",
|
||||
" action=patch-failed",
|
||||
" if [ \"$needs_runtime_cleanup\" = true ]; then",
|
||||
" kubectl -n \"$runtime_namespace\" delete endpoints \"$platform_service\" --ignore-not-found=true >/tmp/hwlab-platform-postgres-endpoints-delete.out 2>/tmp/hwlab-platform-postgres-endpoints-delete.err",
|
||||
" delete_legacy_endpoints_exit=$?",
|
||||
" wait_runtime_bridge_clean",
|
||||
" remaining_extra=$(extra_endpoint_slices)",
|
||||
" if [ -n \"$remaining_extra\" ]; then",
|
||||
" kubectl -n \"$runtime_namespace\" delete $remaining_extra --ignore-not-found=true >/tmp/hwlab-platform-postgres-endpointslices-delete.out 2>/tmp/hwlab-platform-postgres-endpointslices-delete.err",
|
||||
" delete_extra_endpointslices_exit=$?",
|
||||
" wait_runtime_bridge_clean",
|
||||
" fi",
|
||||
" fi",
|
||||
" if [ \"$needs_argo_update\" = true ] || [ \"$needs_runtime_cleanup\" = true ]; then",
|
||||
" kubectl -n \"$namespace\" annotate application \"$application\" argocd.argoproj.io/refresh=hard --overwrite >/tmp/hwlab-argocd-endpoint-bridge-refresh.out 2>/tmp/hwlab-argocd-endpoint-bridge-refresh.err",
|
||||
" refresh_exit=$?",
|
||||
" fi",
|
||||
" if [ -n \"$delete_legacy_endpoints_exit\" ] && [ \"$delete_legacy_endpoints_exit\" != 0 ]; then action=delete-legacy-endpoints-failed",
|
||||
" elif [ -n \"$delete_extra_endpointslices_exit\" ] && [ \"$delete_extra_endpointslices_exit\" != 0 ]; then action=delete-extra-endpointslices-failed",
|
||||
" elif [ -n \"$refresh_exit\" ] && [ \"$refresh_exit\" != 0 ]; then action=refresh-failed",
|
||||
" elif [ \"$needs_argo_update\" = true ] && [ \"$needs_runtime_cleanup\" = true ]; then action=removed-old-endpoint-exclusions-and-legacy-endpoints; mutation=true",
|
||||
" elif [ \"$needs_argo_update\" = true ]; then action=removed-old-endpoint-exclusions; mutation=true",
|
||||
" elif [ \"$needs_runtime_cleanup\" = true ]; then action=removed-legacy-endpoints; mutation=true",
|
||||
" else action=kept; fi",
|
||||
" fi",
|
||||
"fi",
|
||||
"after_endpoint_resources_excluded=$(endpoint_resources_excluded)",
|
||||
"after_endpoints_ignore_updates=$(cm_has_key 'resource\\.customizations\\.ignoreResourceUpdates\\.Endpoints')",
|
||||
"after_endpoint_slice_ignore_updates=$(cm_has_key 'resource\\.customizations\\.ignoreResourceUpdates\\.discovery\\.k8s\\.io_EndpointSlice')",
|
||||
"after_endpoints_ignore_updates=$(cm_has_key 'resource.customizations.ignoreResourceUpdates.Endpoints')",
|
||||
"after_endpoint_slice_ignore_updates=$(cm_has_key 'resource.customizations.ignoreResourceUpdates.discovery.k8s.io_EndpointSlice')",
|
||||
"after_legacy_endpoints_exists=$(resource_exists endpoints \"$platform_service\")",
|
||||
"after_host_endpointslice_exists=$(resource_exists endpointslice \"$host_endpointslice\")",
|
||||
"after_extra_endpoint_slice_names=$(extra_endpoint_slices)",
|
||||
"printf 'namespace\\t%s\\n' \"$namespace\"",
|
||||
"printf 'runtimeNamespace\\t%s\\n' \"$runtime_namespace\"",
|
||||
"printf 'configMap\\t%s\\n' \"$configmap\"",
|
||||
"printf 'application\\t%s\\n' \"$application\"",
|
||||
"printf 'platformService\\t%s\\n' \"$platform_service\"",
|
||||
"printf 'hostEndpointSlice\\t%s\\n' \"$host_endpointslice\"",
|
||||
"printf 'preset\\t%s\\n' \"$preset\"",
|
||||
"printf 'action\\t%s\\n' \"$action\"",
|
||||
"printf 'dryRun\\t%s\\n' \"$dry_run\"",
|
||||
@@ -559,17 +628,28 @@ function endpointBridgeScript(options: { lane: HwlabRuntimeLane; dryRun: boolean
|
||||
"printf 'beforeEndpointResourcesExcluded\\t%s\\n' \"$before_endpoint_resources_excluded\"",
|
||||
"printf 'beforeEndpointsIgnoreUpdates\\t%s\\n' \"$before_endpoints_ignore_updates\"",
|
||||
"printf 'beforeEndpointSliceIgnoreUpdates\\t%s\\n' \"$before_endpoint_slice_ignore_updates\"",
|
||||
"printf 'beforeLegacyEndpointsExists\\t%s\\n' \"$before_legacy_endpoints_exists\"",
|
||||
"printf 'beforeHostEndpointSliceExists\\t%s\\n' \"$before_host_endpointslice_exists\"",
|
||||
"printf 'beforeExtraEndpointSliceNames\\t%s\\n' \"$before_extra_endpoint_slice_names\"",
|
||||
"printf 'afterEndpointResourcesExcluded\\t%s\\n' \"$after_endpoint_resources_excluded\"",
|
||||
"printf 'afterEndpointsIgnoreUpdates\\t%s\\n' \"$after_endpoints_ignore_updates\"",
|
||||
"printf 'afterEndpointSliceIgnoreUpdates\\t%s\\n' \"$after_endpoint_slice_ignore_updates\"",
|
||||
"printf 'afterLegacyEndpointsExists\\t%s\\n' \"$after_legacy_endpoints_exists\"",
|
||||
"printf 'afterHostEndpointSliceExists\\t%s\\n' \"$after_host_endpointslice_exists\"",
|
||||
"printf 'afterExtraEndpointSliceNames\\t%s\\n' \"$after_extra_endpoint_slice_names\"",
|
||||
"printf 'patchExitCode\\t%s\\n' \"$patch_exit\"",
|
||||
"printf 'rolloutRestartExitCode\\t%s\\n' \"$rollout_restart_exit\"",
|
||||
"printf 'rolloutStatusExitCode\\t%s\\n' \"$rollout_status_exit\"",
|
||||
"printf 'deleteLegacyEndpointsExitCode\\t%s\\n' \"$delete_legacy_endpoints_exit\"",
|
||||
"printf 'deleteExtraEndpointSlicesExitCode\\t%s\\n' \"$delete_extra_endpointslices_exit\"",
|
||||
"printf 'refreshExitCode\\t%s\\n' \"$refresh_exit\"",
|
||||
"if [ \"$dry_run\" != true ] && { [ \"$after_endpoint_resources_excluded\" = yes ] || [ \"$after_endpoints_ignore_updates\" = yes ] || [ \"$after_endpoint_slice_ignore_updates\" = yes ]; }; then exit 46; fi",
|
||||
"if [ \"$dry_run\" != true ] && { [ \"$after_legacy_endpoints_exists\" = yes ] || [ -n \"$after_extra_endpoint_slice_names\" ] || [ \"$after_host_endpointslice_exists\" != yes ]; }; then exit 47; fi",
|
||||
"if [ -n \"$patch_exit\" ] && [ \"$patch_exit\" != 0 ]; then exit \"$patch_exit\"; fi",
|
||||
"if [ -n \"$rollout_restart_exit\" ] && [ \"$rollout_restart_exit\" != 0 ]; then exit \"$rollout_restart_exit\"; fi",
|
||||
"if [ -n \"$rollout_status_exit\" ] && [ \"$rollout_status_exit\" != 0 ]; then exit \"$rollout_status_exit\"; fi",
|
||||
"if [ -n \"$delete_legacy_endpoints_exit\" ] && [ \"$delete_legacy_endpoints_exit\" != 0 ]; then exit \"$delete_legacy_endpoints_exit\"; fi",
|
||||
"if [ -n \"$delete_extra_endpointslices_exit\" ] && [ \"$delete_extra_endpointslices_exit\" != 0 ]; then exit \"$delete_extra_endpointslices_exit\"; fi",
|
||||
"if [ -n \"$refresh_exit\" ] && [ \"$refresh_exit\" != 0 ]; then exit \"$refresh_exit\"; fi",
|
||||
].join("\n");
|
||||
}
|
||||
@@ -689,6 +769,7 @@ function ownedPostgresCleanupScript(options: NodeSecretOptions, spec: RuntimeSec
|
||||
|
||||
function platformDbSecretStatusScript(options: NodeSecretOptions, spec: RuntimeSecretSpec): string {
|
||||
const isOpenFga = options.preset === "openfga";
|
||||
const platformEndpointSlice = `${spec.platformPostgresService}-host`;
|
||||
return [
|
||||
"set +e",
|
||||
`namespace=${shellQuote(spec.namespace)}`,
|
||||
@@ -698,6 +779,7 @@ function platformDbSecretStatusScript(options: NodeSecretOptions, spec: RuntimeS
|
||||
`postgres_password_key=${shellQuote(OPENFGA_POSTGRES_PASSWORD_KEY)}`,
|
||||
`legacy_postgres_secret=${shellQuote(spec.postgresSecret)}`,
|
||||
`platform_service=${shellQuote(spec.platformPostgresService)}`,
|
||||
`platform_endpointslice=${shellQuote(platformEndpointSlice)}`,
|
||||
`platform_host=${shellQuote(spec.platformPostgresService)}`,
|
||||
`platform_host_fqdn=${shellQuote(spec.openFgaDbHost)}`,
|
||||
`db_name=${shellQuote(isOpenFga ? spec.openFgaDbName : spec.cloudApiDbName)}`,
|
||||
@@ -708,7 +790,7 @@ function platformDbSecretStatusScript(options: NodeSecretOptions, spec: RuntimeS
|
||||
"dry_run=true",
|
||||
"secret_exists_flag() { kubectl -n \"$namespace\" get secret \"$1\" >/dev/null 2>&1 && printf yes || printf no; }",
|
||||
"resource_exists_flag() { kubectl -n \"$namespace\" get \"$1\" \"$2\" >/dev/null 2>&1 && printf yes || printf no; }",
|
||||
"endpointslice_exists_flag() { kubectl -n \"$namespace\" get endpointslice -l \"kubernetes.io/service-name=$1\" -o name 2>/dev/null | grep -q . && printf yes || printf no; }",
|
||||
"endpointslice_exists_flag() { kubectl -n \"$namespace\" get endpointslice \"$1\" >/dev/null 2>&1 && printf yes || printf no; }",
|
||||
"secret_b64_key() { kubectl -n \"$namespace\" get secret \"$1\" -o \"go-template={{ index .data \\\"$2\\\" }}\" 2>/dev/null || true; }",
|
||||
"decoded_value() { if [ -n \"$1\" ]; then printf '%s' \"$1\" | base64 -d 2>/dev/null || true; fi; }",
|
||||
"decoded_length() { if [ -n \"$1\" ]; then printf '%s' \"$1\" | base64 -d 2>/dev/null | wc -c | tr -d ' '; else printf '0'; fi; }",
|
||||
@@ -738,7 +820,7 @@ function platformDbSecretStatusScript(options: NodeSecretOptions, spec: RuntimeS
|
||||
"pg_password_bytes=$(decoded_length \"$pg_password_b64\")",
|
||||
"platform_service_exists=$(resource_exists_flag service \"$platform_service\")",
|
||||
"platform_endpoints_exists=$(resource_exists_flag endpoints \"$platform_service\")",
|
||||
"platform_endpointslice_exists=$(endpointslice_exists_flag \"$platform_service\")",
|
||||
"platform_endpointslice_exists=$(endpointslice_exists_flag \"$platform_endpointslice\")",
|
||||
"uri_matches_expected \"$uri_value\"",
|
||||
"printf 'namespace\\t%s\\n' \"$namespace\"",
|
||||
"printf 'secret\\t%s\\n' \"$name\"",
|
||||
@@ -763,6 +845,7 @@ function platformDbSecretStatusScript(options: NodeSecretOptions, spec: RuntimeS
|
||||
"printf 'platformService\\t%s\\n' \"$platform_service\"",
|
||||
"printf 'platformServiceExists\\t%s\\n' \"$platform_service_exists\"",
|
||||
"printf 'platformEndpointsExists\\t%s\\n' \"$platform_endpoints_exists\"",
|
||||
"printf 'platformEndpointSlice\\t%s\\n' \"$platform_endpointslice\"",
|
||||
"printf 'platformEndpointSliceExists\\t%s\\n' \"$platform_endpointslice_exists\"",
|
||||
"printf 'dbName\\t%s\\n' \"$db_name\"",
|
||||
"printf 'dbUser\\t%s\\n' \"$db_user\"",
|
||||
@@ -1357,7 +1440,8 @@ function secretStatusFromText(text: string, commandOk: boolean, exitCode: number
|
||||
fields.afterDatabaseUrlPresent === "yes" &&
|
||||
typeof afterUrlBytes === "number" && afterUrlBytes > 0;
|
||||
const platformBridgeHealthy = fields.platformServiceExists === "yes" &&
|
||||
(fields.platformEndpointsExists === "yes" || fields.platformEndpointSliceExists === "yes");
|
||||
fields.platformEndpointsExists !== "yes" &&
|
||||
fields.platformEndpointSliceExists === "yes";
|
||||
const uriHealthy = fields.dbHostMatchesPlatform === "yes" &&
|
||||
fields.dbNameMatchesExpected === "yes" &&
|
||||
fields.dbUserMatchesExpected === "yes";
|
||||
@@ -1384,6 +1468,8 @@ function secretStatusFromText(text: string, commandOk: boolean, exitCode: number
|
||||
name: fields.platformService || spec.platformPostgresService,
|
||||
exists: fields.platformServiceExists === "yes",
|
||||
endpointsExist: fields.platformEndpointsExists === "yes",
|
||||
legacyEndpointsAbsent: fields.platformEndpointsExists !== "yes",
|
||||
endpointSlice: fields.platformEndpointSlice || `${spec.platformPostgresService}-host`,
|
||||
endpointSliceExists: fields.platformEndpointSliceExists === "yes",
|
||||
},
|
||||
dbName: fields.dbName || spec.cloudApiDbName,
|
||||
@@ -1459,7 +1545,8 @@ function secretStatusFromText(text: string, commandOk: boolean, exitCode: number
|
||||
typeof afterAuthnBytes === "number" && afterAuthnBytes > 0 &&
|
||||
typeof afterUriBytes === "number" && afterUriBytes > 0;
|
||||
const platformBridgeHealthy = fields.platformServiceExists === "yes" &&
|
||||
(fields.platformEndpointsExists === "yes" || fields.platformEndpointSliceExists === "yes");
|
||||
fields.platformEndpointsExists !== "yes" &&
|
||||
fields.platformEndpointSliceExists === "yes";
|
||||
const uriHealthy = fields.dbHostMatchesPlatform === "yes" &&
|
||||
fields.dbNameMatchesExpected === "yes" &&
|
||||
fields.dbUserMatchesExpected === "yes";
|
||||
@@ -1487,6 +1574,8 @@ function secretStatusFromText(text: string, commandOk: boolean, exitCode: number
|
||||
name: fields.platformService || spec.platformPostgresService,
|
||||
exists: fields.platformServiceExists === "yes",
|
||||
endpointsExist: fields.platformEndpointsExists === "yes",
|
||||
legacyEndpointsAbsent: fields.platformEndpointsExists !== "yes",
|
||||
endpointSlice: fields.platformEndpointSlice || `${spec.platformPostgresService}-host`,
|
||||
endpointSliceExists: fields.platformEndpointSliceExists === "yes",
|
||||
},
|
||||
dbName: fields.dbName || spec.openFgaDbName,
|
||||
@@ -1625,6 +1714,11 @@ function numericField(value: string | undefined): number | null {
|
||||
return Number.isFinite(parsed) ? parsed : null;
|
||||
}
|
||||
|
||||
function splitWhitespaceField(value: string | undefined): string[] {
|
||||
if (!value) return [];
|
||||
return value.split(/\s+/u).filter(Boolean);
|
||||
}
|
||||
|
||||
function compactCommandResult(result: CommandResult): Record<string, unknown> {
|
||||
return {
|
||||
command: compactCommand(result.command),
|
||||
|
||||
Reference in New Issue
Block a user