Skip to content

[Fix] Wait for cloud-init and apt#1208

Open
RichardAnderson wants to merge 3 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/do-provision-issue
Open

[Fix] Wait for cloud-init and apt#1208
RichardAnderson wants to merge 3 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/do-provision-issue

Conversation

@RichardAnderson

@RichardAnderson RichardAnderson commented Jul 23, 2026

Copy link
Copy Markdown
Member

Wait for cloud-init and apt locks to clear before provisioning starts, so new servers (notably DigitalOcean) no longer fail with "Could not get lock /var/cache/apt/archives/lock".

Closes #1205

New command executed at the start:
image

Server continues past the upgrade process:
image

DO 1CPU/1GB RAM VPS provisions successfully (where it previously failed):
image

Summary by CodeRabbit

  • New Features
    • Server installation now advances to “preparing-system” and then waits for the operating system to complete initial boot readiness.
    • Provisioning now pauses until first-boot prerequisites finish, including:
      • waiting for cloud-init when it’s in the running state, and
      • waiting for package manager lock releases (via fuser).
    • Added timeout-based safeguards for both boot readiness and provisioning checks, with clear error messaging when limits are exceeded.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Installation now marks the system as preparing, waits for cloud-init and package-manager locks through SSH, and then continues server provisioning.

Changes

Server boot readiness

Layer / File(s) Summary
Boot-readiness checks
app/SSH/OS/OS.php, resources/views/ssh/os/wait-for-boot.blade.php
Adds waitForBoot() and a remote script that waits for cloud-init and apt/dpkg locks, with a configurable timeout.
Installation integration
app/Actions/Server/InstallServer.php
Sets installation progress to preparing-system and waits for boot readiness before continuing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InstallServer
  participant OS
  participant RemoteSystem
  InstallServer->>InstallServer: Set progress to preparing-system
  InstallServer->>OS: Call waitForBoot()
  OS->>RemoteSystem: Execute wait-for-boot
  RemoteSystem->>RemoteSystem: Wait for cloud-init and package locks
  RemoteSystem-->>OS: Complete readiness checks
  OS-->>InstallServer: Return
  InstallServer->>InstallServer: Continue installation
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address the reported 15% VPS install failure by waiting for cloud-init and apt locks to clear.
Out of Scope Changes check ✅ Passed All code changes stay focused on provisioning readiness and lock handling, with no obvious unrelated additions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: provisioning now waits for cloud-init and apt locks before continuing.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@resources/views/ssh/os/wait-for-boot.blade.php`:
- Around line 3-5: Update the wait-for-boot readiness flow around cloud-init and
the lock check to fail closed: bound the cloud-init wait, remove suppressed
failures, treat missing or failing fuser checks as errors, and exit non-zero
when readiness cannot be confirmed or the timeout expires. Ensure all
provider/service command errors propagate through SSH::exec() instead of
allowing provisioning to continue.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: a97fd5fb-ec65-443c-b69b-e53baef80399

📥 Commits

Reviewing files that changed from the base of the PR and between a56cf6d and e8d9ce4.

📒 Files selected for processing (3)
  • app/Actions/Server/InstallServer.php
  • app/SSH/OS/OS.php
  • resources/views/ssh/os/wait-for-boot.blade.php

Comment thread resources/views/ssh/os/wait-for-boot.blade.php

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@resources/views/ssh/os/wait-for-boot.blade.php`:
- Around line 4-8: Update the cloud-init wait command in the boot script so its
exit status is captured through an if/else or || control-flow branch that
remains reachable under set -e. Preserve the timeout-specific message and exit 1
for status 124, while explicitly propagating or normalizing all other nonzero
cloud-init failures.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: ed24046e-7f5e-4759-a086-a5c863591f72

📥 Commits

Reviewing files that changed from the base of the PR and between e8d9ce4 and 7012380.

📒 Files selected for processing (1)
  • resources/views/ssh/os/wait-for-boot.blade.php

Comment thread resources/views/ssh/os/wait-for-boot.blade.php Outdated
@saeedvaziry

Copy link
Copy Markdown
Member

@RichardAnderson do we need to apply this to all servers

@RichardAnderson

Copy link
Copy Markdown
Member Author

@RichardAnderson do we need to apply this to all servers

At the moment its only effecting DO servers (confirmed even the larger servers have this, but it's a worthwhile check regardless, and could solve problems should other providers introduce default cloud-init scripts that run apt updates/upgrades automatically.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
resources/views/ssh/os/wait-for-boot.blade.php (1)

4-12: 🩺 Stability & Availability | 🟠 Major

Keep boot readiness fail-closed.

The script can still print “System is ready” after readiness checks fail:

  • Line 4’s pipeline reports awk’s success, so a failed cloud-init status can be treated as an empty state.
  • Line 7 ignores every non-zero exit except 124, including cloud-init failures and a missing timeout binary.
  • The fuser loop treats command errors as “unlocked”, while lines 26–28 merely log when fuser is unavailable.

Reject unknown/error cloud-init states, every failed wait/probe, missing fuser, and fuser execution errors; otherwise provisioning may begin while cloud-init or apt still holds a lock.

As per coding guidelines, provider/service errors must bubble up rather than being silently suppressed.

Also applies to: 18-28

🤖 Prompt for 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.

In `@resources/views/ssh/os/wait-for-boot.blade.php` around lines 4 - 12, Update
the wait-for-boot readiness checks to fail closed: preserve the cloud-init
probe’s command failure status instead of treating an empty state as ready,
reject unknown or failed cloud-init states, and make every non-zero timeout/wait
result—including missing timeout—exit with failure. In the fuser lock-check
loop, treat missing fuser and any fuser execution error as fatal rather than
unlocked, while retaining successful lock detection and waiting behavior.

Source: Coding guidelines

🤖 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.

Duplicate comments:
In `@resources/views/ssh/os/wait-for-boot.blade.php`:
- Around line 4-12: Update the wait-for-boot readiness checks to fail closed:
preserve the cloud-init probe’s command failure status instead of treating an
empty state as ready, reject unknown or failed cloud-init states, and make every
non-zero timeout/wait result—including missing timeout—exit with failure. In the
fuser lock-check loop, treat missing fuser and any fuser execution error as
fatal rather than unlocked, while retaining successful lock detection and
waiting behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0dbf6a86-0f63-4c01-b00a-1792ef278e64

📥 Commits

Reviewing files that changed from the base of the PR and between 7012380 and d469b3a.

📒 Files selected for processing (1)
  • resources/views/ssh/os/wait-for-boot.blade.php

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]: Installation fails at 15% every time

2 participants