Skip to content

fix: update Storj deployment and add stop_timeout support#25

Merged
GeiserX merged 2 commits intomainfrom
fix/storj-deployment
Apr 18, 2026
Merged

fix: update Storj deployment and add stop_timeout support#25
GeiserX merged 2 commits intomainfrom
fix/storj-deployment

Conversation

@GeiserX
Copy link
Copy Markdown
Owner

@GeiserX GeiserX commented Apr 18, 2026

Summary

  • Fix Storj image name: storjlabs/storagenode (was incorrectly storj/storagenode)
  • Add stop_timeout schema field: services can now specify graceful shutdown time; orchestrator passes it to containers.run() and respects it on stop/restart
  • Storj YAML: added stop_timeout: 300, one-time setup: instructions, updated notes about image name and identity generation
  • Storj collector: improved error message when API unreachable — suggests using node's LAN IP instead of localhost when running in Docker

Test plan

  • Deploy a service with stop_timeout set → verify Docker container has correct stop timeout
  • Stop/restart Storj → confirm 300s timeout instead of default 30s
  • Storj collector with unreachable API → verify improved error message includes LAN IP hint
  • Services without stop_timeout → confirm default 30s behavior unchanged

Closes #24

Summary by CodeRabbit

  • New Features

    • Added configurable Docker container stop timeout support for services.
    • Service deployment now includes one-time setup instructions.
  • Bug Fixes

    • Improved error messages for Docker connectivity issues, recommending LAN IP configuration for local deployments.
    • Updated Storj service Docker image reference.
  • Documentation

    • Enhanced deployment guidance with clearer setup instructions.

- Fix Storj image name (storjlabs/storagenode, not storj/storagenode)
- Add stop_timeout field to service schema and orchestrator
- Respect per-service stop_timeout on stop/restart (Storj needs 300s)
- Add one-time setup instructions to Storj YAML
- Improve Storj collector error message with LAN IP hint

Closes #24
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 18 seconds.

⌛ 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 669c6975-4837-4ab9-aee0-6a729d51b9fb

📥 Commits

Reviewing files that changed from the base of the PR and between c35bb82 and 865bb8b.

📒 Files selected for processing (2)
  • app/orchestrator.py
  • services/storage/storj.yml
📝 Walkthrough

Walkthrough

Updates Storj deployment to use storjlabs/storagenode image and adds a required one-time setup step. Introduces configurable Docker container stop_timeout in orchestrator with dynamic timeout lookups for stop/restart operations. Improves error messaging to display actual API URLs and recommends using LAN IPs instead of localhost.

Changes

Cohort / File(s) Summary
Storj Service Updates
app/collectors/storj.py, services/storage/storj.yml
Updated Docker image reference to storjlabs/storagenode, added one-time setup command for identity and storage directory binding, improved error message to interpolate actual API URL, and guidance recommending LAN IP over localhost for collector access.
Container Lifecycle Management
app/orchestrator.py, services/_schema.yml
Added configurable stop_timeout for Docker containers via new _get_stop_timeout() function; refactored deploy_service() to build and pass run_kwargs dict; updated stop_service() and restart_service() to use dynamic timeouts instead of hardcoded 30 seconds. Schema expanded to document stop_timeout and setup optional Docker fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: updating Storj deployment and adding stop_timeout support.
Linked Issues check ✅ Passed All coding requirements from issue #24 are met: image updated to storjlabs/storagenode, setup run instructions added, collector error message improved with LAN IP guidance, and stop_timeout support implemented.
Out of Scope Changes check ✅ Passed All changes directly address issue #24 requirements and the PR objectives; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 fix/storj-deployment

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/collectors/storj.py (1)

61-70: ⚠️ Potential issue | 🟡 Minor

Also catch httpx.ConnectTimeout for the same LAN-IP hint.

When a LAN IP is unreachable or blackholed, httpx may raise ConnectTimeout instead of ConnectError, which currently bypasses this helpful error message.

