fix(kube): add two-stage test connection diagnostics #83
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#83
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/kube-test-connection-diagnostics"
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?
Summary
detect_auth_method()to parse the kubeconfig and identify the credential type (exec plugin, bearer token, inline cert, file-referenced cert, basic auth) — surfaces an actionable warning when an exec binary or external cert file is requiredtest_kubectl_connectioninto two staged checks:kubectl get --raw=/healthz(no auth required) isolates connectivity failureskubectl cluster-info(authenticated) tests actual credentialsmemcache.gonoise that previously obscured the root causeTest plan
cargo test→ 343 pass,cargo clippy -- -D warnings→ cleanAutomated PR Review (qwen36-35b-a3b-nvfp4 via liteLLM):\n\nSummary
The PR refactors
test_kubectl_connectionto support two-stage diagnostics (connectivity and authentication) and introducesdetect_auth_methodto identify kubeconfig credential types. A criticaltracingimport is missing from the codebase index despite being used in the file, which will cause compilation failure. Additionally, theauth_methoddiagnostics may incorrectly report "client certificate (inline base64)" for Kubernetes Service Account tokens (which are also base64 encoded PEM bundles), potentially misleading users as to the nature of their auth.Findings
tracingimport causing compilation failure.Evidence: The file uses
info!()(lines 926, 935, 949) anddebug!()(line 1005), but the provided Codebase Index forsrc-tauri/src/commands/kube.rsand the file header do not includeuse tracing::{info, debug};or a globuse tracing::*;. While other files might have these, Rust does not allow reusing imports across files without explicit inclusion. If the index is exhaustive for the module, this is a build break.Fix: Add
use tracing::{info, debug};(oruse tracing::*;) to the imports at the top ofkube.rs.detect_auth_methodclassifies Kubernetes Service Account tokens as "client certificate (inline base64)".Evidence: Kubernetes Service Account tokens (mounted at
/var/run/secrets/kubernetes.io/serviceaccount/token) are base64-encoded PEM bundles that contain a certificate, a private key, and a CA cert. Kubeconfig references this file, but if the user copies the content inline, it is base64 data. More importantly, theclient-certificate-datafield is technically for user-provided client certs. While K8s SA mounts usually use thetokenfield in kubeconfig, some setups might map them differently or the heuristic might be overly broad.Fix: If the intent is to distinguish between user certs and K8s internal certs, consider checking for the presence of specific OIDs in the base64 data or simply labeling it "client certificate (inline)" to be more generic, or relying on the fact that
client-certificate-datainusersusually implies user certs, whiletokenimplies SA. If this is a limitation, document it.connect_cluster_from_kubeconfigerror message implies the cluster is not found in storage, but the error string says "not found in session".Evidence: The error message "not found in session" appears in
test_kubectl_connection(line 239), butconnect_cluster_from_kubeconfiguses "not found in storage". This is actually correct forconnectvstest. However,test_kubectl_connection(line 239) uses "not found in session". Ensure consistency if "session" refers to the in-memory map.Fix: No immediate fix needed, but ensure "session" vs "memory" terminology is consistent if it confuses users.
write_secure_temp_fileusesmode(0o600)which is Unix-specific.Evidence: On Windows, the file is created with default permissions, which might be world-readable. Tauri apps often run on Windows.
Fix: Add a Windows-specific implementation for
write_secure_temp_fileto ensure 0600 equivalent permissions (usingstd::os::windows::fs::OpenOptionsExt) or acknowledge this as a known limitation for non-Unix platforms.Verdict: APPROVE WITH COMMENTS