Commit Graph
100 Commits
Author SHA1 Message Date
nexgen_mirrors 758318f71a fix region id 2026-02-04 16:38:28 +10:30
nexgen_mirrors 82be76c1d1 misc 2026-02-04 14:23:32 +10:30
nexgen_mirrors c7f49cc533 fix(dns): use Flask app config for WebSocket URL
The change switches from using environment variables to Flask's application configuration for retrieving the WebSocket server URL, ensuring consistent configuration access through the application context.
2026-02-04 14:23:26 +10:30
nexgen_mirrors 1f6ce0dbad fix(container): add console log dumping for NSController debugging
Dump container console logs when NSController failures or health check failures occur to help with troubleshooting. The new method fetches the last 100 lines of logs and logs them at debug level for easier diagnosis of container startup issues.

Called in two scenarios:
- When NSController failure is detected
- When NSController health check fails
2026-02-04 14:23:00 +10:30
nexgen_mirrors 4c4a344acd fix(container): track launch failures and skip delta updates when failures occur
Track NSController and regular container launch failures when health checks fail or containers are skipped. Only send delta status updates when there are no launch failures, preventing misleading status communications.
2026-02-04 14:08:15 +10:30
nexgen_mirrors 6570d4c8a8 fix(container): clean up NSController containers on health check failure
When NSController health check fails, properly clean up the container instead of just aborting. This prevents resource leaks by stopping and removing the failed container, cleaning up network namespace symlinks, and removing injected files.
2026-02-04 14:07:22 +10:30
nexgen_mirrors b9207c3ec1 misc 2026-01-10 19:09:00 +10:30
nexgen_mirrors ef862078a5 refactor(network): use NSController network port IP for port forwarding
Move NetworkPort creation earlier in the allocation process and use the NSController's attached NetworkPort IP address for port forwarding when available, instead of defaulting to the host's IP address. This ensures pods with NSControllers use their dedicated network port IP for external connectivity.
2026-01-10 19:08:53 +10:30
nexgen_mirrors 00e092a268 tidy docs 2026-01-06 15:54:35 +10:30
nexgen_mirrors a152f57539 feat(api): add network ports to pod details response
Collects network ports from all containers within a pod and includes
them in the API response. Each network port entry contains full details
including ID, name, network ID, IP address, MAC address, port type,
DNS servers, subnet mask, and status information.
2026-01-06 15:43:31 +10:30
nexgen_mirrors 06989be22e Hugo user docs 2026-01-06 15:43:03 +10:30
nexgen_mirrors 52c559e1cd refactor(network): move NetworkPort creation from containers to NSController
NetworkPort objects are now attached to the NSController (not individual containers).
The NSController manages the network namespace for the entire pod, and containers
within that pod share this network configuration. This design allows containers
to share the same network stack while maintaining proper isolation via the
NSController's network namespace.

The refactor consolidates network port creation by:
- Scanning all containers in a pod to collect network requirements
- Creating NetworkPort records attached to the NSController
- Updating port_type from "container" to "nscontroller"
- Removing explicit networks configuration from NSController config (relying on inherited pod networking)
2026-01-06 15:42:42 +10:30
nexgen_mirrors 016f1fc447 refactor(workload): consolidate deletion logic into shared utilities
Extract duplicate deletion code from pod and container routes into
reusable helper functions in deletion_helpers.py module:
- collect_and_cleanup_network_ports() for network port cleanup
- cleanup_workload_related_records() for resource/volume cleanup
- log_deletion_audit_event() for consistent audit logging

Add SDN network port updates during pod deletion to ensure proper
network cleanup when containers are removed.

Optimize get_pods() endpoint by replacing N+1 queries with batch
queries and lookup maps for nscontrollers, tunnels, and DNS records.

