Skip to content

Conversation

@KevinGruber2001
Copy link

@KevinGruber2001 KevinGruber2001 commented Nov 16, 2025

In this PR a feature flag is added to the Theia Cloud Operator, to mount a gradle configureation file into the Thea IDEs to enable them to access the remote cache.

At the moment, no authorization is configured. Which means that the Remote Gradle Cache needs to allow anonymouse access

Summary by CodeRabbit

  • New Features
    • Added caching support with new configurable command-line options to enable cache functionality and specify a remote cache URL for cloud operator deployments.
    • Introduced environment variables for managing cache settings, enabling fine-grained control over cache enablement status, remote cache URL configuration, and cache push operations across deployed instances.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

The changes add caching configuration support to the Theia Cloud operator. Two new command-line arguments (enableCaching and cacheUrl) are introduced alongside corresponding getters, hashCode/equals updates, and environment variable placeholders that conditionally populate deployment templates based on caching settings.

Changes

Cohort / File(s) Summary
Operator Configuration
java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/TheiaCloudOperatorArguments.java
Added two new fields (enableCaching as boolean defaulting to false, cacheUrl as String) with public accessor methods isEnableCaching() and getCacheUrl(). Updated hashCode(), equals(), and toString() methods to include both new fields.
Dependency Import
java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/AddedHandlerUtil.java
Added import statement for TheiaCloudOperatorArguments class.
Template Replacement Logic
java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/replacements/DefaultDeploymentTemplateReplacements.java
Introduced three new public placeholder constants: PLACEHOLDER_ENV_CACHE_ENABLED, PLACEHOLDER_ENV_CACHE_URL, and PLACEHOLDER_ENV_CACHE_PUSH. Added conditional logic to environment variable generation methods to populate cache-related variables based on caching configuration.
Kubernetes Deployment Templates
java/operator/org.eclipse.theia.cloud.operator/src/main/resources/templateDeployment.yaml, java/operator/org.eclipse.theia.cloud.operator/src/main/resources/templateDeploymentWithoutOAuthProxy.yaml
Added three new environment variables (REMOTE_CACHE_ENABLED, REMOTE_CACHE_URL, REMOTE_CACHE_PUSH) to container specifications, each mapped to corresponding placeholder values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A cache arrives with whisper-light bounds,
New arguments hop through operator ground,
Environment variables bloom in their place,
Templates embrace the caching embrace,
Configuration flows, smooth as can be! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a feature flag to enable shared caching in the Theia Cloud Operator.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@KevinGruber2001 KevinGruber2001 moved this from Milestone 1 to In Progress in Scalable Cloud Tools Project Jan 17, 2026
@KevinGruber2001 KevinGruber2001 marked this pull request as ready for review January 17, 2026 20:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/AddedHandlerUtil.java`:
- Around line 57-61: Remove the unused imports in AddedHandlerUtil: delete the
import lines for ConfigMapVolumeSource, ObjectMeta, OwnerReference, Volume, and
VolumeMount since they are not referenced anywhere in the AddedHandlerUtil
class; update the import block accordingly so only used classes remain and run a
quick compile or IDE organize-imports to ensure no other unused imports remain.

In
`@java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/session/EagerSessionHandler.java`:
- Around line 165-175: The comment and warning in EagerSessionHandler around the
try block misleadingly state that a per-session gradle.properties/init config is
created and mounted, but AddedHandlerUtil.configureGradleCaching only injects
environment variables; update the comment and the LOGGER.warn message to
accurately state that configureGradleCaching injects env vars into the
deployment (refer to AddedHandlerUtil.configureGradleCaching and
deploymentName), or if mounting gradle.properties was intended implement the
mount logic instead of calling configureGradleCaching; adjust the text in the
try-block comment and the formatLogMessage call so logs reflect the actual
behavior.
🧹 Nitpick comments (3)
java/operator/.idea/workspace.xml (1)

1-24: IDE configuration file should not be committed.

The .idea/workspace.xml file contains user-specific and machine-specific IntelliJ IDEA settings that should not be tracked in version control. These files can cause merge conflicts and clutter the repository.

♻️ Recommended fix
  1. Remove this file from the PR:

    git rm --cached java/operator/.idea/workspace.xml
  2. Ensure .idea/workspace.xml is in your .gitignore:

    +**/workspace.xml

Note: Project-level .idea files (like codeStyles, runConfigurations) can be shared, but workspace.xml contains user-specific settings and should always be excluded.

java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/TheiaCloudOperatorArguments.java (1)

125-131: Consider defaulting enableCaching to false for safer rollout.

Enabling caching by default (enableCaching = true) changes behavior for all existing deployments upon upgrade. This could cause unexpected issues if the cache service isn't deployed. A safer approach would be to default to false and require explicit opt-in.

Additionally, the default cacheUrl uses HTTP. While this may be acceptable for internal cluster communication, the PR description mentions "switching the default cache URL to use TLS." If HTTPS is intended, update the default accordingly.

Suggested changes
 `@Option`(names = {
         "--enableCaching" }, description = "Whether to enable caching of Theia application containers.", required = false)
-private boolean enableCaching = true;
+private boolean enableCaching = false;

 `@Option`(names = {
-        "--cacheUrl" }, description = "The URL of the remote cache server.", required = false, defaultValue = "http://theia-cloud-combined-cache:8080/cache/")
+        "--cacheUrl" }, description = "The URL of the remote cache server.", required = false, defaultValue = "https://theia-cloud-combined-cache:8080/cache/")
 private String cacheUrl;
java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/AddedHandlerUtil.java (1)

260-317: Implementation looks correct, with a few considerations.

The method properly configures Gradle caching environment variables. A few observations:

  1. Duplicate env vars risk: If this method is called multiple times on the same deployment (e.g., during retries), it will add duplicate environment variables. Consider checking for existing env vars before adding or clearing them first.

  2. Hardcoded push permission: GRADLE_REMOTE_CACHE_PUSH is hardcoded to "true". The comment at line 306 acknowledges this could be made configurable. For a read-only cache scenario, this would need to be false.

Optional: Prevent duplicate env vars
+    private static void setOrReplaceEnvVar(Container container, String name, String value) {
+        container.getEnv().removeIf(env -> name.equals(env.getName()));
+        EnvVar envVar = new EnvVar();
+        envVar.setName(name);
+        envVar.setValue(value);
+        container.getEnv().add(envVar);
+    }
+
     public static void configureGradleCaching(String correlationId, Deployment deployment,
                                               AppDefinition appDefinition,
                                               TheiaCloudOperatorArguments arguments) {
         // ... existing code to find container and init env list ...

-        // Always set the ENABLED variable for explicit control
-        EnvVar cacheEnabledEnv = new EnvVar();
-        cacheEnabledEnv.setName("GRADLE_REMOTE_CACHE_ENABLED");
-        cacheEnabledEnv.setValue(String.valueOf(cachingEnabled));
-        container.getEnv().add(cacheEnabledEnv);
+        setOrReplaceEnvVar(container, "GRADLE_REMOTE_CACHE_ENABLED", String.valueOf(cachingEnabled));

         if (cachingEnabled) {
-            // Set cache URL
-            EnvVar cacheUrlEnv = new EnvVar();
-            cacheUrlEnv.setName("GRADLE_REMOTE_CACHE_URL");
-            cacheUrlEnv.setValue(arguments.getCacheUrl().trim());
-            container.getEnv().add(cacheUrlEnv);
-
-            // Set push permission (default: true, could be made configurable)
-            EnvVar cachePushEnv = new EnvVar();
-            cachePushEnv.setName("GRADLE_REMOTE_CACHE_PUSH");
-            cachePushEnv.setValue("true");
-            container.getEnv().add(cachePushEnv);
+            setOrReplaceEnvVar(container, "GRADLE_REMOTE_CACHE_URL", arguments.getCacheUrl().trim());
+            setOrReplaceEnvVar(container, "GRADLE_REMOTE_CACHE_PUSH", "true");
             // ...
         }
     }

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/AddedHandlerUtil.java`:
- Around line 253-295: The configureRemoteCaching method currently always
appends REMOTE_CACHE_* EnvVar entries causing duplicates and leaving stale
REMOTE_CACHE_URL/REMOTE_CACHE_PUSH when caching is turned off; update
configureRemoteCaching to upsert env vars by name in the container's env list
(use findContainerIdxInDeployment to locate the container and container.getEnv()
to operate on the list), i.e. if an EnvVar with name
"REMOTE_CACHE_ENABLED"/"REMOTE_CACHE_URL"/"REMOTE_CACHE_PUSH" exists update its
value, otherwise add it; when cachingEnabled is false ensure you remove any
existing "REMOTE_CACHE_URL" and "REMOTE_CACHE_PUSH" entries (and only
set/override "REMOTE_CACHE_ENABLED" to "false"), avoiding duplicate entries on
redeploys.
🧹 Nitpick comments (1)
java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/session/LazySessionHandler.java (1)

