-
Notifications
You must be signed in to change notification settings - Fork 3
Add scheduled job support and OCI image pull job #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Introduces ScheduledJob model, migrations, and seeder for cron-based job scheduling. Updates job-runner to process scheduled jobs and create pending jobs when schedule conditions are met. Adds support for defaultStorage on nodes, including migration, model, and form update. Implements oci-build-job utility to pull OCI container images to Proxmox nodes using API credentials and storage configuration.
Scheduled Jobs / OCI Image Pull IntegrationSummary
Why
Files Changed (High-Level)Migrations
Models
Seeders
Job Runner
Utils
UI
package.json
Architecture Diagram (Mermaid)graph LR
A[ScheduledJobs] -->|"evaluated by"| B[Job Runner]
B -->|"on match"| C[Jobs (pending)]
C -->|"claimed by"| D[Runner Execution]
D -->|"executes"| E[OCI Build Job Script]
E -->|"uses"| F[Node Model (apiUrl, token, defaultStorage)]
Implementation Notes (Concise)ScheduledJobs Table Columns
Job Runner:
|
create-a-container/seeders/20251203000000-seed-oci-build-job.js
Outdated
Show resolved
Hide resolved
|
|
||
| <div class="mb-3"> | ||
| <label for="defaultStorage" class="form-label">Default Storage</label> | ||
| <input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has the router been updated to handle this input?
Introduces a script to build and push site-specific OCI images using Docker, a seeder to schedule this job, and a Debian Dockerfile template. Updates oci-build-job.js to prefer LOCAL_REGISTRY for image registry. The README is updated to reference the local registry in example commands.
Replaces separate oci-build-job and build-push-oci scripts with a single oci-build-push-pull job that builds, pushes, and pulls OCI images for all sites and nodes. Updates scheduled job seeders to use the new script and introduces shared Proxmox utilities for task polling and image pulling. Old scripts and their references are removed or deprecated for migration rollback support.
| * command path relative to the repository root. | ||
| */ | ||
|
|
||
| const { run } = require('../utils/oci-build-push-pull'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just move the other file here and run it. It should not be in the utils folder because it's not a utility.
| async up(queryInterface, Sequelize) { | ||
| // This seeder is now superseded by 20251203000000-seed-oci-build-job.js | ||
| // which uses the combined oci-build-push-pull.js job. | ||
| // Keeping this file for migration rollback support only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file, we don't need it in main since it was never deployed.
| @@ -0,0 +1,11 @@ | |||
| # Debian OCI image template for site-specific builds | |||
| FROM debian:13 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to derive from Proxmox's base image, not Docker's. See https://github.com/mieweb/opensource-server/blob/main/Dockerfile 2 stage build on how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excerpt
FROM debian:13 AS builder
ARG URL="http://download.proxmox.com/images/system/debian-13-standard_13.1-2_amd64.tar.zst"
ARG DOMAIN
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
tar \
zstd \
ca-certificates && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /rootfs/usr/local/bin && \
curl -fsSL "$URL" | tar --zstd -x -C /rootfs && \
curl -fsSL https://pown.sh/ -o /tmp/pown.sh && \
chmod +x /tmp/pown.sh && \
cp /tmp/pown.sh /rootfs/usr/local/bin/pown.sh && \
chmod +x /rootfs/usr/local/bin/pown.sh && \
chroot /rootfs /usr/local/bin/pown.sh "$DOMAIN"
| } | ||
| } | ||
|
|
||
| module.exports = { run }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove from here down once it's called directly in bin and replace with a single call to run()
| // ========== PHASE 2: Prepare all images to pull ========== | ||
| console.log('\n[oci-build-push-pull] ========== PHASE 2: Prepare Images to Pull =========='); | ||
|
|
||
| const preBuiltImages = getPreBuiltImages(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Phase 2 can likely be removed (with the following phases refactored accordingly) since we're only concerned with the site-specific images and nothing prebuilt.
| async pullImage(nodeName, image, storage) { | ||
| // Use global fetch (Node 18+). If not available, this will throw and the caller | ||
| // can fallback or install a fetch polyfill. | ||
| if (typeof fetch !== 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this check. We will not be supporting node runtimes <18
| headers['Content-Type'] = 'application/json'; | ||
|
|
||
| // Determine agent for TLS options if provided | ||
| let agent = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumer of this class is responsible for creation the https agent and attaching it to the options object if required. This agent construction here should be removed. And replaced with this.options.httpsAgent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need these functions (I don't see the need, they're pretty simple wrappers), then they should be methods on the ProxmoxApi class not arbitrary helpers.
README.md
Outdated
| ```bash | ||
| # Pull and run the container from GHCR | ||
| pct create <VMID> ghcr.io/mieweb/opensource-server:latest \ | ||
| pct create <VMID> localhost:5000/mieweb/opensource-server:latest \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not something that should be updated in this PR. This is part of instructions for bootstrapping the cluster which does use ghcr.io unlike the template builds which won't.
Moved and consolidated the OCI build/push/pull logic into the bin/oci-build-push-pull.js file, removing the old utils/oci-build-push-pull.js and proxmox-utils.js modules. Updated the Dockerfile template to use Proxmox's minimal LXC rootfs for more accurate OCI images. Improved CLI argument parsing and Proxmox API utilities for image pulling and storage selection. Updated README to use ghcr.io for container pulls. Removed obsolete seeder for build-push-oci job.
Introduces ScheduledJob model, migrations, and seeder for cron-based job scheduling. Updates job-runner to process scheduled jobs and create pending jobs when schedule conditions are met. Adds support for defaultStorage on nodes, including migration, model, and form update. Implements oci-build-job utility to pull OCI container images to Proxmox nodes using API credentials and storage configuration.