Skip to content

[JetBrains] Improve ports listener leaking #20872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Jun 3, 2025

Description

Related Issue(s)

Fixes #

How to test

Integration tests

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=jetbrains
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@mustard-mh mustard-mh changed the title WIP: [JetBrains] Improve ports listener leaking [JetBrains] Improve ports listener leaking Jun 16, 2025
@mustard-mh mustard-mh marked this pull request as ready for review June 16, 2025 08:03
@mustard-mh mustard-mh requested review from a team as code owners June 16, 2025 08:03
@mustard-mh mustard-mh requested a review from Copilot June 16, 2025 08:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates how the Rider backend plugin image is pinned, integrates Rider into the preview patch script, refactors the port-forwarding service to use a throttled shared flow, and adjusts plugin XMLs to register the forwarding service per channel.

  • Pin Rider’s backend-plugin image to a specific commit in the IDE config map.
  • Extend the preview patch script to handle Rider images.
  • Refactor AbstractGitpodPortForwardingService to use MutableSharedFlow with throttling and introduce a Rider-specific forwarding service.
  • Move service registration out of the main plugin.xml into channel-specific extensions and update the Gradle stable build to exclude the main impl.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
install/installer/pkg/components/ide-service/ide_config_configmap.go Hardcode pinned commit for Rider plugin images
dev/preview/workflow/preview/patch-ide-configmap.js Add Rider image entries and mapping logic
components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml Remove default port-forwarding service registration
components/ide/jetbrains/backend-plugin/src/main/resources-stable/META-INF/extensions.xml Register forwarding service for stable channel
components/ide/jetbrains/backend-plugin/src/main/resources-latest/META-INF/extensions.xml Register forwarding service for latest channel
components/ide/jetbrains/backend-plugin/src/main/resources-rider/META-INF/plugin.xml Register Rider-specific forwarding service
components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/…ServiceImpl.kt Add throttleLatest to main forwarding service implementation
components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/AbstractGitpodPortForwardingService.kt Use MutableSharedFlow with throttling
components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/optional/GitpodRiderPortForwardingService.kt Introduce Rider forwarding service stub
components/ide/jetbrains/backend-plugin/build.gradle-stable.kts Exclude main forwarding service impl on stable Rider builds
Comments suppressed due to low confidence (1)

components/ide/jetbrains/backend-plugin/build.gradle-stable.kts:41

  • Excluding GitpodPortForwardingServiceImpl.kt in the stable build removes the class referenced in extensions.xml and will cause a class-not-found error. You likely meant to exclude the Rider-specific implementation, not the main service impl.
sourceSets["main"].kotlin.exclude("**/GitpodPortForwardingServiceImpl.kt")

Comment on lines +82 to +83
JetBrainsPluginRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, "commit-8cdc2a1a45c66ac9e003a97af8c57fad42d923f6-rider"),
JetBrainsPluginLatestRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, "commit-8cdc2a1a45c66ac9e003a97af8c57fad42d923f6-rider-latest"),
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

[nitpick] This hardcoded commit string acts as a magic value. Consider extracting it into a named constant or configuration property to make future updates clearer.

Suggested change
JetBrainsPluginRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, "commit-8cdc2a1a45c66ac9e003a97af8c57fad42d923f6-rider"),
JetBrainsPluginLatestRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, "commit-8cdc2a1a45c66ac9e003a97af8c57fad42d923f6-rider-latest"),
JetBrainsPluginRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, RiderCommit),
JetBrainsPluginLatestRiderImage: ctx.ImageName(ctx.Config.Repository, ide.JetBrainsBackendPluginImage, RiderLatestCommit),

Copilot uses AI. Check for mistakes.

@@ -43,6 +45,11 @@ for (let ide in json.ideOptions.options) {
json.ideOptions.options[ide].imageLayers = json.ideOptions.options[ide].imageLayers.map(replaceImage2);
}

if (["rider"].includes(ide)) {
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Using an array for a single value is overkill. You can simplify this to if (ide === "rider") for clarity.

Suggested change
if (["rider"].includes(ide)) {
if (ide === "rider") {

Copilot uses AI. Check for mistakes.

@@ -34,8 +37,26 @@ abstract class AbstractGitpodPortForwardingService : GitpodPortForwardingService
private val perClientPortForwardingManager = service<PerClientPortForwardingManager>()
private val ignoredPortsForNotificationService = service<GitpodIgnoredPortsForNotificationService>()
private val lifetime = Lifetime.Eternal.createNested()
private val portStatusFlow = MutableSharedFlow<Status.PortsStatusResponse>()
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

The default MutableSharedFlow has no buffer and will suspend emit until a collector is ready. Consider configuring an extraBufferCapacity or using MutableSharedFlow(replay=0, extraBufferCapacity=N) to avoid potential deadlocks if bursts of events arrive before collection.

Suggested change
private val portStatusFlow = MutableSharedFlow<Status.PortsStatusResponse>()
private val portStatusFlow = MutableSharedFlow<Status.PortsStatusResponse>(replay = 0, extraBufferCapacity = 64)

Copilot uses AI. Check for mistakes.

@mustard-mh mustard-mh marked this pull request as draft June 16, 2025 08:13
@mustard-mh mustard-mh closed this Jun 17, 2025
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