Enhance get_pod() response to include cloudflare tunnel configuration
and DNS records for better visibility into pod networking setup.
2026-01-05 16:24:37 +10:30
nexgen_mirrors d1fbd4eaec minor tidy ups 2026-01-05 13:22:00 +10:30
nexgen_mirrors 9ac0f98d92 feat(container): add network port management using OVS SDN
- Add network port configuration during container creation using OVS_SDN
- Clean up OVS bridge ports when deleting containers
- Import OVS_SDN module for port management operations
- Update delete_container method to accept and process network_ports parameter
2026-01-03 23:22:29 +10:30
nexgen_mirrors 923dc345ed feat(sdn): add network port data to pod payload
Add network port information to pod payload construction by querying
NetworkPort records for each container and including network details
(vni, ovs_bridge, gateway, ip_address, mac_address, dns_servers) in the
container specification.
2026-01-03 23:04:22 +10:30
nexgen_mirrors 21c7765a0a feat(sdn): add delete_port method for OVS bridge port management
Add a new delete_port method to the OVS_SDN worker class that enables removing network ports from Open vSwitch bridges. The method includes safety checks to verify port existence before deletion and provides proper error handling and logging for troubleshooting.
2026-01-03 23:03:56 +10:30
nexgen_mirrors 5018a74c3a feat(sdn): add network port management and SDN updates for container lifecycle
Implement comprehensive network port management across container lifecycle operations:
- Add NetworkPort creation when containers are provisioned
- Send SDN updates after port creation for network configuration
- Properly clean up network ports and send SDN updates on container deletion
- Filter out deleted ports from SDN payload calculations and network port queries
- Add dependency on SDN update tasks before container dispatch

These changes ensure proper network state synchronization between the database and SDN controller, preventing stale port configurations and ensuring consistent network topology across container lifecycle operations.
2026-01-02 23:52:04 +10:30
nexgen_mirrors 81dda8de4f fix(sdn): handle None workload_host_ip to prevent VXLAN failures
Added validation to skip peer ports with missing workload_host_ip during SDN
payload generation. When a port's peer host has no east-west IP configured, the
system now logs a warning and continues processing rather than allowing the None
value to cause VXLAN interface failures.
2026-01-02 16:32:57 +10:30
nexgen_mirrors f490f05584 feat(api): add SDN payload preview endpoint for network debugging
Adds a debug endpoint to preview SDN payloads without sending to workers, enabling easier troubleshooting of network configurations. Also fixes indentation issue in generate_sdn_payload that prevented proper return of payload data, and removes blocking debug code that was preventing SDN updates from being processed.
2026-01-02 16:20:12 +10:30
nexgen_mirrors 7b977c7f9b feat(dns): add localhost resolution and DNS configuration for NSControllers
- Add address=/localhost/127.0.0.1 to DNS zone generation for Docker healthchecks
- Configure container DNS to use 127.0.0.1 for NSControllers with empty dns_opt and search
- Update NSController image to xcloudify-nscontroller:latest
- Adjust Dockerfile healthcheck start-period from 10s to 5s for faster startup detection
2026-01-02 14:28:32 +10:30
nexgen_mirrors 0577cae99f docs(scripts): add DNS capabilities demonstration script
Adds a comprehensive bash script that demonstrates DNS functionality for containers:
- Creating containers with DNS-enabled ports (automatic DNS record creation)
- Creating custom A and CNAME records
- Listing, updating TTL, and deleting DNS records for a VDC

