Skip to content

fix: send SIGHUP to MCP container after initial deploy#378

Merged
tsivaprasad merged 2 commits into
mainfrom
PLAT-588-mcp-server-starts-without-embedding-config-on-initial-provisioning
May 5, 2026
Merged

fix: send SIGHUP to MCP container after initial deploy#378
tsivaprasad merged 2 commits into
mainfrom
PLAT-588-mcp-server-starts-without-embedding-config-on-initial-provisioning

Conversation

@tsivaprasad
Copy link
Copy Markdown
Contributor

@tsivaprasad tsivaprasad commented May 5, 2026

Summary

This PR ensures that once the MCP container is confirmed running during initial provisioning, a SIGHUP signal is sent to trigger a config reload.

Changes

  • service_instance.go — call spec.PostDeploy() after WaitForService()
  • service_instance_spec.go — add PostDeploy() with a service-type switch
  • mcp_config_resource.go — add public PostDeploy() that calls the existing signalConfigReload()

Testing

Verification:

  • Created DB and MCP service using below config
curl -s -X POST http://localhost:3000/v1/databases \
  -H "Content-Type: application/json" -d '{
  "id": "test-mcp-embed",
  "spec": {
    "database_name": "test_mcp_embed",
    "database_users": [
      {
        "username": "admin",
        "password": "password",
        "db_owner": true,
        "attributes": ["LOGIN", "SUPERUSER"]
      }
    ],
    "port": 0,
    "nodes": [
      { "name": "n1", "host_ids": ["host-1"] }
    ],
    "services": [
      {
        "service_id": "mcp-server",
        "service_type": "mcp",
        "version": "latest",
        "host_ids": ["host-1"],
        "port": 0,
        "connect_as": "admin",
        "config": {
          "embedding_provider": "openai",
          "embedding_model": "text-embedding-3-small",
          "embedding_api_key": "sk-proj-1"
        }
      }
    ]
  }
}'

  • Confirmed from config.yaml that embedding.enabled: true (Enabled)
embedding:
  enabled: true
  provider: openai
  model: text-embedding-3-small

From logs confirmed that config reloaded:

Database configured: admin@:0/test_mcp_embed (per-session connections)
Received SIGHUP, reloading configuration...
Updated database configurations: 1 database(s)
Configuration reloaded successfully from /app/data/config.yaml

Checklist

  • Tests no change and no existing tests failure

PLAT-588

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Warning

Rate limit exceeded

@tsivaprasad has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 54 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53978953-17f9-4923-8917-c2030f433d12

📥 Commits

Reviewing files that changed from the base of the PR and between 2f9be52 and 44c8871.

📒 Files selected for processing (2)
  • server/internal/orchestrator/swarm/mcp_config_resource.go
  • server/internal/orchestrator/swarm/service_instance_spec.go
📝 Walkthrough

Walkthrough

Added a post-deployment hook mechanism that allows service resources to execute custom logic after their containers are confirmed running. The MCP service uses this hook to trigger a best-effort configuration reload via SIGHUP after deployment completes.

Changes

Post-Deployment Hook System

Layer / File(s) Summary
Hook Interface
server/internal/orchestrator/swarm/service_instance_spec.go
ServiceInstanceSpecResource.PostDeploy method defines the post-deployment hook, dispatching to service-type-specific implementations (currently MCP).
MCP Implementation
server/internal/orchestrator/swarm/mcp_config_resource.go
MCPConfigResource.PostDeploy invokes signalConfigReload as a best-effort operation, discarding errors to prevent deployment failure.
Deployment Integration
server/internal/orchestrator/swarm/service_instance.go
ServiceInstanceResource.deploy calls spec.PostDeploy after the Docker service confirms tasks have started but before setting the instance state to Running in etcd.

Poem

🐰 A hook springs forth, so clever and neat,
When containers wake, their config to greet!
SIGHUP whispers gently through the MCP air,
Best-effort reloads handled with care.
Deployment flows on, no failures to fear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: sending SIGHUP to the MCP container after initial deployment to enable config reload.
Description check ✅ Passed The PR description is well-structured following the template with Summary, Changes, Testing sections, and includes a checked Checklist. However, the Changelog entry requirement from the template checklist was not addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PLAT-588-mcp-server-starts-without-embedding-config-on-initial-provisioning

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.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 5, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/internal/orchestrator/swarm/mcp_config_resource.go`:
- Around line 260-262: In PostDeploy, do not ignore the return from
r.signalConfigReload(ctx, rc); instead check the error and emit a structured
zerolog error log including at least error (err), operation ("PostDeploy" or
"signalConfigReload"), and relevant resource/context identifiers (e.g., rc or
resource name); use the existing logger (e.g., r.logger or rc.Logger) and
include domain error mapping to HTTP codes where appropriate (via Goa) when
handling the error downstream so reload failures are visible in logs and can be
translated to proper status codes.

In `@server/internal/orchestrator/swarm/service_instance_spec.go`:
- Around line 98-100: The current code silently ignores errors from
resource.FromContext; change it to log failures using structured zerolog and
retain the successful path: call resource.FromContext[*MCPConfigResource](rc,
MCPConfigResourceIdentifier(s.ServiceInstanceID)); if err != nil, emit a
structured error log (include fields like "service_instance_id"
s.ServiceInstanceID, "resource" "MCPConfigResource", and the error value) using
the existing zerolog logger available in the request context or rc, and only
call mcpCfg.PostDeploy(ctx, rc) when err == nil; keep the same identifiers
(resource.FromContext, MCPConfigResource, MCPConfigResourceIdentifier,
PostDeploy, mcpCfg) so reviewers can locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f2e8d827-e5f3-41fd-ab8f-50136e4a876d

📥 Commits

Reviewing files that changed from the base of the PR and between ea89e93 and 2f9be52.

📒 Files selected for processing (3)
  • server/internal/orchestrator/swarm/mcp_config_resource.go
  • server/internal/orchestrator/swarm/service_instance.go
  • server/internal/orchestrator/swarm/service_instance_spec.go

Comment thread server/internal/orchestrator/swarm/mcp_config_resource.go
Comment thread server/internal/orchestrator/swarm/service_instance_spec.go Outdated
Copy link
Copy Markdown
Contributor

@rshoemaker rshoemaker left a comment

Choose a reason for hiding this comment

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

LGTM.

One minor comment: cluster update will cause a double SIGHUP on the container ( once in MCPConfigResource.Update() and again in ServiceInstanceResource.deploy() ), while create will only cause a single SIGHUP. The double signal is benign though - not worth changing IMO.

@tsivaprasad
Copy link
Copy Markdown
Contributor Author

tsivaprasad commented May 5, 2026

Will address complete solution as part PLAT-589

@tsivaprasad tsivaprasad merged commit 21f23cb into main May 5, 2026
3 checks passed
@tsivaprasad tsivaprasad deleted the PLAT-588-mcp-server-starts-without-embedding-config-on-initial-provisioning branch May 5, 2026 15:59
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