Proposed fix
-        except httpx.ConnectError:
+        except (httpx.ConnectError, httpx.ConnectTimeout):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/collectors/storj.py` around lines 61 - 70, Update the Storj collector's
exception handling so the LAN-IP hint is also shown for timeout cases: in the
try/except block that currently catches httpx.ConnectError (used when calling
the Storj API in the collector code that returns an EarningsResult with
platform/self.platform and api_url), extend the except clause to also catch
httpx.ConnectTimeout (e.g. change the except to handle both httpx.ConnectError
and httpx.ConnectTimeout) so both connection failures and connect timeouts
produce the same helpful LAN-IP error message.
app/orchestrator.py (1)

140-144: ⚠️ Potential issue | 🟠 Major

Use graceful shutdown when replacing an existing container.

The redeploy code at lines 140-144 force-removes the old container, bypassing the _get_stop_timeout() helper already used in stop_service(). This skips graceful shutdown and can corrupt Storj data. The same issue exists at line 261 in deploy_raw().

Proposed fix
    # Remove any existing container with the same name
    try:
        old = client.containers.get(name)
        logger.info("Removing existing container %s", name)
+       old.stop(timeout=_get_stop_timeout(slug))
-       old.remove(force=True)
+       old.remove()
    except NotFound:
        pass

Apply the same fix to line 261 in deploy_raw() and consider adding graceful stop to remove_service() at line 328 as well.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/orchestrator.py` around lines 140 - 144, Replace the force-remove of an
existing container (currently using client.containers.get(...) then
old.remove(force=True)) with a graceful stop followed by a normal removal: call
old.stop(timeout=_get_stop_timeout(...)) (matching how stop_service() computes
timeout), then call old.remove() without force so Docker can cleanly shut down;
apply the same change in deploy_raw() where old.remove(force=True) is used and
also add a graceful stop before removal in remove_service() so all three code
paths use _get_stop_timeout() and avoid force removal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/orchestrator.py`:
- Around line 227-228: Validate stop_timeout before casting by ensuring the
value is a positive integer and falling back to the default 30 on invalid input;
replace direct int(stop_timeout) usage with a small validation block that tries
to coerce to int inside a try/except (catch ValueError/TypeError), verifies the
resulting int is >= 0, and only then assigns run_kwargs["stop_timeout"] =
parsed_value, otherwise leave run_kwargs unset or explicitly set it to 30; apply
the same change for every place in orchestrator.py where stop_timeout is cast
(the occurrences around the current if stop_timeout block and the similar logic
at the 302-308 region) so deploy/stop/restart use the safe fallback.

In `@services/storage/storj.yml`:
- Around line 60-65: The documented one-time setup under the setup block drops
the Docker user flag and can create root-owned bind-mounted identity/config
files; update the docker run invocation in the setup description to include
--user $(id -u):$(id -g) so the container creates files with the calling host
user's UID:GID (preserve host ownership for the identity and storage mounts
referenced in the setup block).

---

Outside diff comments:
In `@app/collectors/storj.py`:
- Around line 61-70: Update the Storj collector's exception handling so the
LAN-IP hint is also shown for timeout cases: in the try/except block that
currently catches httpx.ConnectError (used when calling the Storj API in the
collector code that returns an EarningsResult with platform/self.platform and
api_url), extend the except clause to also catch httpx.ConnectTimeout (e.g.
change the except to handle both httpx.ConnectError and httpx.ConnectTimeout) so
both connection failures and connect timeouts produce the same helpful LAN-IP
error message.

In `@app/orchestrator.py`:
- Around line 140-144: Replace the force-remove of an existing container
(currently using client.containers.get(...) then old.remove(force=True)) with a
graceful stop followed by a normal removal: call
old.stop(timeout=_get_stop_timeout(...)) (matching how stop_service() computes
timeout), then call old.remove() without force so Docker can cleanly shut down;
apply the same change in deploy_raw() where old.remove(force=True) is used and
also add a graceful stop before removal in remove_service() so all three code
paths use _get_stop_timeout() and avoid force removal.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59a1231f-14f7-4f9d-b26e-dcf550ab5731

📥 Commits

Reviewing files that changed from the base of the PR and between b2e0663 and c35bb82.

📒 Files selected for processing (4)
  • app/collectors/storj.py
  • app/orchestrator.py
  • services/_schema.yml
  • services/storage/storj.yml

Comment thread app/orchestrator.py Outdated
Comment thread services/storage/storj.yml
Address CodeRabbit review:
- Add _parse_stop_timeout() to safely handle malformed values
- Add --user $(id -u):$(id -g) to Storj setup command to preserve host ownership
@GeiserX GeiserX merged commit 5d53de5 into main Apr 18, 2026
4 of 5 checks passed
@GeiserX GeiserX mentioned this pull request Apr 18, 2026
2 tasks
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.

[Bug]: Storj deploy outdated

1 participant