Also improves pod naming uniqueness in launch_single_container.sh by adding timestamps, and adds nscontroller image to the build script.
2026-01-02 14:12:34 +10:30
nexgen_mirrors 1a018edb67 fix(dns): fix SRV record format and add hostNetwork pod support
Correct the SRV record format in dnsmasq configuration from
<service>,<priority>,<weight>,<port>,<target> to
<service>,<target>,<port>,<priority>,<weight>. Also add support for pods
running in hostNetwork mode by using the host's ip_address_northsouth
when a pod has no network port assigned.
2026-01-02 14:12:12 +10:30
nexgen_mirrors 43a0f7ddd0 fix(allocation): fix allocation retry to pick new host on offline failure
When an alternate host doesn't exist for a pod that's failing on an offline
host, we need to clear the workload_host_id reference so that allocate_and_dispatch
will select a new host instead of repeatedly trying the same offline host.
2026-01-02 13:23:32 +10:30
nexgen_mirrors 1a8b3bbaca feat(dns): implement centralized NSController configuration and fix double period bug
Refactor NSController configuration into a single source of truth module, ensuring consistent DNS volume mounts and resource limits. Fixes bug where trailing periods in universe DNS names caused double periods in VDC zone names. Removes legacy DNS update modes and standardizes on shared volume approach. Adds comprehensive configuration constants and improves worker-side DNS handling.
2026-01-02 12:58:03 +10:30
nexgen_mirrors e5e5f8f58f feat(models): add pod relationship to Workload model 2026-01-02 12:56:33 +10:30
nexgen_mirrors 05a9ab1741 dns improvements 2025-12-09 15:16:13 +10:30
nexgen_mirrors ea4578101a Merge branch 'master' of ssh://source.hawkless.id.au:222/coryHawkvelt/theapi 2025-12-09 14:17:26 +10:30
nexgen_mirrors 76ab70db86 x 2025-12-09 14:17:22 +10:30
nexgen_mirrors 2debc9a467 Pushing failover changes...i thinik 2025-12-03 21:36:40 +10:30
nexgen_mirrors 62aac75309 feat(api): include creation timestamp in pod response data 2025-12-02 10:32:34 +10:30
nexgen_mirrors b8a7f85558 moved docs and scripts 2025-12-01 14:50:08 +10:30
nexgen_mirrors 466a6f1e08 feat(worker): add configurable websocket ping debug logging
Add ENABLE_WEBSOCKET_PING_DEBUG setting to control whether websocket ping
diagnostic logs are emitted. This reduces log noise during normal operation
while allowing detailed ping debugging when needed.
2025-12-01 14:50:00 +10:30
nexgen_mirrors 358d961dbd ansible stuff 2025-12-01 14:36:27 +10:30
nexgen_mirrors 8d2c722d4a feat(workload): add resource usage to container workload details
Enhance the get_container_workload endpoint to include resource usage
data in the response. Additionally adds validation for the optional
pod_name parameter to ensure non-empty string values.
2025-12-01 14:36:21 +10:30
nexgen_mirrors 8e15951843 refactor(worker): remove periodic connection health monitor
Remove the periodic_connection_monitor method and its associated task
lifecycle management. This eliminates the 10-second interval health
checks that logged transport state and detected split-brain, stale
flag, and ghost state conditions.
2025-12-01 14:18:36 +10:30
nexgen_mirrors a7b832aa59 feat(worker): enhance connection monitoring with health checks and diagnostics
- Add periodic health monitor to detect split-brain and ghost connection states
- Disable automatic reconnection in favor of manual control
- Fix reconnection_in_progress flag not being reset after successful reconnect
- Add structured logging with prefixes ([RECONNECT], [HEALTH], [PING], [START])
- Log transport state during connection lifecycle events for better debugging
2025-12-01 14:17:20 +10:30
nexgen_mirrors 09cc7f19d4 feat(worker): add PCI device scanner for GPU/TPU detection
Implement PCI device scanner to detect and report GPUs, TPUs, and other
hardware accelerators on workload hosts at startup. The scanner follows
the same pattern as the existing OVS bridge scanner.

Key components:
- PCIDeviceScannerTask: Scans devices using lspci, filters based on
  vendor/device ID combinations from region configuration, and reports
  to API server
- Worker integration: Scanner initializes on worker startup and executes
  on join accept
- Region-based filtering: JSON configuration allows per-region device
  filters with wildcard support
- Storage: Uses existing WorkloadHostFixedResource model with type
  'gpu', 'tpu', or 'accelerator'

The scanner loads filters from region config via API, executes lspci,
parses device information, applies filters, and reports matched devices
to the API endpoint /api/workload_hosts/{host_id}/pci_devices.

Includes comprehensive documentation covering implementation details,
configuration examples, testing procedures, and troubleshooting guidance.
2025-12-01 12:42:11 +10:30
nexgen_mirrors 84d890f564 feat(ansible): add webserver with content generator deployment example
Add Ansible playbook for deploying nginx webserver and content generator
using shared NFS storage. Update build script to include new container image,
add port mapping to launch example, and note related todos for reallocation
and NSController CPU issues.
2025-11-28 15:23:58 +10:30
nexgen_mirrors b1bee30f9b feat(ansible): enhance xCloudify infrastructure role to v2.0.0 with full API parity
Add comprehensive support for pod management (create/attach/lifecycle), healthchecks (test/interval/timeout/retries/start_period), restart policies (always/on-failure/etc. with max retries), injected files (base64 content/permissions), and partial updates (PATCH for zero-downtime env/resources changes). Update SDK with new methods (patch_container, pod_lifecycle, wait_for_* with backoff), enhanced auth (token refresh), validation, and error handling. Include updated examples, tests, docs, and schemas for backward compatibility and 100% feature coverage.

