fix(kube): action namespace, race condition, stability, dark mode #86
No reviewers
Labels
No Label
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sarman/tftsr-devops_investigation#86
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/kube-action-namespace-and-stability"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root causes fixed
1. Temp kubeconfig race condition — intermittent load failures
Every kubectl command wrote a temp kubeconfig to a static path (
kubeconfig-{cluster_id}-{type}.yaml). Concurrent calls shared the same path; the first to finish deleted the file viaTempFileCleanup::drop()while the second call's kubectl process was still reading it. Replaced all 74 static paths with aunique_kubeconfig_path()helper backed by anAtomicU64counter — each call now gets a unique path. This was the root cause of "things stop loading after a few selection changes".2. Namespace
"all"in pod action commandsPodInfolacked anamespacefield (unlike every other resource type).PodListpassed the UI filter prop (namespace="all") directly to kubectl for every action — logs, shell, attach, edit, delete. Addednamespace: StringtoPodInfo(Rust struct + TypeScript interface + parser), and updatedPodListto usepod.namespacein all action calls.3. Namespace
"all"in all other list component actions18 list components (Deployment, StatefulSet, DaemonSet, Service, ConfigMap, Secret, HPA, PVC, RoleBinding, etc.) had the same bug — action handlers used the filter prop instead of
item.namespace. All fixed.4. WorkloadOverview always showed 0
loadResourceDatahad an early-return forworkloads_overview, so WorkloadOverview always received empty arrays. Now fetches pods + deployments + statefulsets + daemonsets + jobs + cronjobs in parallel viaPromise.allSettledwhen that section is active.5. Double
connectClusterFromKubeconfigCmdon mountloadInitialDataclosed overselectedClusterIdin itsuseCallbackdeps. CallingsetSelectedCluster()inside it recreated the callback and re-fired the effect, triggering a second connect. Fixed with aninitializedRefguard.6. Silent cluster connection errors
Connection failures were swallowed with
.catch(() => {}). Now captured and surfaced as a dismissible error banner.7. Dark mode contrast
PortForwardListstatus badge andWorkloadOverviewdot indicator used non-adaptivetext-gray-*/bg-gray-*classes that vanished on dark backgrounds. Replaced with semantic Tailwind vars (text-muted-foreground,bg-muted).Test plan
cargo test→ 364 passnpm run test:run→ 325 pass (40 files)npx tsc --noEmit→ 0 errorsnpx eslint . --max-warnings 0→ 0 warningscargo fmt --check→ cleancargo clippy -- -D warnings→ 0 warningsAutomated PR Review (qwen3-coder-next via liteLLM):\n\nSummary
The PR addresses critical race conditions, namespace handling bugs, and dark mode issues in the Kubernetes interface. A comprehensive refactor introduced unique temp kubeconfig paths and propagated
namespacefrom resource data in both Rust structs and TypeScript components. The changes are extensive and well-tested, but two high-severity issues remain: thediscover_podsfunction incorrectly uses a hardcodednamespaceparameter instead of respecting"all"→""conversion, andlist_namespaces_resourcelacksnamespacefiltering.Findings
[BLOCKER] src-tauri/src/commands/kube.rs:484 -
discover_podspassesnamespacedirectly tokubectl -n {namespace}without converting"all"→"", causingkubectl -n allfailuresEvidence:
kubectl_cmd.arg("-n").arg(&namespace);indiscover_pods(lines 482–485 in full file) and no handling of"all"caseFix: Replace
kubectl_cmd.arg("-n").arg(&namespace);with logic that appends--all-namespaceswhennamespace == "all"ornamespace.is_empty().[WARNING] src-tauri/src/commands/kube.rs:1238 -
list_namespaces_resourcereturns namespace names but accepts no namespace filter; caller confusion likelyEvidence:
list_namespaces_resource(lines 1227–1306 in full file) runskubectl get namespaces -o jsonwith no-nor--all-namespaces— correct, but theNamespaceResourceInfostruct and UI expectation (e.g., inWorkloadOverview) may imply filtering by namespace when it does not existFix: Document that
list_namespaces_resourceis cluster-scoped and distinct from per-namespace listing; consider adding optional namespace filter if UI truly expects per-namespace resource listing.Verdict: REQUEST CHANGES