472-476: Fix indentation to match the surrounding lambda body.

The new code has inconsistent indentation compared to the rest of the lambda body (lines 459-470 and 478-481). This should be aligned to match the existing code style within the lambda.

Additionally, the comment on line 475 is slightly misleading—configureRemoteCaching is called unconditionally and always sets REMOTE_CACHE_ENABLED (to either "true" or "false"). Consider rewording to clarify that configuration is always applied:

Suggested fix for indentation and comment
-            AddedHandlerUtil.addCustomEnvVarsToDeploymentFromSession(correlationId, deployment, session,
-                appDefinition);
-
-            // If caching is enabled, configure remote build cache via environment variables
-            AddedHandlerUtil.configureRemoteCaching(correlationId, deployment, appDefinition, arguments);
+                    AddedHandlerUtil.addCustomEnvVarsToDeploymentFromSession(correlationId, deployment, session,
+                            appDefinition);
+
+                    // Configure remote build cache environment variables (enabled/disabled based on arguments)
+                    AddedHandlerUtil.configureRemoteCaching(correlationId, deployment, appDefinition, arguments);

Copy link

@lukaskratzel lukaskratzel left a comment

Choose a reason for hiding this comment

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

I think you could handle this in a simpler way by setting the environment variables directly in the deployment template, which I have done so far for all my changes touching on environment variables. You can find the relevant template file here: java/operator/org.eclipse.theia.cloud.operator/src/main/resources/templateDeployment.yaml

The replacements for the templates are handled through this file: java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/util/TheiaCloudHandlerUtil.java.

But if that doesn't work for you we can also try this approach.

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Integrate Shared Cache Node into Theia Cloud

3 participants