Bump role version to 2.0.0; deprecate legacy full-recreate with warnings.
2025-11-28 15:03:51 +10:30
nexgen_mirrors a8eb8001c2 refactor(worker): convert monitors from multiprocessing to threading
- Replace multiprocessing.Process with threading.Thread for Docker and Libvirt monitors
- Remove multiprocessing.Manager usage and associated cleanup code
- Simplify monitor lifecycle with running flag instead of Event objects
- Add use_db_state=True consistently to all build_pod_payload calls
- Add pod_id field to containers in workload host routes
- Add debug logging for host status updates and container data

Threading approach reduces complexity and overhead while maintaining
the same monitoring functionality.
2025-11-28 01:54:13 +10:30
nexgen_mirrors 656719282a blacklisting fixes 2025-11-26 15:54:02 +10:30
nexgen_mirrors 9d20b61db7 work 2025-11-25 22:47:16 +10:30
nexgen_mirrors d03f55c9f0 fix(audit): handle none objects in log_event
Adds logic to set object_type and object_id when object is None,
preventing AttributeError in batch operations. Updates debug logging
and AuditEntry creation to use these variables.
2025-11-21 01:18:48 +10:30
nexgen_mirrors e43edf5c53 Host reconciliation mostly done 2025-11-17 13:50:59 +10:30
nexgen_mirrors 3cb2a0f2fb fixing reconcile 2025-11-17 13:12:52 +10:30
nexgen_mirrors e97e295be6 build(deps): resolve docker connection issue by pinning requests to 2.31.0 and adding fallback client initialization 2025-11-17 12:11:27 +10:30
nexgen_mirrors 7e321a2103 much 2025-11-12 16:42:35 +10:30
nexgen_mirrors 1e71d089ee return api_response(
data="feat(db): add host failure audit table and region failover columns",
    success=True,
    message="Conventional commit message generated successfully.",
    status=200
)
2025-11-12 13:13:09 +10:30
nexgen_mirrors 5d8cf11dc3 maint 2025-11-12 11:55:43 +10:30
nexgen_mirrors 1e49dcf720 tidy docs 2025-11-12 11:55:35 +10:30
nexgen_mirrors 26f39d53b4 unfuck 2025-11-12 11:55:16 +10:30
nexgen_mirrors 2ebf96c626 Docs update 2025-10-16 14:10:56 +10:30
nexgen_mirrors 1f3f6bbfc1 feat(container): add restart policy support to container creation and tests
- Add restart_policy field to ScenarioSpec class in config.py
- Update runner.py to conditionally include restart_policy in container specs for create_container, add_container_to_pod, and create_container_with_invalid_image methods
- Add example scenario with restart_policy in playbook.example.yaml
- Create test_restart_policy.yaml playbook for testing restart policy functionality
- Create test_restart_policy_direct.py script for direct API testing of restart policy feature
2025-10-16 14:08:51 +10:30
nexgen_mirrors 9a77e2e4cd feat(container): add restart policy support to container creation
- Add validation for 'restart_policy' parameter in workload container routes with valid options: 'no', 'always', 'unless-stopped', 'on-failure'
- Set default restart policy to 'always' if not specified
- Update pod payload builder to include restart policy from launch params, defaulting to 'always'
- Modify container task to use restart policy from container spec or settings, with logging for applied policy

Implements configurable container restart behavior as per recent config addition.
2025-10-16 14:08:14 +10:30
nexgen_mirrors ef64ee50da feat(config): add container restart policy setting\n\n- Introduce RESTART_POLICY setting with default value 'always'\n- Apply restart policy to container creation kwargs\n- Supports configurable container restart behavior 2025-09-25 17:42:45 +09:30
nexgen_mirrors e50bf81969 update ip 2025-09-25 17:31:26 +09:30
nexgen_mirrors 8f4c27a1eb feat(ansible): add protocol support for container ports\n\n- Add 'protocol' option (tcp/udp) to container port mappings\n- Update validation to enforce protocol choices\n- Add example usage with udp protocol for dns port 2025-09-25 17:26:20 +09:30
nexgen_mirrors 5515864215 feat(config): add sharedfs root configuration 2025-09-25 17:26:05 +09:30
nexgen_mirrors 70cc4fbe3e feat(ansible): add Node-RED and Omada Controller deployment examples
Adds two new Ansible playbooks demonstrating deployment of Node-RED and TP-Link Omada Controller to xCloudify. Each example includes container configuration, volume definitions, and deployment summaries.

