Skip to content

fix: harden DevWorkspace watch lifecycle and IDE status check (CRW-12992) - #377

Merged
adietish merged 2 commits into
redhat-developer:mainfrom
adietish:crw-12992
Oct 5, 2026
Merged

adietish merged 2 commits into
redhat-developer:mainfrom
adietish:crw-12992

Conversation

@adietish

@adietish adietish commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: acabc3d1-9abb-4c04-8dd2-ffaa45b7cb6f


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

@codecov-commenter

codecov-commenter commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.53374% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.80%. Comparing base (71098f6) to head (0a3d968).
⚠️ Report is 436 commits behind head on main.

Files with missing lines Patch % Lines
.../gateway/view/steps/DevSpacesWorkspacesStepView.kt 0.00% 52 Missing ⚠️
...ateway/view/steps/workspaces/DevWorkspacesTable.kt 0.00% 14 Missing ⚠️
...ateway/devworkspace/WorkspaceEditorInfoProvider.kt 85.48% 3 Missing and 6 partials ⚠️
...s/gateway/devworkspace/DevWorkspaceWatchManager.kt 85.18% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main     #377       +/-   ##
==========================================
+ Coverage   0.00%   39.80%   +39.80%     
==========================================
  Files          4      123      +119     
  Lines         26     5363     +5337     
  Branches       0     1032     +1032     
==========================================
+ Hits           0     2135     +2135     
- Misses        26     2943     +2917     
- Partials       0      285      +285     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adietish
adietish force-pushed the crw-12992 branch 2 times, most recently from dd914eb to 2df7936 Compare September 11, 2026 00:32
@adietish
adietish marked this pull request as ready for review September 11, 2026 08:45
@adietish
adietish force-pushed the crw-12992 branch 6 times, most recently from f2236e8 to b09a81d Compare September 11, 2026 23:36
@adietish adietish self-assigned this Sep 14, 2026
@vrubezhny

Copy link
Copy Markdown
Collaborator

I don't spot any problems with this PR. The only effect of non-JB Editor-based WSs not being watched: the status icon for such WSs doesn't get updated automatically (users always need to click Refresh to see actual states).
As result, Stat and Stop buttons may work unpredictably as their handlers don't check the current DevWorkspace spec.started value and once clicked patch it with no any precautions . This is probably a subject to be fixed (we either need to refresh the selected DevWorkspace object before executing Start/Stop or warn user and ask to Refresh before clicking these.)

Probably the same could happen to the "Unknown"/"Not-detected"-like WSs (we've added the possibility to be started to). Also in this case the Connect button's handler may try connecting to a WS that isn't really running while it has to.

For the WSs detected clearly as JBs Editor based ones everything works perfectly. During my ~2hrs testing session, with the total started thread count (shown by jconsole <PID>) >1000, the maximum running thread number has never exceeded 132, in "idle" state the number of running threads was heading to ~50, while rising to 75-85 threads when performing some actions, like start/stop WS, refreshing, connecting (including up to the WS project appearance in thinClient, stopping it together with the WS or letting the WS to continue running). The same patterns were repeating during the session so no anything like "constant growth of the running threads number" has been found.

@vrubezhny

vrubezhny commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Not sure if this is anything related to the PR, but I spotted the WS status icons flickering. No actions taken, no WSs changed from outside (I'm not 100% sure about this, but at least I haven't performed any changed in WebDashboard while recording it), no thread counters changing, so it's the same WS-monitor's thread issue:

output-looped-5-times.mp4

This screencast video is looped 5 times, but the effect gets repeating once in a few minutes with no any action actually taken while, I suppose, any WS that failed shouldn't change its state until explicitly altered.

PS: Buttons are actually flickering too - the effect is clearly seen to me when a Running WS is selected:

output-flickering-buttons-looped-5-times.mp4

@adietish

Copy link
Copy Markdown
Collaborator Author

@vrubezhny the "flickering" that you see is not related to this PR. If you think that this PR is otherwise OK, please +1 it.

This "flickering" is related to the tabular listing of the workspaces that shows editors for workspaces. The workspace editors are fetched in a background thread #359 and the editor column updated. Maybe there's a glitch where update would not have to be updated. I cannot clearly see it in the videos. If you think that this is a bug and should be enhanced, we should file a new bug.

@adietish

Copy link
Copy Markdown
Collaborator Author

@vrubezhny I guess that we should either disable start/stop for non-jetbrains workspaces or watch these for status updates, too. What you report is definitely inconsistent behaviour.

@adietish adietish changed the title fix(workspaces): watch JetBrains namespaces only and pause on connect (CRW-12992) fix(workspaces): CRW-12992 watchers + harden Java port-forward Sep 24, 2026
@adietish
adietish force-pushed the crw-12992 branch 2 times, most recently from 606afad to 44ed6ca Compare September 24, 2026 15:23
@adietish

adietish commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

@vrubezhny I am now back to watching all workspaces. Only watching jetbrains workspaces may reduce the number of threads but introduces inconsistencies. Not worth it.

This PR now has the following fixes:

  • DevWorkspaceWatch.stop() now closes the current watch, which unblocks the stuck IO thread immediately instead of waiting for the OkHttp read timeout — previously stopped watches leaked their blocking threads.
  • DevWorkspaceWatchManager.start() now stops all watches first, so repeated refreshes no longer accumulate duplicate watchers per namespace — the main growth driver of pool exhaustion.

Please re-review, thanks!

@adietish adietish changed the title fix(workspaces): CRW-12992 watchers + harden Java port-forward fix: harden watch lifecycle and JetBrains filtering (CRW-12992) Sep 24, 2026
@adietish
adietish force-pushed the crw-12992 branch 4 times, most recently from 6b98a16 to c53fee8 Compare September 28, 2026 12:30
@adietish
adietish force-pushed the crw-12992 branch 7 times, most recently from ee2ac42 to 6844db0 Compare September 28, 2026 19:31
@adietish

Copy link
Copy Markdown
Collaborator Author

@vrubezhny, @azatsarynnyy please review

@adietish adietish changed the title fix: harden watch lifecycle and JetBrains filtering (CRW-12992) fix: harden DevWorkspace watch lifecycle and IDE status check (CRW-12992) Sep 29, 2026
@adietish
adietish force-pushed the crw-12992 branch 2 times, most recently from 48e2b75 to 6a3563f Compare September 30, 2026 03:34
adietish and others added 2 commits September 30, 2026 10:51
…992)

* Close the active K8s Watch on stop to unblock IO threads immediately
* make watch manager start idempotent, and share the coroutine scope with the workspaces table controller.
* add JetBrains workspace detection helpers (editor template annotation resolution, idea-server component check, family classification) with unit tests.
* Stop the DevWorkspace watches while the IDE status check and connection run to free Dispatchers.IO for pod exec,
  and restart them from the cached resource versions in finally blocks.
* Register per-namespace watches based on the watch decision so any non-empty namespace with a known resource version
  is watched, keeping VS Code rows live.
* Rename WorkspacesWatch to DevWorkspaceTableController.

Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Track elapsed wait time via System.nanoTime() so logs reflect actual
probe and refresh duration, not just summed backoff delays.

Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@adietish

Copy link
Copy Markdown
Collaborator Author

@vrubezhny: I filed the flickering issue to https://redhat.atlassian.net/browse/CRW-13522

@vrubezhny vrubezhny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, Thanks!

@adietish
adietish merged commit 64b6f65 into redhat-developer:main Oct 5, 2026
7 checks passed
@adietish
adietish deleted the crw-12992 branch October 5, 2026 21:50
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.

3 participants