Skip to content

Enhance debug conn with --kind filter; move sweeper to internal/debug. - #2604

Open
AryanP123 wants to merge 3 commits into
skupperproject:mainfrom
AryanP123:enhance-debug-conn-kind
Open

AryanP123 wants to merge 3 commits into
skupperproject:mainfrom
AryanP123:enhance-debug-conn-kind

Conversation

@AryanP123

@AryanP123 AryanP123 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Relocate the sweeper package out of cmd so the CLI is a thin wrapper, and add filtering/labeling by correlated resource kind (listener, connector, multikeylistener).

Fixes #2601

Summary by CodeRabbit

  • New Features
    • Added a --kind filter to connection debugging and port listings for listeners, connectors, and multikey listeners.
    • Resource-kind aliases are normalized, while invalid or explicitly empty filters are rejected.
    • Connection and port results now display each resource’s kind.
    • Kind filtering can be combined with routing-key filtering to narrow connection results and port statistics.
    • Port listings preserve and display multiple associated resource kinds when applicable.

Relocate the sweeper package out of cmd so the CLI is a thin wrapper, and
add filtering/labeling by correlated resource kind (listener, connector,
multikeylistener).
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 80876856-511d-41aa-8b0d-87a5ae7dfbd2
📥 Commits

Reviewing files that changed from the base of the PR and between 1a8868a and 0dc6d2d.

📒 Files selected for processing: 2
  • internal/debug/sweeper/enrich.go
  • internal/debug/sweeper/enrich_filter_test.go
🚧 Files skipped from review as they are similar to previous changes: 2
  • internal/debug/sweeper/enrich_filter_test.go
  • internal/debug/sweeper/enrich.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The debug connection command accepts resource-kind filters. The shared sweeper normalizes and applies them to connection inspection and port listings. Connection and port output includes resource kinds.

Changes: Connection sweeper kind filters

Layer / File(s) Summary
Kind filter contract and enrichment
internal/cmd/skupper/common/flags.go, internal/debug/sweeper/filter.go, internal/debug/sweeper/enrich.go, internal/debug/sweeper/enrich_filter_test.go
The sweeper accepts resource-kind aliases, normalizes filters, matches connections and port statistics, preserves correlated endpoint kinds, and tests these behaviors.
Sweeper execution and output
internal/debug/sweeper/gather.go, internal/debug/sweeper/sweeper.go, internal/debug/sweeper/ports.go, internal/debug/sweeper/output.go
Connection inspection and port listing request endpoint data when kinds are configured, apply kind filters, and include kinds in text output.
CLI kind filter wiring
internal/cmd/skupper/debug/debug.go, internal/cmd/skupper/debug/kube/conn_sweeper.go, internal/cmd/skupper/debug/nonkube/conn_sweeper.go
The command documents and registers --kind. Kubernetes and non-Kubernetes modes validate kind values and pass them to the shared sweeper package.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI as debug conn CLI
  participant Run as sweeper.Run
  participant Gather as Gather
  participant Filter as FilterByKinds
  participant Report as connection report
  CLI->>Run: Config with Kinds
  Run->>Gather: Gather with endpoint data required
  Gather-->>Run: connections
  Run->>Filter: connections and normalized kinds
  Filter-->>Run: matching connections
  Run->>Report: filtered connections
Loading
Merge Risk: ⚪ Minimal · up to 0dc6d

No actionable issue remains; the kind-filtered port listing is ready to merge after normal checks.

Security architecture risk: 🔵 Low · up to 1a886

The filter narrows an existing administrative operation and preserves explicit execution and failure reporting. No expanded access was established. Some uncertainty remains around kind selection when different listener kinds share a port.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The sensitive outcome remains closure of selected router connections through the existing management endpoint or Kubernetes pod execution context. Kubernetes execution can span the selected router pods. Effects can include the paired connection leg, so kind selection is not isolation of all downstream effects to one resource kind.

Trust Boundaries and Controls

  • inferred — The new user-controlled kind value is a selector, not a new authority source. It is normalized and applied before the existing explicit execution gate; the sensitive operation remains an identity-targeted management update. The inspected change does not demonstrate a new authentication bypass or privilege grant.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 37.04% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes both primary changes: adding the --kind filter and moving the sweeper package to internal/debug.
Linked Issues check Passed Issue #2601 requires resource-kind filtering or labeling and core sweeper logic outside cmd. The PR adds --kind support for listener, connector, and multikeylistener, validates and applies f…
Out of Scope Changes check Passed The changes stay within issue #2601. They add resource-kind options, validation, correlation, filtering, output labels, tests, and the sweeper relocation. No unrelated product behavior is established …
Full details: Linked Issues check

Explanation

Issue #2601 requires resource-kind filtering or labeling and core sweeper logic outside cmd. The PR adds --kind support for listener, connector, and multikeylistener, validates and applies filters to connections and port statistics, preserves multiple correlated kinds, and labels output with KIND. The CLI imports internal/debug/sweeper. Tests cover normalization, filtering, enrichment, and shared-port kind preservation.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2601. They add resource-kind options, validation, correlation, filtering, output labels, tests, and the sweeper relocation. No unrelated product behavior is established by the reviewed changes.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3f569c3f-2eb8-4a3b-8868-7972200ef825
📥 Commits

Reviewing files that changed from the base of the PR and between 15c974d and 2684a7d.

📒 Files selected for processing: 17
  • internal/cmd/skupper/common/flags.go
  • internal/cmd/skupper/debug/debug.go
  • internal/cmd/skupper/debug/kube/conn_sweeper.go
  • internal/cmd/skupper/debug/nonkube/conn_sweeper.go
  • internal/debug/sweeper/criteria.go
  • internal/debug/sweeper/enrich.go
  • internal/debug/sweeper/enrich_filter_test.go
  • internal/debug/sweeper/filter.go
  • internal/debug/sweeper/gather.go
  • internal/debug/sweeper/gather_test.go
  • internal/debug/sweeper/inetdiag.go
  • internal/debug/sweeper/inetdiag_test.go
  • internal/debug/sweeper/kill.go
  • internal/debug/sweeper/output.go
  • internal/debug/sweeper/ports.go
  • internal/debug/sweeper/ports_test.go
  • internal/debug/sweeper/sweeper.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread internal/debug/sweeper/filter.go Outdated
Comment thread internal/debug/sweeper/ports.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 106c1eeb-77db-4940-af2a-6b37a9ead079
📥 Commits

Reviewing files that changed from the base of the PR and between 2684a7d and 1a8868a.

📒 Files selected for processing: 4
  • internal/debug/sweeper/enrich.go
  • internal/debug/sweeper/enrich_filter_test.go
  • internal/debug/sweeper/filter.go
  • internal/debug/sweeper/ports.go
🚧 Files skipped from review as they are similar to previous changes: 3
  • internal/debug/sweeper/ports.go
  • internal/debug/sweeper/enrich_filter_test.go
  • internal/debug/sweeper/filter.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread internal/debug/sweeper/enrich.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance debug conn by resource kind; move sweeper out of cmd

1 participant