- node-red.yml: Deploys Node-RED with configurable module installation and authentication
- omada-controller.yml: Deploys Omada Controller with required ports and storage volumes

Both examples use the xcloudify_infrastructure role and include debug output for deployment verification.
2025-09-25 17:25:42 +09:30
nexgen_mirrors e2c850fb58 Slight improvements to logging 2025-09-23 21:50:06 +09:30
nexgen_mirrors 4c34ac1ec8 refactor(api): remove debug log and add TODO for CloudflareTunnelManager initialization 2025-09-23 15:02:18 +09:30
nexgen_mirrors 998d8d9fda feat(docker): add support for docker_absent event
Add "docker_absent" to the list of handled Docker events and map it to the "deleted" status in the event-to-status dictionary. This ensures proper handling of container absence events.
2025-09-23 15:00:22 +09:30
nexgen_mirrors 04724ddb15 docs 2025-09-23 02:25:06 +09:30
nexgen_mirrors 4fd1d28403 Containers can transition form one host to another now when a failure is detected :) 2025-09-23 02:24:47 +09:30
nexgen_mirrors c65c4ae004 feat(api): add pod status update based on container statuses
- Introduce update_pod_status function to synchronize pod status with container statuses
- Set pod to 'mixed' if containers have varying statuses, or match uniform status
- Soft delete pod if all containers are deleted

Closes #123 (assuming related issue)
2025-09-23 01:31:59 +09:30
nexgen_mirrors 109f99369d Modified the handle_disconnect function in websocket_server/events/messages.py to delete the Redis keys ws_liveness:{worker_id} and ws_latency:{worker_id} when a worker disconnects. This prevents stale heartbeat data from causing reconcile_online_workers to incorrectly mark disconnected workers as online. 2025-09-23 01:31:41 +09:30
nexgen_mirrors 932156dcc6 chore(worker): disable debug logging in reconcile_online_workers 2025-09-23 01:14:36 +09:30
nexgen_mirrors 38925d32f8 feat(api): add support for including deleted containers via query parameter
Add 'include_deleted' query parameter to the get_container_workloads_for_host endpoint,
allowing clients to retrieve deleted containers in the response. Update build_pod_payload
function to accept and handle the include_deleted flag, filtering workloads accordingly.

This enhances the API's flexibility for reconciliation tasks by providing access to
deleted container data when needed.
2025-09-23 00:53:30 +09:30
nexgen_mirrors c2142fc23b improved injected files 2025-09-23 00:53:15 +09:30
nexgen_mirrors 787a1050a5 docs 2025-09-22 17:34:57 +09:30
nexgen_mirrors 78980cb047 feat(container): add support for injecting files into containers
Add validation for injected_files parameter in API, including security checks for filenames, base64 content, and permissions. Update pod payload building to include injected files. Implement file injection logic in worker tasks, with base64 decoding, temp file creation, bind mounts, and cleanup. Include comprehensive test script for validation and handling.
2025-09-22 14:12:33 +09:30
nexgen_mirrors 50db17d62b fix(worker): await async container status reporting methods
Make report_container_statuses and fetch_container_workloads_for_host properly async,
ensuring correct handling of asynchronous operations in the worker client.
2025-09-22 13:45:00 +09:30
nexgen_mirrors 2025acadff feat(api): add query parameter to include deleted containers
The get_container_workloads endpoint now supports an optional 'include_deleted' query parameter. When set to 'true', it includes deleted container workloads in the response. Defaults to 'false' for backward compatibility.
2025-09-22 13:44:48 +09:30
nexgen_mirrors d564376ebd feat(worker): filter container status reports to only expected containers
Add logic to fetch current desired container workloads from the server and filter status reporting to only include containers that should exist according to the server response. This prevents reporting on stale or unexpected containers, improving accuracy and reducing noise in status updates.
2025-09-22 12:54:18 +09:30
nexgen_mirrors b296bc8372 Added command param to validation function 2025-09-22 12:14:18 +09:30
nexgen_mirrors 1de1ee60c6 more ansible 2025-09-22 12:13:58 +09:30
nexgen_mirrors 2b17b685a5 updated ansible examples 2025-09-22 12:13:39 +09:30
nexgen_mirrors c90a3514b2 feat(ansible): add single container deployment example and improve container state handling
- Add new single-container.yml example for deploying nginx container
- Filter out deleted/pending-deleted containers in management operations
- Enhance error handling in network module with safer result access
2025-09-21 22:53:48 +09:30
nexgen_mirrors 71636e4d98 Moved pull info into extended status param ont he Workload model
Fixed bug in reconciliation that caused pending deleted containers to launch on worker restart
2025-09-21 22:45:37 +09:30
nexgen_mirrors 7532075126 feat(api): add VNI uniqueness validation and random generation
- Validate provided VNI for uniqueness within the region
- Generate random VNI if not provided
- Improve error handling for VDC not found and VNI conflicts

