calicovppctl: improve capture file transfer robustness#869
Merged
Conversation
sknat
reviewed
Jan 29, 2026
sknat
reviewed
Jan 29, 2026
Collaborator
sknat
left a comment
There was a problem hiding this comment.
Good catch, thanks for taking a stab at it !
A few comments inline
92f6100 to
97a2b74
Compare
Replace kubectl exec shell command with Kubernetes Go client API (remotecommand) for streaming capture files. This improves error handling and avoids shell-related issues. Key changes: - Use k8s.io/client-go/tools/remotecommand for file streaming instead of exec.Command with kubectl - Add retry logic (3 attempts) for file transfer to handle transient network issues - On transfer failure, print manual recovery instructions and preserve remote files for manual retrieval - Clean up pre-existing capture files before starting new captures to prevent stale capture data - Extend 'capture clear' command to also remove remote capture files (/tmp/trace.txt, /tmp/trace.pcap, /tmp/dispatch.pcap and .gz variants) Signed-off-by: Aritra Basu <aritrbas@cisco.com>
97a2b74 to
f9be920
Compare
sknat
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the robustness of capture file downloads in
calicovppctlfortrace,pcap, anddispatchcommands.Problem
Large capture file downloads using
kubectl cpwere unreliable, often failing mid-transfer with generic errors forcing users to rerun entire captures when the transfer failed.Changes
1. Use Kubernetes Go Client API Instead of Shell Exec
Replace
exec.Command(kubectl ...)with the native Kubernetes Go client API (k8s.io/client-go/tools/remotecommand). This provides better error handling with structured errors through direct integration with the existing Kubernetes client.2. Retry Logic for File Transfer
Add retry mechanism (3 attempts) for file transfers. This handles transient network issues that commonly cause failures with large capture files.
3. Graceful Failure with Manual Recovery
When file transfer fails after all 3 retry attempts:
calicovppctl capture clearfor cleanup after manual retrieval4. Pre-existing File Cleanup
Before starting a new capture, any pre-existing capture file is removed. This ensures fresh captures without stale data and prevents accidental appending to pre-existing capture files.
5. Enhanced
capture clearCommandThe
capture clearcommand now also removes remote capture files:/tmp/trace.txtand/tmp/trace.txt.gz/tmp/trace.pcapand/tmp/trace.pcap.gz/tmp/dispatch.pcapand/tmp/dispatch.pcap.gz