Skip to content

refactor inspector helper to use iterators instead of callbacks - #248

Open
sivchari wants to merge 1 commit into
kubernetes-sigs:mainfrom
sivchari:worktree-inspector-iterator
Open

refactor inspector helper to use iterators instead of callbacks#248
sivchari wants to merge 1 commit into
kubernetes-sigs:mainfrom
sivchari:worktree-inspector-iterator

Conversation

@sivchari

@sivchari sivchari commented Jun 1, 2026

Copy link
Copy Markdown
Member

Introduce iterator pattern instead of callbacks. It's faster and safer than current implementation.

Signed-off-by: sivchari <shibuuuu5@gmail.com>
@k8s-ci-robot
k8s-ci-robot requested a review from JoelSpeed June 1, 2026 08:17
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sivchari

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
k8s-ci-robot requested a review from jpbetz June 1, 2026 08:17
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 1, 2026

@JoelSpeed JoelSpeed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just one question about whether we actually still need that panic recovery at all now

Comment on lines 200 to 206
defer func() {
if r := recover(); r != nil {
// If the inspectField function panics, we recover and log information that will help identify the issue.
// If the consumer panics, we recover and log information that will help identify the issue.
debug := printDebugInfo(field)
panic(fmt.Sprintf("%s %v", debug, r)) // Re-panic to propagate the error.
}
}()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not convinced we will need this recovery now, since the panic is not handled in a closure we call, will this actually do anything?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Verified this still works correctly, since yield() is called synchronously within this function's stack frame, the deferred recover() catches panics from the loop body just like before.

@sivchari

sivchari commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Hi @JoelSpeed
PTAL 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants