Skip to content

🐛 Fixes Respect Keyboard interrupt kantra#776#1133

Draft
jwmatthews wants to merge 2 commits into
konveyor:mainfrom
jwmatthews:ctrl_c_lockup_kantra_issue_776
Draft

🐛 Fixes Respect Keyboard interrupt kantra#776#1133
jwmatthews wants to merge 2 commits into
konveyor:mainfrom
jwmatthews:ctrl_c_lockup_kantra_issue_776

Conversation

@jwmatthews

@jwmatthews jwmatthews commented Mar 25, 2026

Copy link
Copy Markdown
Member

See: konveyor/kantra#776

analyzer-lsp fixes:

  • Buffer engine response channel so workers don't block after handler exits
  • Guard rule dispatch loop with ctx.Done() to prevent deadlock on full channel
  • Buffer ProviderStart abConfigChan and add ctx.Done() to init wait select
  • Add 5s timeout to gRPC provider Stop() (was context.TODO() with no timeout)
  • Thread context through GetProviderClient/NewGRPCClient for signal-aware startup
  • Rewrite checkServicesRunning to accept context and fix broken 30s timeout

Related to konveyor/kantra#777

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

See: konveyor/kantra#776

Signed-off-by: John Matthews <jwmatthews@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3d2abb7d-9830-4470-bed4-f124a9c6cd98

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

…ffered channel

 Replace buffered abConfigChan with unbuffered channel and wrap the send
 in a select with providerInitCtx.Done() so sender goroutines exit cleanly
 on cancellation. Move waitGroup.Done() from receiver to sender to ensure
 it always runs. More idiomatic Go approach to the ctrl-c deadlock fix.

Signed-off-by: John Matthews <jwmatthews@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@shawn-hurley shawn-hurley 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.

This is really good and helpful. This has been a nagging issue that I think should be solved.

Thank you!

Comment thread core/analyzer.go
select {
case <-c:
a.log.V(3).Info("started all non builtin providers")
case <-a.ctx.Done():

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.

We should add timeout to the providerInitCtx, and then update this to use the providerInitCtx.

It should be built off to a.ctx so that if a.ctx is done, it will provide providerInitCtx, and providerInitCtx timeout is a part of the context. Then we can remove the if/else and just have a single select on c or providerInitCtx.Done().

Let me know if that makese sense or not?

Comment thread core/analyzer.go
Total: len(a.providers),
})
abConfigChan <- additionalBuiltins
select {

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.

This is fixing a channel drain on when context is done.

But the fix I don't think is achieving the same result, we are now marking the wait group finished when additional builtins are passed to the channel, not when the the go routine that adds the additonal builtins to the slice is completed.

If the channel has a buffer of 1. there will still be a lag between updating the slice and the WaitGroup.Wait() finishing, and this I think could cause a race condition.

the waitGroup.Done() I think needs to be called original location, we just need to add on cancel to all call waitGroup.Done().

For draining the waitGroup, there could be at most 1 other object in the buffer.

But, I think that the fix below, around adding context to if noTimeout, actually fully solves the issue that you are trying to solve, without having to worry about this.

Comment thread engine/engine.go
rule.scope = scopes
rule.carrier = carrier
r.ruleProcessing <- rule
select {

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.

a couple of things:

  1. I think I would be hard-pressed to agree on using the goTo here.
  2. Why add a buffer to the return channel?

To add support for canceling w/ the working group, we should follow a similar pattern in analyzer.go where we have the wait in a go routine, and when we finish, we close a sentinel channel, with a select that selects on ctx.Done() or the close of the channel.

Comment thread provider/lib/lib.go

// We need some wrapper that can deal with out of tree providers, this will be a call, that will mock it out, but go against in tree.
func GetProviderClient(config provider.Config, log logr.Logger, progress *progress.Progress) (provider.InternalProviderClient, error) {
func GetProviderClient(ctx context.Context, config provider.Config, log logr.Logger, progress *progress.Progress) (provider.InternalProviderClient, 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 don't know if we need to do this or if we want to do this,

But this will break consumers of the lib package.

Can we add a GetProviderClientWithContext function and update this function to call it with the context set to background?

What are your thoughts?

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days.
It will remain open for visibility and reporting purposes.
Please comment if this PR is still relevant.

@github-actions github-actions Bot added the stale label May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants