prole/knoe/ui/screens/validate.py
chrisfu a069989315 Rename prole-db to knoe-db, add knoe-auth as cluster-internal KDC
Itemized changes:

1. knoe-auth: New cluster-internal KDC and SSO gateway service
   - Created etc/init_knoe_auth.sh based on init_kdc.sh with knoe-auth naming
   - Namespace defaults to SERVICE_NAMESPACE (knoe-system)
   - ConfigMap: knoe-auth-kdc-config, Secret: knoe-auth-secrets
   - Legacy cleanup removes old auth/dog/authority deployments

2. Orchestration: knoe-auth initializes before CloudNativePG
   - Updated prole.sh to insert init_knoe_auth.sh as step 2 (before CNPG)
   - Renumbered all subsequent initialization steps

3. Kong routing: Updated init_kong.sh to route to knoe-auth in SERVICE_NAMESPACE

4. Comment/reference updates for knoe-auth
   - Updated init_common_services.sh, init_service_layer.sh, init_kerberos.sh

5. prole-db renamed to knoe-db across the entire codebase
   - Renamed prole-db/ directory to knoe-db/
   - Renamed all prole-db Kubernetes manifests (deploy/opentofu, k8s/)
   - Renamed scripts: docker-root-knoe-db.sh, docker-run-knoe-db.sh, test-cnpg-knoe-db.sh
   - Renamed etc/init_prole-db-reset.sh to etc/init_knoe-db-reset.sh
   - Renamed etc/prole-db-passwwd.sh to etc/knoe-db-passwwd.sh
   - Renamed mock_val counterparts accordingly
   - Renamed tests/etc/test_init_prole-db-reset.sh to test_init_knoe-db-reset.sh
   - Renamed docs/prole-db-documentation-mcp-architecture.md to knoe-db variant
   - Renamed modes/k3d/prole-db/ to modes/k3d/knoe-db/
   - Renamed prole-db.iml to knoe-db.iml

6. Configuration updates
   - Updated conf/dev, conf/prod, conf/test, conf/service prole.cfg files
   - Updated conf/port-mapping.cfg
   - Updated etc/prole_cfg.sh and mock_val/prole_cfg.sh
   - Updated service/prole.cfg

7. Kubernetes manifests and deploy configuration
   - Updated deploy/opentofu/k3s ArgoCD application YAMLs
   - Updated kong-configmap.yaml and kustomization.yaml
   - Updated k3s/kong-config.yml and prole-resources.yaml
   - Updated prole-mssql-db deployment YAMLs
   - Updated supabase helm render and deploy scripts

8. Infrastructure and GCP Terraform
   - Updated deploy/gcp/terraform: folders, groups, IAM, service-projects

9. Python/installer code updates
   - Updated knoe/core: actions, build_context, controller, env, milestones
   - Updated knoe/milestone.py
   - Updated knoe/ui/screens: cfg, database, database_options, deploy, docker,
     navigation, security, services, validate
   - Updated knoe.spec, status.py

10. Shell script updates
    - Updated etc/: build_db, init_cloudnative_pg, init_cnpg_backup,
      init_db_manager, init_forgejo, init_gitlab, init_monitoring, init_openbao,
      init_port_forwards, init_postgrest, init_supabase_ports, status
    - Updated mock_val/ counterparts for all above scripts
    - Updated prole-net/init-prole-dns.sh
    - Updated bin/prole-kpf.sh, gitea/deploy.sh, supabase/deploy.sh

11. Test updates
    - Updated tests/etc/: test_init_cloudnative_pg*, test_init_cnpg_backup*,
      test_init_kdc*, test_init_kerberos*, test_init_kong*, test_prole_cfg*
    - Updated tests/installer/: test_actions_helpers, test_cfg_save_kubecontext,
      test_controller, test_core_classes, test_milestones, test_milestones_extended,
      test_namespace_propagation
    - Updated tests/: test_database_options, test_navigation,
      test_render_supabase_hostname, test_docker_build_fix,
      test_all_prole_home_fixes, silent_install_test, final_test

12. Documentation updates
    - Updated docs/: DOCKER-BUILD-FIX, PROLE-CFG-SECRETS, PROLE-HOME-DIRECTORY,
      build-system, patent
    - Updated scan/network_description.txt
    - Updated pom.xml

13. Miscellaneous script updates
    - Updated root-level: _adopt_replica_pvcs, _fix_replica_merlin, _import_pi,
      _patch_cluster, _prebind_pvcs, _rebind_d002, _rebind_d002b, test_resolve
    - Updated scripts/generate_spec.py

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-22 22:16:21 -07:00

189 lines
6.7 KiB
Python

