feat: onyx discord bot - supervisord and kube deployment#7706
feat: onyx discord bot - supervisord and kube deployment#7706justin-tahara merged 4 commits intomainfrom
Conversation
Greptile OverviewGreptile SummaryAdded infrastructure configuration for the Discord bot feature across Docker Compose and Kubernetes deployments. The PR adds supervisord configuration to run the Discord bot process, environment variables for bot configuration ( Key Changes:
Critical Issues Found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Discord as Discord Platform
participant Bot as Discord Bot Pod
participant API as API Server
participant Cache as Cache Manager
participant DB as Database
Note over Bot: Deployed via supervisord<br/>(Docker Compose) or<br/>Kubernetes Deployment (Helm)
Bot->>Discord: Connect with DISCORD_BOT_TOKEN
Discord-->>Bot: WebSocket connection established
Bot->>Cache: Initialize cache
Cache->>API: Fetch registered guilds
API->>DB: Query guild configurations
DB-->>API: Return guild data
API-->>Cache: Return guild configurations
Discord->>Bot: User message received
Bot->>Cache: Check if guild registered
alt Guild registered
Bot->>API: POST message via API_SERVER_HOST
Note over Bot,API: Uses API_SERVER_PROTOCOL://API_SERVER_HOST
API->>DB: Process message & store
API-->>Bot: Response
Bot->>Discord: Send response to user
else Guild not registered
Bot->>Discord: Ignore or prompt registration
end
loop Every CACHE_REFRESH_INTERVAL
Bot->>Cache: Refresh guild cache
Cache->>API: Fetch updated configurations
API-->>Cache: Return updated data
end
|
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="deployment/helm/charts/onyx/templates/discordbot.yaml">
<violation number="1" location="deployment/helm/charts/onyx/templates/discordbot.yaml:74">
P2: Avoid rendering duplicate `DISCORD_BOT_TOKEN` env vars when both `botToken` and `botTokenSecretName` are set. Use an `else if` (or mutual-exclusion validation) so only one source is emitted.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
4 issues found across 9 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="deployment/helm/charts/onyx/values.yaml">
<violation number="1" location="deployment/helm/charts/onyx/values.yaml:707">
P1: The Helm values configuration for `discordbot` is incomplete - there's no corresponding deployment template file (`templates/discordbot.yaml`) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See `slackbot.yaml` template as a reference for the expected structure.</violation>
<violation number="2" location="deployment/helm/charts/onyx/values.yaml:1203">
P2: Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via `discordbot.botTokenSecretName`). Keeping `DISCORD_BOT_TOKEN` in the ConfigMap risks leaking the token in plain text.</violation>
</file>
<file name="deployment/docker_compose/docker-compose.multitenant-dev.yml">
<violation number="1" location="deployment/docker_compose/docker-compose.multitenant-dev.yml:227">
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) [FEEDBACK_USED]</violation>
<violation number="2" location="deployment/docker_compose/docker-compose.multitenant-dev.yml:229">
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) [FEEDBACK_USED]</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| # Discord bot for Onyx | ||
| # IMPORTANT: Discord bots cannot be horizontally scaled - only one WebSocket connection per token is allowed. | ||
| # The bot offloads message processing to scalable API pods via HTTP requests. | ||
| discordbot: |
There was a problem hiding this comment.
P1: The Helm values configuration for discordbot is incomplete - there's no corresponding deployment template file (templates/discordbot.yaml) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See slackbot.yaml template as a reference for the expected structure.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/helm/charts/onyx/values.yaml, line 707:
<comment>The Helm values configuration for `discordbot` is incomplete - there's no corresponding deployment template file (`templates/discordbot.yaml`) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See `slackbot.yaml` template as a reference for the expected structure.</comment>
<file context>
@@ -701,6 +701,45 @@ celery_worker_user_file_processing:
+# Discord bot for Onyx
+# IMPORTANT: Discord bots cannot be horizontally scaled - only one WebSocket connection per token is allowed.
+# The bot offloads message processing to scalable API pods via HTTP requests.
+discordbot:
+ enabled: false # Disabled by default - requires bot token configuration
+ # Bot token can be provided directly or via a Kubernetes secret
</file context>
| NOTIFY_SLACKBOT_NO_ANSWER: "" | ||
| # Discord Bot Configs (runs via supervisord, requires DISCORD_BOT_TOKEN to be set) | ||
| # IMPORTANT: Only one Discord bot instance can run per token | ||
| DISCORD_BOT_TOKEN: "" |
There was a problem hiding this comment.
P2: Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via discordbot.botTokenSecretName). Keeping DISCORD_BOT_TOKEN in the ConfigMap risks leaking the token in plain text.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/helm/charts/onyx/values.yaml, line 1203:
<comment>Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via `discordbot.botTokenSecretName`). Keeping `DISCORD_BOT_TOKEN` in the ConfigMap risks leaking the token in plain text.</comment>
<file context>
@@ -1159,6 +1198,10 @@ configMap:
NOTIFY_SLACKBOT_NO_ANSWER: ""
+ # Discord Bot Configs (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
+ # IMPORTANT: Only one Discord bot instance can run per token
+ DISCORD_BOT_TOKEN: ""
+ DISCORD_BOT_INVOKE_CHAR: ""
# Logging
</file context>
| # Discord Bot Configuration (runs via supervisord, requires DISCORD_BOT_TOKEN to be set) | ||
| # IMPORTANT: Only one Discord bot instance can run per token - do not scale background workers | ||
| - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-} | ||
| - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!} |
There was a problem hiding this comment.
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/docker_compose/docker-compose.multitenant-dev.yml, line 227:
<comment>Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) </comment>
<file context>
@@ -221,6 +221,13 @@ services:
+ # Discord Bot Configuration (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
+ # IMPORTANT: Only one Discord bot instance can run per token - do not scale background workers
+ - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
+ - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
+ # API Server connection for Discord bot message processing
+ - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
</file context>
| - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!} | |
| - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-} |
| - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-} | ||
| - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!} | ||
| # API Server connection for Discord bot message processing | ||
| - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http} |
There was a problem hiding this comment.
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/docker_compose/docker-compose.multitenant-dev.yml, line 229:
<comment>Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.
(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) </comment>
<file context>
@@ -221,6 +221,13 @@ services:
+ - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
+ - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
+ # API Server connection for Discord bot message processing
+ - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
+ - API_SERVER_HOST=${API_SERVER_HOST:-api_server}
# Logging
</file context>
| - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http} | |
| - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-} |
Description
Creating all the necessary infra related to the Discord Bot.
How Has This Been Tested?
Additional Options
Summary by cubic
Adds Discord bot support with supervisord and deployment configs for Docker Compose and Kubernetes. Enables a single OnyxBot instance to run in Discord and route message processing to the API server.
New Features
Migration
Written for commit ab807e3. Summary will update on new commits.