syntheses:vps-create-flow
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| syntheses:vps-create-flow [22/07/2026 00:43] – Format VPS create flow to match DokuWiki style guide bkirk | syntheses:vps-create-flow [03/08/2026 23:16] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== VPS Creation / Provisioning Flow ====== | ||
| - | |||
| - | This page traces the source-backed flow for creating a VPS from the customer/ | ||
| - | |||
| - | ===== Scope ===== | ||
| - | |||
| - | * Main repo: '' | ||
| - | * Main application area: '' | ||
| - | * Compute execution: HostDaemon and host command handlers. | ||
| - | * Related repo: '' | ||
| - | |||
| - | ===== Short Version ===== | ||
| - | |||
| - | - The API accepts a create-server request and validates the customer, plan, OS, network, billing state, and requested options. | ||
| - | - Domain services create a '' | ||
| - | - Provisioning services assign the lease, host, network, primary interface/ | ||
| - | - '' | ||
| - | - HostDaemon polls the '' | ||
| - | - On success, HostDaemon sets the guest status to '' | ||
| - | - On failure, HostDaemon attempts cleanup/ | ||
| - | |||
| - | ===== API and Domain Flow ===== | ||
| - | |||
| - | ==== 1. API Request ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * Loads the customer entity, including subscription state and billing history. | ||
| - | * '' | ||
| - | * Blocks creation if the customer lacks verified payment details. | ||
| - | * Signup flow can bypass this by calling with '' | ||
| - | * '' | ||
| - | * Checks purchase eligibility, | ||
| - | * '' | ||
| - | * Resolves facility, plan, operating system, network, and extras into '' | ||
| - | * '' | ||
| - | * Wraps domain guest creation so the main database changes are atomic. | ||
| - | * '' | ||
| - | * Performs the domain-level guest creation described in the next step. | ||
| - | * NHibernate flush | ||
| - | * Forces the guest insert so the API ID exists before the response is returned. | ||
| - | * '' | ||
| - | * Runs after the domain transaction if the command has a blocking invoice that '' | ||
| - | * Attempts immediate payment using customer credit or stored payment details. | ||
| - | * If payment fails, the command still enters the queue and HostDaemon blocks on the unpaid invoice later. | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== 2. Guest/ | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * Blocks customers with overdue invoices. | ||
| - | * Guest limit check | ||
| - | * Compares '' | ||
| - | * Private IP validation | ||
| - | * If a VPC private IP was requested, validates that it belongs to the requested network. | ||
| - | * Split NIC validation | ||
| - | * Requires a private network when '' | ||
| - | * '' | ||
| - | * Creates the in-memory guest entity. | ||
| - | * Sets initial status to '' | ||
| - | * Sets plan/OS placeholders, | ||
| - | * '' | ||
| - | * Runs entity validation before provisioning resources. | ||
| - | * Option application | ||
| - | * Applies port block, IPv6, split NICs, SSH keys, scripts/ | ||
| - | * Referral and fraud-review handling | ||
| - | * Applies referral information where present. | ||
| - | * Marks the customer for review on the 10th server creation path. | ||
| - | * '' | ||
| - | * Allocates lease, host, network, interfaces, backup schedule, and firewall state. | ||
| - | * '' | ||
| - | * Persists the configured guest. | ||
| - | * '' | ||
| - | * Queues the HostDaemon create command. | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== 3. Initial Guest State ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * A unique generated name and customer-facing hostname. | ||
| - | * Rescue password and OS-specific defaults through '' | ||
| - | * '' | ||
| - | * Initial status: | ||
| - | |||
| - | < | ||
| - | guest.SetStatus(GuestStatus.Building); | ||
| - | </ | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== 4. Provisioning Assignments ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | - '' | ||
| - | * Creates lease and lease-term records. | ||
| - | * Creates the invoice that can block command execution. | ||
| - | - '' | ||
| - | * Selects and assigns a compute host in the requested facility. | ||
| - | - '' | ||
| - | * Assigns the guest to the selected network zone. | ||
| - | - '' | ||
| - | * Creates the primary interface. | ||
| - | * Allocates public IPv4 and IPv6 where applicable. | ||
| - | - '' | ||
| - | * Adds VPC or split-NIC interfaces. | ||
| - | - '' | ||
| - | * Sets backup and offsite backup schedule state. | ||
| - | - '' | ||
| - | * Clears or initialises firewall state for a fresh guest. | ||
| - | |||
| - | '' | ||
| - | |||
| - | ===== HostCommand / HostDaemon Flow ===== | ||
| - | |||
| - | ==== 5. CreateGuestCommand Is Queued ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Creates '' | ||
| - | * Attaches build inputs: | ||
| - | * '' | ||
| - | * Password override through '' | ||
| - | * Deployment script and script input. | ||
| - | * SSH key IDs. | ||
| - | * User-data. | ||
| - | * Calls '' | ||
| - | * Persists the command to the '' | ||
| - | * Leaves it not started and not completed until HostDaemon picks it up. | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | - Requesting server resources. | ||
| - | - Allocating virtual disk. | ||
| - | - Installing operating system. | ||
| - | - Starting server. | ||
| - | - Configuring operating system. | ||
| - | - Processing invoice. | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * Its blocking invoice is '' | ||
| - | * HostDaemon will not build prepaid guests until that invoice is paid. | ||
| - | * For postpaid customers, the invoice gate depends on subscription state. | ||
| - | |||
| - | ==== 6. HostDaemon Picks Up The Command ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | - '' | ||
| - | * Opens a database transaction. | ||
| - | * Calls '' | ||
| - | * Calls '' | ||
| - | - '' | ||
| - | * Checks '' | ||
| - | * Checks '' | ||
| - | * Prevents concurrent execution of incompatible commands for the same guest. | ||
| - | - Query-duration guard | ||
| - | * If acquiring a database connection takes too long, the command is skipped for that pass. | ||
| - | * This avoids starving already-running handlers when the pool is contended. | ||
| - | - Worker start | ||
| - | * Starts '' | ||
| - | * Some Windows host paths can run commands in a separate process. | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== 7. HostDaemon Creates The Guest ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | - Step 0: Invoice gate | ||
| - | * Calls '' | ||
| - | * Checks '' | ||
| - | * For prepaid invoices, blocks until '' | ||
| - | * For postpaid invoices, blocks only when the customer is not subscribed. | ||
| - | * If blocked, returns without touching the guest. | ||
| - | - Step 1: Request server resources | ||
| - | * Connects to the compute host shell through '' | ||
| - | * Checks banned-customer conditions. | ||
| - | * Aborts if a disk already exists for this guest. | ||
| - | - Step 2: Allocate virtual disk | ||
| - | * Calls '' | ||
| - | * Issues licences early through '' | ||
| - | - Step 3: Install operating system | ||
| - | * Calls '' | ||
| - | * Configures time machine if enabled. | ||
| - | - Step 4: Start server | ||
| - | * Boots the VM on the compute host. | ||
| - | - Step 5: Configure operating system | ||
| - | * Waits for the guest to respond to ping. | ||
| - | * Installs SSH keys. | ||
| - | * Runs deployment script/ | ||
| - | * Sets the password. | ||
| - | - Step 6: Finalise successful create | ||
| - | * Calls '' | ||
| - | * Sends relevant customer emails. | ||
| - | * Updates network membership state. | ||
| - | |||
| - | '' | ||
| - | |||
| - | < | ||
| - | command.Guest.SetStatus(GuestStatus.Active); | ||
| - | _guestService.Commit(command.Guest); | ||
| - | </ | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== 8. Command Completion ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Loads the command from the database with '' | ||
| - | * Resolves the correct handler through '' | ||
| - | * Calls '' | ||
| - | * On success: | ||
| - | * Calls '' | ||
| - | * Commits the command. | ||
| - | * Calls '' | ||
| - | * Commits again for post-completion changes. | ||
| - | * On handler failure without an exception: | ||
| - | * Saves structured '' | ||
| - | * On load or commit failure: | ||
| - | * Enqueues a '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | ===== Billing Behaviour ===== | ||
| - | |||
| - | ==== API-Side Payment Attempt ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Refreshes the customer entity. | ||
| - | * Returns early if the invoice does not require payment. | ||
| - | * Marks the invoice ready for sending. | ||
| - | * Handles zero-dollar invoices. | ||
| - | * Uses customer credit first. | ||
| - | * Generates a credit-card deposit if needed and possible. | ||
| - | * Preserves invoice sent state in credit-only failure cases to avoid duplicate payable-now emails. | ||
| - | * Calls '' | ||
| - | |||
| - | ==== HostDaemon Invoice Gate ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Checks the command' | ||
| - | * Blocks prepaid invoices until paid. | ||
| - | * Allows subscribed postpaid customers through when the invoice is not final and unpaid. | ||
| - | * Reschedules unpaid commands with '' | ||
| - | * Cancels commands when the invoice is overdue, cancelled/ | ||
| - | |||
| - | '' | ||
| - | |||
| - | ===== Failure and Recovery Behaviour ===== | ||
| - | |||
| - | ==== Unpaid Invoice / Pending Payment ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * '' | ||
| - | * Retry path uses a 1-minute wait. | ||
| - | * Cancel path runs the handler' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Ends the lease. | ||
| - | * Cancels the invoice when needed. | ||
| - | * Removes allocated resources from the guest. | ||
| - | * Sets guest status to '' | ||
| - | * Commits the guest. | ||
| - | * Sends a guest-creation-cancelled email when appropriate. | ||
| - | |||
| - | ==== Exception During Provisioning ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * Logs the failure. | ||
| - | * Writes a '' | ||
| - | * Clears '' | ||
| - | * Attempts cleanup: | ||
| - | * unclean guest poweroff; | ||
| - | * primary disk removal. | ||
| - | * In a transaction: | ||
| - | * cancels and refunds the invoice where applicable; | ||
| - | * ends the current lease; | ||
| - | * cancels the guest; | ||
| - | * sets guest status to '' | ||
| - | * commits the guest. | ||
| - | * Revokes licences. | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== Failure While Recording Command State ==== | ||
| - | |||
| - | '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | * '' | ||
| - | * '' | ||
| - | * loads the command; | ||
| - | * runs handler abort logic; | ||
| - | * calls '' | ||
| - | * commits the state. | ||
| - | * If failure handling itself fails for non-database reasons, it logs and proceeds rather than retrying indefinitely. | ||
| - | |||
| - | ===== Data / State Transitions ===== | ||
| - | |||
| - | ^ Object ^ Initial / queued state ^ Successful state ^ Failure state ^ | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | |||
| - | ===== Support-Relevant Failure Points ===== | ||
| - | |||
| - | * Customer has unpaid or overdue invoices. | ||
| - | * API path: '' | ||
| - | * HostDaemon path: '' | ||
| - | * Customer has no verified payment details or is not subscribed. | ||
| - | * API path checks '' | ||
| - | * Customer is at guest limit. | ||
| - | * Checked at API and domain level. | ||
| - | * Plan is inactive or not listable. | ||
| - | * Caught by '' | ||
| - | * No host, network, or IP is available. | ||
| - | * Allocation services fail before HostDaemon starts the build. | ||
| - | * HostCommand is blocked by another active command. | ||
| - | * '' | ||
| - | * Payment cannot be processed. | ||
| - | * '' | ||
| - | * HostDaemon cannot create disk, install OS, start guest, or reach guest by ping. | ||
| - | * Handler exception path suspends the guest and attempts cleanup. | ||
| - | * HostDaemon or database commit fails. | ||
| - | * '' | ||
| - | |||
| - | ===== Source Files ===== | ||
| - | |||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | ===== Remaining Questions ===== | ||
| - | |||
| - | * Which customer-visible status label maps to internal '' | ||
| - | * Which operational job performs automatic cleanup/ | ||
| - | * Which logs/ | ||
| - | |||
| - | ===== Related Wiki Pages ===== | ||
| - | |||
| - | * [[syntheses: | ||
| - | * [[syntheses: | ||
| - | * [[syntheses: | ||
| - | * [[wiki: | ||
| - | * [[wiki: | ||
syntheses/vps-create-flow.1784681017.txt.gz · Last modified: by bkirk