BREAKING CHANGE: VNI is now required to be unique per region, may affect existing networks with duplicate VNIs
2025-09-18 15:30:05 +09:30
nexgen_mirrors 0532f234e4 Dont require VNI in netowrk POST input, but create random VNI 2025-09-18 15:03:49 +09:30
nexgen_mirrors 7d6130af0b Move docs 2025-09-18 15:03:21 +09:30
nexgen_mirrors 49c915a721 Merge branch 'master' of ssh://source.hawkless.id.au:222/coryHawkvelt/theapi 2025-09-18 13:32:41 +09:30
nexgen_mirrors 5b89c9dd8f feat(container): add reconciliation-based pod update with noise reduction
- Extract original pod update logic into _process_pod_update method
- Introduce handle_pod_update_with_reconciliation for blacklist-based noise reduction and status reconciliation
- Add methods to capture, compare, and send delta container status updates
- Implement blacklisting/unblacklisting to prevent event processing during updates
- Update handle_pod_update to delegate to new reconciliation approach
- Remove NSController recreation logic from core update flow
- Add shutdown method for graceful Docker connection closure

This enhances pod update reliability by reducing event noise and ensuring accurate status reporting through reconciliation.
2025-09-18 13:32:03 +09:30
nexgen_mirrors 33c2f2c88f missed these in the last commit 2025-09-15 22:03:06 +09:30
nexgen_mirrors 88f7e5bd17 If nscontroller restrats, recreate all attached containers 2025-09-15 17:04:31 +09:30
nexgen_mirrors 8321e2bf34 improved deletion process to handle cloudflare record not being trashed when a nscontroller restarts 2025-09-15 16:42:13 +09:30
nexgen_mirrors 852ea3c207 remove debug line 2025-09-15 13:29:10 +09:30
nexgen_mirrors 07571d2da4 dont crash if dns creation fails 2025-09-15 13:28:57 +09:30
nexgen_mirrors 2407101ac6 offloaded the deletion process to celery and optimsed it 2025-09-15 12:14:14 +09:30
nexgen_mirrors 5a3e3ef493 Missed from the last commit for some reason 2025-09-11 15:07:14 +09:30
nexgen_mirrors a26e740cfd Deleted the concept of ContainerPodContainers and all the bits that went along with its, specifically the 'mappings'
Rebuild the DB from scratch again cos alembic was confused
2025-09-11 15:06:51 +09:30
nexgen_mirrors b79b11881f Allowed for reconciliation to reset status back to running 2025-09-11 01:28:56 +09:30
nexgen_mirrors cb841ad415 First version of reconciliation implimented 2025-09-11 00:35:13 +09:30
nexgen_mirrors eb9e1dfe12 todo update 2025-09-11 00:15:17 +09:30
nexgen_mirrors ecd9dbfba0 Added large container pull tracking to the worker client, websocket server and the api server 2025-09-11 00:05:18 +09:30
nexgen_mirrors 5dbba98282 First kinda working POC of docker pull tracking 2025-09-04 15:05:40 +09:30
nexgen_mirrors 8b47047eca Sandbox for testing docker pull monitoring 2025-09-04 13:48:31 +09:30
nexgen_mirrors 9c1dccdf2d sanitise docker_image input 2025-09-04 00:36:14 +09:30