Skip to content

fix: frontend load global extraENV & setup script #414

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

Merged
merged 7 commits into from
May 28, 2025

Conversation

dacbd
Copy link
Contributor

@dacbd dacbd commented May 28, 2025

Summary by CodeRabbit

  • New Features

    • The frontend now loads environment variables from a Kubernetes secret for enhanced configuration.
    • Added an environment variable to enable the operator in the frontend.
    • Introduced a setup script that dynamically updates frontend environment settings during build time.
  • Chores

    • Updated the Helm chart version for operator-wandb to 0.31.6.

Copy link
Contributor

coderabbitai bot commented May 28, 2025

"""

Walkthrough

The changes update the Helm chart for the operator-wandb application by incrementing its version and modifying the frontend configuration to enable the operator via a new environment variable, load environment variables from a Kubernetes secret, and mount a ConfigMap volume containing a setup script that patches the frontend environment JavaScript file during build.

Changes

File(s) Change Summary
charts/operator-wandb/Chart.yaml Bumped chart version from 0.31.5 to 0.31.6.
charts/operator-wandb/values.yaml Added frontend.env.OPERATOR_ENABLED set to "true", updated frontend.envFrom to reference a Kubernetes secret, and added a volume mounting a ConfigMap with setup scripts.
charts/operator-wandb/templates/frontend.yaml Added a new ConfigMap resource <release-name>-frontend-configmap containing a shell script 02_patch_env_js.sh that dynamically patches the frontend env.js file with environment flags.

Sequence Diagram(s)

sequenceDiagram
    participant Helm as Helm Chart
    participant K8s as Kubernetes
    participant Frontend as Frontend Pod

    Helm->>K8s: Deploy operator-wandb with updated values and ConfigMap volume
    K8s->>Frontend: Create frontend pod with envFrom referencing global secret, OPERATOR_ENABLED=true, and mount setup script volume
    Frontend->>Frontend: Run `02_patch_env_js.sh` to patch env.js with server flags and additional environment variables
Loading

Possibly related PRs

Suggested reviewers

  • jsbroks
  • vanpelt

Poem

🐇 A secret tucked in pods so neat,
Environment variables now complete.
Operator enabled, scripts in place,
Patching env.js with careful grace.
Version bumped, the chart takes flight,
Helm and K8s hopping bright!
🎉🚀🐰
"""


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 05:04 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:25 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
@dacbd dacbd temporarily deployed to Helm Charts May 28, 2025 21:26 — with GitHub Actions Inactive
Copy link
Contributor

@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: 0

♻️ Duplicate comments (2)
charts/operator-wandb/templates/frontend.yaml (2)

5-6: Fix incorrect indentation for Helm label include
The {{- include "wandb.commonLabels" . | nindent 4 }} line is over-indented under labels:, causing YAML syntax errors (wrong indentation and expected <block end>). It should align directly under labels: without extra spaces.

Proposed diff:

   labels:
-      {{- include "wandb.commonLabels" . | nindent 4 }}
+{{- include "wandb.commonLabels" . | nindent 4 }}
🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 6-6: wrong indentation: expected 4 but found 6

(indentation)


31-33: Use parameter expansion to strip the trailing comma in extract_server_flags
The current approach with local length="${#new_js}"-1 and ${new_js:0:length} won’t evaluate the arithmetic as intended. Switch to bash’s ${var%,} expansion for reliable comma removal.

Proposed diff:

-      # remove the trailing comma and close the object
-      local length="${#new_js}"-1
-      printf "${new_js:0:length}};\n" >> "$env_js_path"
+      # remove trailing comma and append closing brace
+      local trimmed="${new_js%,}"
+      printf '%s};\n' "$trimmed" >> "$env_js_path"
🧹 Nitpick comments (2)
charts/operator-wandb/templates/frontend.yaml (2)

8-17: Ensure robust JSON key/value quoting in append_env_js
The function correctly checks writability and appends assignments, but values aren’t quoted in the JS object. If any $value contains special characters, the resulting JS could be invalid.

You might wrap both key and value in quotes:

-      printf "Object.assign(window.CONFIG, {%s: %s});\n" "$key" "$value" >> "$env_js_path"
+      printf 'Object.assign(window.CONFIG, {"%s":"%s"});\n' "$key" "$value" >> "$env_js_path"

37-72: Consistent bash conditional syntax in known_additional_flags
This function mixes single‐bracket [...] and double‐bracket [[...]] tests, as well as = and == operators. For readability and fewer surprises, prefer [[ ... ]] with == throughout.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a43bcc2 and ae623d9.

📒 Files selected for processing (1)
  • charts/operator-wandb/templates/frontend.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/operator-wandb/templates/frontend.yaml

[warning] 6-6: wrong indentation: expected 4 but found 6

(indentation)


[error] 4-4: syntax error: expected , but found ''

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (24)
  • GitHub Check: Test Chart (v1.29.14, weave-trace)
  • GitHub Check: Test Chart (v1.29.14, runs-v2-bufstream)
  • GitHub Check: Test Chart (v1.29.14, separate-pods)
  • GitHub Check: Test Chart (v1.29.14, user-defined-secrets)
  • GitHub Check: Test Chart (v1.29.14, executor-enabled)
  • GitHub Check: Test Chart (v1.29.14, default)
  • GitHub Check: Test Chart (v1.30.10, weave-trace)
  • GitHub Check: Test Chart (v1.30.10, runs-v2-bufstream)
  • GitHub Check: Test Chart (v1.30.10, separate-pods)
  • GitHub Check: Test Chart (v1.30.10, user-defined-secrets)
  • GitHub Check: Test Chart (v1.30.10, executor-enabled)
  • GitHub Check: Test Chart (v1.30.10, default)
  • GitHub Check: Test Chart (v1.31.6, weave-trace)
  • GitHub Check: Test Chart (v1.31.6, runs-v2-bufstream)
  • GitHub Check: Test Chart (v1.31.6, separate-pods)
  • GitHub Check: Test Chart (v1.31.6, user-defined-secrets)
  • GitHub Check: Test Chart (v1.31.6, executor-enabled)
  • GitHub Check: Test Chart (v1.31.6, default)
  • GitHub Check: Test Chart (v1.32.2, weave-trace)
  • GitHub Check: Test Chart (v1.32.2, runs-v2-bufstream)
  • GitHub Check: Test Chart (v1.32.2, separate-pods)
  • GitHub Check: Test Chart (v1.32.2, user-defined-secrets)
  • GitHub Check: Test Chart (v1.32.2, executor-enabled)
  • GitHub Check: Test Chart (v1.32.2, default)
🔇 Additional comments (2)
charts/operator-wandb/templates/frontend.yaml (2)

1-7: Approve ConfigMap scaffold (except label indentation)
The new ConfigMap resource and its metadata fields (apiVersion, kind, name) are correct and align with the requirement to inject a setup script into the frontend build.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 6-6: wrong indentation: expected 4 but found 6

(indentation)


[error] 4-4: syntax error: expected , but found ''

(syntax)


74-83: Approve main execution guard
The main function correctly ensures idempotent patching of env.js by checking for const SERVER_FLAGS =. The overall control flow matches the intended behavior.

@dacbd dacbd changed the title fix: frontend load global extraENV fix: frontend load global extraENV & setup script May 28, 2025
@dacbd dacbd merged commit e57bcec into main May 28, 2025
29 checks passed
@dacbd dacbd deleted the dacbd/frontend-extraEnv branch May 28, 2025 21:39
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.

2 participants