chore: Fix try cath and nushell bugs, review for nu 0.110.0
This commit is contained in:
parent
59b3651412
commit
069c8785a9
@ -339,32 +339,31 @@ def execute_migration [config: record, verbose: bool = false] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Execute migration
|
# Execute migration
|
||||||
try {
|
let r = (do { ^$ORCHESTRATOR_BIN ...$cmd_args } | complete)
|
||||||
let result = run-external $ORCHESTRATOR_BIN ...$cmd_args
|
if $r.exit_code == 0 {
|
||||||
|
|
||||||
if $verbose {
|
if $verbose {
|
||||||
log info $"Migration completed: ($result)"
|
log info $"Migration completed: ($r.stdout)"
|
||||||
}
|
}
|
||||||
|
|
||||||
print "✅ Migration completed successfully!"
|
print "✅ Migration completed successfully!"
|
||||||
|
|
||||||
# Parse and display results if available
|
# Parse and display results if available
|
||||||
if ($result | str contains "Migration Report") {
|
if ($r.stdout | str contains "Migration Report") {
|
||||||
print "\n📊 Migration Report"
|
print "\n📊 Migration Report"
|
||||||
print "==================="
|
print "==================="
|
||||||
print $result
|
print $r.stdout
|
||||||
}
|
}
|
||||||
} catch {
|
} else {
|
||||||
print "❌ Migration failed!"
|
print "❌ Migration failed!"
|
||||||
|
|
||||||
# Try to get error details from the binary
|
# Try to get error details from the binary
|
||||||
let error_result = run-external $ORCHESTRATOR_BIN ...$cmd_args --dry-run
|
let r2 = (do { ^$ORCHESTRATOR_BIN ...$cmd_args --dry-run } | complete)
|
||||||
print $"Error details: ($error_result)"
|
print $"Error details: ($r2.stdout)"
|
||||||
} finally {
|
}
|
||||||
|
|
||||||
# Clean up temporary config file
|
# Clean up temporary config file
|
||||||
rm -f $config_file
|
rm -f $config_file
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Execute interactive migration
|
# Execute interactive migration
|
||||||
def execute_migration_interactive [config: record] {
|
def execute_migration_interactive [config: record] {
|
||||||
@ -394,22 +393,20 @@ def execute_migration_interactive [config: record] {
|
|||||||
let config_file = $"/tmp/migration_config_(random uuid).json"
|
let config_file = $"/tmp/migration_config_(random uuid).json"
|
||||||
$binary_config | to json | save $config_file
|
$binary_config | to json | save $config_file
|
||||||
|
|
||||||
try {
|
|
||||||
# Real-time progress monitoring
|
# Real-time progress monitoring
|
||||||
print "📊 Migration Progress:"
|
print "📊 Migration Progress:"
|
||||||
print "=====================\n"
|
print "=====================\n"
|
||||||
|
|
||||||
let result = run-external $ORCHESTRATOR_BIN "migrate" "--config-file" $config_file "--progress"
|
let r = (do { ^$ORCHESTRATOR_BIN "migrate" "--config-file" $config_file "--progress" } | complete)
|
||||||
|
if $r.exit_code == 0 {
|
||||||
print "\n✅ Migration completed successfully!"
|
print "\n✅ Migration completed successfully!"
|
||||||
print $result
|
print $r.stdout
|
||||||
|
} else {
|
||||||
} catch {
|
|
||||||
print "\n❌ Migration failed!"
|
print "\n❌ Migration failed!"
|
||||||
print "Check the logs for more details."
|
print "Check the logs for more details."
|
||||||
} finally {
|
|
||||||
rm -f $config_file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rm -f $config_file
|
||||||
}
|
}
|
||||||
|
|
||||||
# Validate storage types
|
# Validate storage types
|
||||||
@ -628,10 +625,10 @@ def "migrate validate" [
|
|||||||
def "migrate status" [] {
|
def "migrate status" [] {
|
||||||
print "🔍 Checking Migration Status..."
|
print "🔍 Checking Migration Status..."
|
||||||
|
|
||||||
try {
|
let r = (do { ^$ORCHESTRATOR_BIN "migrate" "--status" } | complete)
|
||||||
let status = run-external $ORCHESTRATOR_BIN "migrate" "--status"
|
if $r.exit_code == 0 {
|
||||||
print $status
|
print $r.stdout
|
||||||
} catch {
|
} else {
|
||||||
print "No active migrations found or binary not available"
|
print "No active migrations found or binary not available"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,11 +132,12 @@ def check_service [pid_file: string] {
|
|||||||
print $"✓ KMS service is running \(PID: ($pid)\)"
|
print $"✓ KMS service is running \(PID: ($pid)\)"
|
||||||
|
|
||||||
# Check health endpoint
|
# Check health endpoint
|
||||||
try {
|
let r = (do { ^http get "http://localhost:8081/api/v1/kms/health" | from json } | complete)
|
||||||
let health = http get "http://localhost:8081/api/v1/kms/health" | from json
|
if $r.exit_code == 0 {
|
||||||
|
let health = ($r.stdout | from json)
|
||||||
print $" Status: ($health.status)"
|
print $" Status: ($health.status)"
|
||||||
print $" Backend: ($health.backend)"
|
print $" Backend: ($health.backend)"
|
||||||
} catch {
|
} else {
|
||||||
print " ⚠ Health check failed - service may be starting"
|
print " ⚠ Health check failed - service may be starting"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -132,11 +132,11 @@ def main [
|
|||||||
|
|
||||||
# Check if Docker is installed and running
|
# Check if Docker is installed and running
|
||||||
def check_docker [] {
|
def check_docker [] {
|
||||||
try {
|
let result = (do { docker ps | complete } | complete)
|
||||||
docker ps | complete | get exit_code | $in == 0
|
if $result.exit_code == 0 {
|
||||||
print $"(ansi green)✓ Docker is running(ansi reset)"
|
print $"(ansi green)✓ Docker is running(ansi reset)"
|
||||||
true
|
true
|
||||||
} catch {
|
} else {
|
||||||
print $"(ansi red_bold)✗ Docker is not running or not installed(ansi reset)"
|
print $"(ansi red_bold)✗ Docker is not running or not installed(ansi reset)"
|
||||||
print "Please install Docker and ensure it's running"
|
print "Please install Docker and ensure it's running"
|
||||||
false
|
false
|
||||||
@ -145,11 +145,11 @@ def check_docker [] {
|
|||||||
|
|
||||||
# Check if docker compose is installed
|
# Check if docker compose is installed
|
||||||
def check_docker_compose [] {
|
def check_docker_compose [] {
|
||||||
try {
|
let result = (do { docker compose version | complete } | complete)
|
||||||
docker compose version | complete | get exit_code | $in == 0
|
if $result.exit_code == 0 {
|
||||||
print $"(ansi green)✓ docker compose is installed(ansi reset)"
|
print $"(ansi green)✓ docker compose is installed(ansi reset)"
|
||||||
true
|
true
|
||||||
} catch {
|
} else {
|
||||||
print $"(ansi red_bold)✗ docker compose is not installed(ansi reset)"
|
print $"(ansi red_bold)✗ docker compose is not installed(ansi reset)"
|
||||||
print "Please install docker compose plugin"
|
print "Please install docker compose plugin"
|
||||||
false
|
false
|
||||||
@ -208,21 +208,17 @@ def validate_env_file [file: string] {
|
|||||||
|
|
||||||
# Create Docker networks
|
# Create Docker networks
|
||||||
def create_networks [] {
|
def create_networks [] {
|
||||||
try {
|
let networks = [
|
||||||
docker network create provisioning-net | ignore
|
"provisioning-net"
|
||||||
} catch {}
|
"provisioning-net-frontend"
|
||||||
|
"provisioning-net-backend"
|
||||||
|
"provisioning-net-storage"
|
||||||
|
]
|
||||||
|
|
||||||
try {
|
for network in $networks {
|
||||||
docker network create provisioning-net-frontend | ignore
|
let result = (do { docker network create $network } | complete)
|
||||||
} catch {}
|
# Ignore errors (network may already exist)
|
||||||
|
}
|
||||||
try {
|
|
||||||
docker network create provisioning-net-backend | ignore
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
docker network create provisioning-net-storage | ignore
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run docker compose down
|
# Run docker compose down
|
||||||
|
|||||||
@ -27,9 +27,8 @@ def main [--mode: string = "all", --format: string = "all", --output-dir: string
|
|||||||
|
|
||||||
# Create output directories
|
# Create output directories
|
||||||
[docker-compose kubernetes nginx prometheus systemd oci-registry] | each { |dir|
|
[docker-compose kubernetes nginx prometheus systemd oci-registry] | each { |dir|
|
||||||
try {
|
let r = (do { mkdir $"($output_base)/($dir)" } | complete)
|
||||||
mkdir $"($output_base)/($dir)"
|
if $r.exit_code != 0 { }
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1. Generate Docker Compose configurations
|
# 1. Generate Docker Compose configurations
|
||||||
@ -89,21 +88,17 @@ def generate_docker_compose [mode: string, schema_base: string, output_base: str
|
|||||||
|
|
||||||
if ($formats | any { |f| $f == "yaml" }) {
|
if ($formats | any { |f| $f == "yaml" }) {
|
||||||
log info $" Generating docker-compose.($mode).yaml..."
|
log info $" Generating docker-compose.($mode).yaml..."
|
||||||
try {
|
let r = (do { ^nickel export --format yaml $schema_file | save $"($output_base)/docker-compose/docker-compose.($mode).yaml" } | complete)
|
||||||
nickel export --format yaml $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/docker-compose/docker-compose.($mode).yaml"
|
log error $"Failed to generate docker-compose.($mode).yaml"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate docker-compose.($mode).yaml: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($formats | any { |f| $f == "json" }) {
|
if ($formats | any { |f| $f == "json" }) {
|
||||||
log info $" Generating docker-compose.($mode).json..."
|
log info $" Generating docker-compose.($mode).json..."
|
||||||
try {
|
let r = (do { ^nickel export --format json $schema_file | save $"($output_base)/docker-compose/docker-compose.($mode).json" } | complete)
|
||||||
nickel export --format json $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/docker-compose/docker-compose.($mode).json"
|
log error $"Failed to generate docker-compose.($mode).json"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate docker-compose.($mode).json: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,17 +107,14 @@ def generate_kubernetes [mode: string, schema_base: string, output_base: string,
|
|||||||
let schema_file = $"($schema_base)/kubernetes.ncl"
|
let schema_file = $"($schema_base)/kubernetes.ncl"
|
||||||
let mode_subdir = $"($output_base)/kubernetes/($mode)"
|
let mode_subdir = $"($output_base)/kubernetes/($mode)"
|
||||||
|
|
||||||
try {
|
let r = (do { mkdir $mode_subdir } | complete)
|
||||||
mkdir $mode_subdir
|
if $r.exit_code != 0 { }
|
||||||
} catch { }
|
|
||||||
|
|
||||||
if ($formats | any { |f| $f == "yaml" }) {
|
if ($formats | any { |f| $f == "yaml" }) {
|
||||||
log info $" Generating kubernetes/($mode)/deployment.yaml..."
|
log info $" Generating kubernetes/($mode)/deployment.yaml..."
|
||||||
try {
|
let r = (do { ^nickel export --format yaml $schema_file | save $"($mode_subdir)/deployment.yaml" } | complete)
|
||||||
nickel export --format yaml $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($mode_subdir)/deployment.yaml"
|
log error $"Failed to generate kubernetes manifest"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate kubernetes manifest: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,11 +124,9 @@ def generate_nginx [mode: string, schema_base: string, output_base: string, form
|
|||||||
|
|
||||||
if ($formats | any { |f| $f == "json" }) {
|
if ($formats | any { |f| $f == "json" }) {
|
||||||
log info $" Generating nginx.($mode).json..."
|
log info $" Generating nginx.($mode).json..."
|
||||||
try {
|
let r = (do { ^nickel export --format json $schema_file | save $"($output_base)/nginx/nginx.($mode).json" } | complete)
|
||||||
nickel export --format json $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/nginx/nginx.($mode).json"
|
log error $"Failed to generate nginx config"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate nginx config: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,11 +136,9 @@ def generate_prometheus [mode: string, schema_base: string, output_base: string,
|
|||||||
|
|
||||||
if ($formats | any { |f| $f == "yaml" }) {
|
if ($formats | any { |f| $f == "yaml" }) {
|
||||||
log info $" Generating prometheus.($mode).yml..."
|
log info $" Generating prometheus.($mode).yml..."
|
||||||
try {
|
let r = (do { ^nickel export --format yaml $schema_file | save $"($output_base)/prometheus/prometheus.($mode).yml" } | complete)
|
||||||
nickel export --format yaml $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/prometheus/prometheus.($mode).yml"
|
log error $"Failed to generate prometheus config"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate prometheus config: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,11 +148,9 @@ def generate_systemd [mode: string, schema_base: string, output_base: string, fo
|
|||||||
|
|
||||||
if ($formats | any { |f| $f == "json" }) {
|
if ($formats | any { |f| $f == "json" }) {
|
||||||
log info $" Generating systemd.($mode).json..."
|
log info $" Generating systemd.($mode).json..."
|
||||||
try {
|
let r = (do { ^nickel export --format json $schema_file | save $"($output_base)/systemd/systemd.($mode).json" } | complete)
|
||||||
nickel export --format json $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/systemd/systemd.($mode).json"
|
log error $"Failed to generate systemd units"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate systemd units: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,11 +160,9 @@ def generate_oci_registry [mode: string, schema_base: string, output_base: strin
|
|||||||
|
|
||||||
if ($formats | any { |f| $f == "json" }) {
|
if ($formats | any { |f| $f == "json" }) {
|
||||||
log info $" Generating oci-registry.($mode).json..."
|
log info $" Generating oci-registry.($mode).json..."
|
||||||
try {
|
let r = (do { ^nickel export --format json $schema_file | save $"($output_base)/oci-registry/oci-registry.($mode).json" } | complete)
|
||||||
nickel export --format json $schema_file
|
if $r.exit_code != 0 {
|
||||||
| save $"($output_base)/oci-registry/oci-registry.($mode).json"
|
log error $"Failed to generate OCI registry config"
|
||||||
} catch {|e|
|
|
||||||
log error $"Failed to generate OCI registry config: ($e.msg)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,20 +44,30 @@ def main [
|
|||||||
$content = ($content | str replace -a $secret.key $secret.value)
|
$content = ($content | str replace -a $secret.key $secret.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save file
|
# Save file with restricted permissions (600: rw-------)
|
||||||
$content | save -f $output
|
$content | save -f $output
|
||||||
|
do {
|
||||||
|
^chmod 600 $output | complete
|
||||||
|
} catch {
|
||||||
|
print $"(ansi yellow)⚠️ Warning: Could not set restrictive permissions on ($output)(ansi reset)"
|
||||||
|
}
|
||||||
|
|
||||||
print $"(ansi green)✓ Generated ($output) with secure secrets(ansi reset)"
|
print $"(ansi green)✓ Generated ($output) with secure secrets(ansi reset)"
|
||||||
print ""
|
print ""
|
||||||
print $"(ansi cyan_bold)Generated Secrets:(ansi reset)"
|
print $"(ansi cyan_bold)Generated Secrets (redacted):(ansi reset)"
|
||||||
|
|
||||||
for secret in ($secrets | transpose key value) {
|
for secret in ($secrets | transpose key value) {
|
||||||
let name = ($secret.key | str replace "CHANGE_ME_" "" | str replace "_" " " | str downcase | str title-case)
|
let name = ($secret.key | str replace "CHANGE_ME_" "" | str replace "_" " " | str downcase | str title-case)
|
||||||
print $" ($name): ($secret.value | str substring 0..8)..."
|
print $" ($name): [REDACTED - see ($output)]"
|
||||||
}
|
}
|
||||||
|
|
||||||
print ""
|
print ""
|
||||||
print $"(ansi yellow)Keep this file secure! Add to .gitignore:(ansi reset)"
|
print $"(ansi yellow)⚠️ SECURITY WARNING:(ansi reset)"
|
||||||
|
print $" • Secrets are held in this process memory temporarily"
|
||||||
|
print $" • The file ($output) contains unencrypted secrets"
|
||||||
|
print $" • Use encrypted vaults (SOPS/Age) for production secrets"
|
||||||
|
print $" • Never commit ($output) to version control"
|
||||||
|
print $" • Add to .gitignore immediately:"
|
||||||
print $" echo '($output)' >> .gitignore"
|
print $" echo '($output)' >> .gitignore"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ def main [
|
|||||||
|
|
||||||
# Check HTTP service health
|
# Check HTTP service health
|
||||||
def check_service [name: string, url: string, timeout: int] {
|
def check_service [name: string, url: string, timeout: int] {
|
||||||
try {
|
let result = (do {
|
||||||
let response = (http get --max-time $timeout $url)
|
let response = (http get --max-time $timeout $url)
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
@ -72,21 +72,25 @@ def check_service [name: string, url: string, timeout: int] {
|
|||||||
url: $url,
|
url: $url,
|
||||||
message: "OK"
|
message: "OK"
|
||||||
}
|
}
|
||||||
} catch {
|
} | complete)
|
||||||
|
|
||||||
|
if $result.exit_code != 0 {
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
status: "unhealthy",
|
status: "unhealthy",
|
||||||
url: $url,
|
url: $url,
|
||||||
message: $"Failed to connect to ($url)"
|
message: $"Failed to connect to ($url)"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result.stdout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check DNS service
|
# Check DNS service
|
||||||
def check_dns [name: string, host: string, port: int, timeout: int] {
|
def check_dns [name: string, host: string, port: int, timeout: int] {
|
||||||
try {
|
let result = (do {
|
||||||
dig +short +time=($timeout) @($host) -p ($port) health.check | complete | get exit_code
|
let dig_result = (dig +short +time=($timeout) @($host) -p ($port) health.check | complete)
|
||||||
if $in == 0 {
|
if $dig_result.exit_code == 0 {
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
status: "healthy",
|
status: "healthy",
|
||||||
@ -101,21 +105,25 @@ def check_dns [name: string, host: string, port: int, timeout: int] {
|
|||||||
message: "DNS not responding"
|
message: "DNS not responding"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} | complete)
|
||||||
|
|
||||||
|
if $result.exit_code != 0 {
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
status: "unhealthy",
|
status: "unhealthy",
|
||||||
url: $"dns://($host):($port)",
|
url: $"dns://($host):($port)",
|
||||||
message: "Failed to query DNS"
|
message: "Failed to query DNS"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result.stdout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check PostgreSQL
|
# Check PostgreSQL
|
||||||
def check_postgres [name: string, host: string, port: int, timeout: int] {
|
def check_postgres [name: string, host: string, port: int, timeout: int] {
|
||||||
try {
|
let result = (do {
|
||||||
docker exec provisioning-postgres pg_isready -h localhost -p 5432 | complete | get exit_code
|
let pg_result = (docker exec provisioning-postgres pg_isready -h localhost -p 5432 | complete)
|
||||||
if $in == 0 {
|
if $pg_result.exit_code == 0 {
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
status: "healthy",
|
status: "healthy",
|
||||||
@ -130,13 +138,17 @@ def check_postgres [name: string, host: string, port: int, timeout: int] {
|
|||||||
message: "PostgreSQL not ready"
|
message: "PostgreSQL not ready"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} | complete)
|
||||||
|
|
||||||
|
if $result.exit_code != 0 {
|
||||||
{
|
{
|
||||||
service: $name,
|
service: $name,
|
||||||
status: "unhealthy",
|
status: "unhealthy",
|
||||||
url: $"postgres://($host):($port)",
|
url: $"postgres://($host):($port)",
|
||||||
message: "Failed to check PostgreSQL"
|
message: "Failed to check PostgreSQL"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result.stdout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -172,26 +172,26 @@ def "main health" [] {
|
|||||||
print "🏥 Health Check:\n"
|
print "🏥 Health Check:\n"
|
||||||
|
|
||||||
# Check orchestrator
|
# Check orchestrator
|
||||||
try {
|
let r1 = (do { ^http get http://localhost:8080/health } | complete)
|
||||||
let health = (http get http://localhost:8080/health)
|
if $r1.exit_code == 0 {
|
||||||
print $" ✅ Orchestrator: Healthy"
|
print $" ✅ Orchestrator: Healthy"
|
||||||
} catch {
|
} else {
|
||||||
print $" ❌ Orchestrator: Not responding"
|
print $" ❌ Orchestrator: Not responding"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check control-center
|
# Check control-center
|
||||||
try {
|
let r2 = (do { ^http get http://localhost:8081/health } | complete)
|
||||||
let health = (http get http://localhost:8081/health)
|
if $r2.exit_code == 0 {
|
||||||
print $" ✅ Control Center: Healthy"
|
print $" ✅ Control Center: Healthy"
|
||||||
} catch {
|
} else {
|
||||||
print $" ❌ Control Center: Not responding"
|
print $" ❌ Control Center: Not responding"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check KMS (mandatory per ADR-007)
|
# Check KMS (mandatory per ADR-007)
|
||||||
try {
|
let r3 = (do { ^http get http://localhost:9998/health } | complete)
|
||||||
let health = (http get http://localhost:9998/health)
|
if $r3.exit_code == 0 {
|
||||||
print $" ✅ KMS: Healthy"
|
print $" ✅ KMS: Healthy"
|
||||||
} catch {
|
} else {
|
||||||
print $" ❌ KMS: Not responding (required per ADR-007)"
|
print $" ❌ KMS: Not responding (required per ADR-007)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,18 +188,18 @@ def "main health" [] {
|
|||||||
print "🏥 Health Check:\n"
|
print "🏥 Health Check:\n"
|
||||||
|
|
||||||
# Check orchestrator
|
# Check orchestrator
|
||||||
try {
|
let r1 = (do { ^http get http://localhost:8080/health } | complete)
|
||||||
let health = (http get http://localhost:8080/health)
|
if $r1.exit_code == 0 {
|
||||||
print $" ✅ Orchestrator: Healthy"
|
print $" ✅ Orchestrator: Healthy"
|
||||||
} catch {
|
} else {
|
||||||
print $" ❌ Orchestrator: Not responding"
|
print $" ❌ Orchestrator: Not responding"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check control-center
|
# Check control-center
|
||||||
try {
|
let r2 = (do { ^http get http://localhost:8081/health } | complete)
|
||||||
let health = (http get http://localhost:8081/health)
|
if $r2.exit_code == 0 {
|
||||||
print $" ✅ Control Center: Healthy"
|
print $" ✅ Control Center: Healthy"
|
||||||
} catch {
|
} else {
|
||||||
print $" ❌ Control Center: Not responding"
|
print $" ❌ Control Center: Not responding"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,10 @@ def is-running [pid: string] {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
let r = (do { ps | where pid == ($pid | into int) | length } | complete)
|
||||||
(ps | where pid == ($pid | into int) | length) > 0
|
if $r.exit_code == 0 {
|
||||||
} catch {
|
($r.stdout | into int) > 0
|
||||||
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,18 +90,22 @@ def stop-cmd [] {
|
|||||||
|
|
||||||
print $"Stopping daemon (PID: $pid)..."
|
print $"Stopping daemon (PID: $pid)..."
|
||||||
|
|
||||||
try {
|
let r = (do { ^kill $pid } | complete)
|
||||||
^kill $pid
|
if $r.exit_code == 0 {
|
||||||
sleep 500ms
|
sleep 500ms
|
||||||
|
|
||||||
if (is-running $pid) {
|
if (is-running $pid) {
|
||||||
print "Force killing daemon..."
|
print "Force killing daemon..."
|
||||||
^kill -9 $pid
|
let r2 = (do { ^kill -9 $pid } | complete)
|
||||||
|
if $r2.exit_code != 0 {
|
||||||
|
print "✗ Failed to force kill daemon"
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove-pid
|
remove-pid
|
||||||
print "✓ Daemon stopped"
|
print "✓ Daemon stopped"
|
||||||
} catch {
|
} else {
|
||||||
print "✗ Failed to stop daemon"
|
print "✗ Failed to stop daemon"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,10 +122,11 @@ def status-cmd [] {
|
|||||||
print $" HTTP API: http://$DAEMON_HOST:$DAEMON_PORT/api/v1"
|
print $" HTTP API: http://$DAEMON_HOST:$DAEMON_PORT/api/v1"
|
||||||
print $" Nushell: http://$DAEMON_HOST:$DAEMON_PORT/api/v1/execute"
|
print $" Nushell: http://$DAEMON_HOST:$DAEMON_PORT/api/v1/execute"
|
||||||
|
|
||||||
try {
|
let r = (do { ^curl -s $"http://$DAEMON_HOST:$DAEMON_PORT/api/v1/health" | from json } | complete)
|
||||||
let response = (curl -s $"http://$DAEMON_HOST:$DAEMON_PORT/api/v1/health" | from json)
|
if $r.exit_code == 0 {
|
||||||
|
let response = ($r.stdout | from json)
|
||||||
print $" Status: ($response.status)"
|
print $" Status: ($response.status)"
|
||||||
} catch {
|
} else {
|
||||||
print " Health check failed (daemon may not be responding)"
|
print " Health check failed (daemon may not be responding)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,12 +5,8 @@
|
|||||||
|
|
||||||
def check-config [path: string] {
|
def check-config [path: string] {
|
||||||
if ($path | path exists) {
|
if ($path | path exists) {
|
||||||
try {
|
let r = (do { open $path | ignore } | complete)
|
||||||
open $path | ignore
|
if $r.exit_code == 0 { true } else { false }
|
||||||
true
|
|
||||||
} catch {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,16 +28,20 @@ def main [--config-dir: string = "provisioning/platform/infrastructure"] {
|
|||||||
def validate_docker_compose [config_dir: string] {
|
def validate_docker_compose [config_dir: string] {
|
||||||
log info "Validating Docker Compose files..."
|
log info "Validating Docker Compose files..."
|
||||||
|
|
||||||
let dc_files = (try { ls -la $"($config_dir)/docker-compose/*.yaml" } catch { [] })
|
let dc_files_result = (do { ls -la $"($config_dir)/docker-compose/*.yaml" } | complete)
|
||||||
| each { |file| $file.name }
|
let dc_files = if $dc_files_result.exit_code == 0 {
|
||||||
|
($dc_files_result.stdout | lines | each { |line| $line | from json } | each { |file| $file.name })
|
||||||
|
} else {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
for file in $dc_files {
|
for file in $dc_files {
|
||||||
let filename = $file | path basename
|
let filename = $file | path basename
|
||||||
try {
|
let r = (do { ^docker-compose -f $file config --quiet } | complete)
|
||||||
docker-compose -f $file config --quiet
|
if $r.exit_code == 0 {
|
||||||
log info $" ✅ ($filename)"
|
log info $" ✅ ($filename)"
|
||||||
} catch {|e|
|
} else {
|
||||||
log warning $" ⚠️ ($filename): ($e.msg)"
|
log warning $" ⚠️ ($filename): validation error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,15 +49,19 @@ def validate_docker_compose [config_dir: string] {
|
|||||||
def validate_kubernetes [config_dir: string] {
|
def validate_kubernetes [config_dir: string] {
|
||||||
log info "Validating Kubernetes manifests..."
|
log info "Validating Kubernetes manifests..."
|
||||||
|
|
||||||
let k8s_files = (try { ls -la $"($config_dir)/kubernetes/**/*.yaml" } catch { [] })
|
let k8s_files_result = (do { ls -la $"($config_dir)/kubernetes/**/*.yaml" } | complete)
|
||||||
| each { |file| $file.name }
|
let k8s_files = if $k8s_files_result.exit_code == 0 {
|
||||||
|
($k8s_files_result.stdout | lines | each { |line| $line | from json } | each { |file| $file.name })
|
||||||
|
} else {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
for file in $k8s_files {
|
for file in $k8s_files {
|
||||||
let filename = $file | path basename
|
let filename = $file | path basename
|
||||||
try {
|
let r = (do { ^kubectl apply --dry-run=client -f $file out+err> /dev/null } | complete)
|
||||||
kubectl apply --dry-run=client -f $file out+err> /dev/null
|
if $r.exit_code == 0 {
|
||||||
log info $" ✅ ($filename)"
|
log info $" ✅ ($filename)"
|
||||||
} catch {|e|
|
} else {
|
||||||
log warning $" ⚠️ ($filename): validation error"
|
log warning $" ⚠️ ($filename): validation error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,15 +70,19 @@ def validate_kubernetes [config_dir: string] {
|
|||||||
def validate_nginx [config_dir: string] {
|
def validate_nginx [config_dir: string] {
|
||||||
log info "Validating Nginx configurations..."
|
log info "Validating Nginx configurations..."
|
||||||
|
|
||||||
let nginx_files = (try { ls -la $"($config_dir)/nginx/*.conf" } catch { [] })
|
let nginx_files_result = (do { ls -la $"($config_dir)/nginx/*.conf" } | complete)
|
||||||
| each { |file| $file.name }
|
let nginx_files = if $nginx_files_result.exit_code == 0 {
|
||||||
|
($nginx_files_result.stdout | lines | each { |line| $line | from json } | each { |file| $file.name })
|
||||||
|
} else {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
for file in $nginx_files {
|
for file in $nginx_files {
|
||||||
let filename = $file | path basename
|
let filename = $file | path basename
|
||||||
try {
|
let r = (do { ^nginx -t -c $file out+err> /dev/null } | complete)
|
||||||
nginx -t -c $file out+err> /dev/null
|
if $r.exit_code == 0 {
|
||||||
log info $" ✅ ($filename)"
|
log info $" ✅ ($filename)"
|
||||||
} catch {|e|
|
} else {
|
||||||
log info $" ℹ️ ($filename): nginx binary not available"
|
log info $" ℹ️ ($filename): nginx binary not available"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,15 +91,19 @@ def validate_nginx [config_dir: string] {
|
|||||||
def validate_prometheus [config_dir: string] {
|
def validate_prometheus [config_dir: string] {
|
||||||
log info "Validating Prometheus configurations..."
|
log info "Validating Prometheus configurations..."
|
||||||
|
|
||||||
let prom_files = (try { ls -la $"($config_dir)/prometheus/*.yml" } catch { [] })
|
let prom_files_result = (do { ls -la $"($config_dir)/prometheus/*.yml" } | complete)
|
||||||
| each { |file| $file.name }
|
let prom_files = if $prom_files_result.exit_code == 0 {
|
||||||
|
($prom_files_result.stdout | lines | each { |line| $line | from json } | each { |file| $file.name })
|
||||||
|
} else {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
for file in $prom_files {
|
for file in $prom_files {
|
||||||
let filename = $file | path basename
|
let filename = $file | path basename
|
||||||
try {
|
let r = (do { ^promtool check config $file out+err> /dev/null } | complete)
|
||||||
promtool check config $file out+err> /dev/null
|
if $r.exit_code == 0 {
|
||||||
log info $" ✅ ($filename)"
|
log info $" ✅ ($filename)"
|
||||||
} catch {|e|
|
} else {
|
||||||
log info $" ℹ️ ($filename): promtool not available"
|
log info $" ℹ️ ($filename): promtool not available"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -155,7 +155,7 @@ def main [] {
|
|||||||
$doc_files
|
$doc_files
|
||||||
| each { |doc|
|
| each { |doc|
|
||||||
if ($doc | path exists) {
|
if ($doc | path exists) {
|
||||||
let lines = (open $doc | split row "\n" | length)
|
let lines = (open $doc | lines | length)
|
||||||
print $"✓ ($doc) - ($lines) lines"
|
print $"✓ ($doc) - ($lines) lines"
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user