"""Validation screen with auto-refresh status monitoring."""
import subprocess
import threading
import time
import webbrowser
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
from knoe.screen import TerminalConsole
from knoe import screen as ui
class ValidateScreenMixin:
"""Validation screen with auto-refresh status monitoring."""
def create_validate_screen(self):
"""Create the Validate screen"""
frame = self._page_container()
self.screens["validate"] = frame
# Title
title = ttk.Label(frame, text="Validate Deployment", style="Title.TLabel")
title.pack(pady=(0, 20))
# Prometheus link
prometheus_frame = tk.Frame(frame, bg="white")
prometheus_frame.pack(pady=(0, 20))
prometheus_label = tk.Label(
prometheus_frame,
text="Prometheus: ",
bg="white",
fg="#6e6e73",
font=("Helvetica", 11),
)
prometheus_label.pack(side="left")
prometheus_link = tk.Label(
prometheus_frame,
text="http://localhost:9090",
bg="white",
fg="#4a9eff",
font=("Helvetica", 11, "underline"),
cursor="hand2",
)
prometheus_link.pack(side="left")
prometheus_link.bind(
"<Button-1>", lambda e: webbrowser.open("http://localhost:9090")
)
# Status display
status_frame = tk.Frame(frame, bg="white")
status_frame.pack(fill="both", expand=True, pady=10)
status_label = ttk.Label(
status_frame, text="Cluster Status", style="Heading.TLabel"
)
status_label.pack(anchor="w", pady=(0, 10))
# Status text area - using TerminalConsole for consistency
# Use a background frame to ensure NO borders are visible around the console
console_bg = tk.Frame(status_frame, bg="white", highlightthickness=0, bd=0)
console_bg.pack(fill="both", expand=True, padx=1, pady=1)
self._validation_console = ui.TerminalConsole(
console_bg, highlightthickness=0, bd=0
)
self._validation_console.pack(fill="both", expand=True)
self.status_text = self._validation_console.text
# Auto-refresh checkbox
refresh_frame = tk.Frame(frame, bg="white")
refresh_frame.pack(pady=10)
self.auto_refresh_var = tk.BooleanVar(value=True)
refresh_check = tk.Checkbutton(
refresh_frame,
text="Auto-refresh every 10 seconds",
variable=self.auto_refresh_var,
bg="white",
fg="#1d1d1f",
selectcolor="#f0f0f0",
activebackground="white",
activeforeground="#1d1d1f",
font=("Helvetica", 10),
command=self.toggle_auto_refresh,
)
refresh_check.pack(side="left", padx=10)
# Manual refresh button
refresh_btn = tk.Button(
refresh_frame,
text="Refresh Now",
command=self.refresh_status,
bg="#4a9eff",
fg="white",
activebackground="#3a8eef",
highlightbackground="white",
font=("Helvetica", 10),
padx=15,
pady=5,
cursor="hand2",
relief="flat",
)
refresh_btn.pack(side="left", padx=10)
# Start auto-refresh
self.refresh_status()
self.toggle_auto_refresh()
def toggle_auto_refresh(self):
"""Toggle auto-refresh"""
if self.auto_refresh_var.get():
if not self.validation_running:
self.validation_running = True
self.validation_thread = threading.Thread(
target=self.auto_refresh_loop, daemon=True
)
self.validation_thread.start()
else:
self.validation_running = False
def auto_refresh_loop(self):
"""Auto-refresh loop"""
while self.validation_running:
time.sleep(10)
if self.validation_running:
self.root.after(0, self.refresh_status)
def refresh_status(self):
"""Refresh the cluster status"""
def update():
try:
full_status = ""
# Get k3d cluster list
try:
cluster_result = subprocess.run(
["k3d", "cluster", "list"],
capture_output=True,
text=True,
timeout=5,
)
full_status += (
f"=== k3d Cluster Status ===\n{cluster_result.stdout}\n\n"
)
except Exception as e:
full_status += f"=== k3d Cluster Status ===\nError: {str(e)}\n\n"
# Get kubectl cnpg status
try:
namespace = (self.db_namespace.get() or "default").strip()
cmd = self._kubectl_base_cmd() + [
"cnpg",
"status",
"knoe-db",
"-n",
namespace,
]
result = subprocess.run(
cmd, capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
status_output = result.stdout
else:
# Try default namespace if prole fails, or just show error
status_output = f"Error: {result.stderr}\n\nNote: Make sure kubectl cnpg plugin is installed and cluster exists in '{namespace}' namespace."
full_status += f"=== CloudNativePG Status (namespace: {namespace}) ===\n{status_output}\n"
except FileNotFoundError:
full_status += "=== CloudNativePG Status ===\nError: kubectl not found. Please install dependencies first.\n"
except subprocess.TimeoutExpired:
full_status += (
"=== CloudNativePG Status ===\nError: Command timed out\n"
)
except Exception as e:
full_status += f"=== CloudNativePG Status ===\nError: {str(e)}\n"
full_status += f"\nLast updated: {time.strftime('%Y-%m-%d %H:%M:%S')}"
self.status_text.delete("1.0", tk.END)
self.status_text.insert("1.0", full_status)
except Exception as e:
self.status_text.delete("1.0", tk.END)
self.status_text.insert("1.0", f"Error: {str(e)}")
threading.Thread(target=update, daemon=True).start()