Skip to content

Resource Request Feature#332

Open
cmyers-mieweb wants to merge 6 commits into
mainfrom
cmyers_258
Open

Resource Request Feature#332
cmyers-mieweb wants to merge 6 commits into
mainfrom
cmyers_258

Conversation

@cmyers-mieweb
Copy link
Copy Markdown
Collaborator

@cmyers-mieweb cmyers-mieweb commented Jun 4, 2026

Resolves: #258

This pull request introduces a new resource request system for container resources, allowing users to request changes to resource allocations (such as RAM, CPUs, etc.) for their containers, with an approval workflow for changes above default values. It adds new UI components for managing and requesting resources, updates navigation and routing to support new resource request pages, and expands the API query and type definitions to support these features.

Resource Request System Implementation:

  • Added a new ResourcesSection React component (ResourcesSection.tsx) that displays and allows editing of container resources, with a workflow for submitting resource requests and handling admin approval. This component is integrated into the container form page. [1] [2]
  • Defined new types ResourceRequest, EffectiveResources, and ResourceType in types.ts for strong typing of resource requests and allocations.

API and Query Enhancements:

  • Extended the queries and keys in queries.ts to support listing resource requests, counting pending requests, and fetching effective resources for a container. [1] [2]
  • Updated imports and type usages throughout the codebase to support these new features.

Navigation and Routing Updates:

  • Updated the sidebar navigation to include links for "Resource Requests" (for admins, with a pending count badge) and "My Requests" (for regular users). [1] [2] [3]
  • Added routes and page imports for the new resource request pages (ResourceRequestsPage and MyRequestsPage). [1] [2]

Miscellaneous Improvements:

  • Improved .dockerignore to exclude all node_modules directories recursively.
  • Added a debounced value hook for the hostname field in the container form to optimize resource queries. [1] [2]

These changes lay the groundwork for a more robust and user-friendly resource management workflow in the application.

rr5 rr4 rr3 rr2 rr1

Issue: #258

Introduce a full resource request feature: adds ResourceRequest model and migration, API routes for creating/listing/counting/effective/approving/denying requests, and server logic to auto-approve requests that are within defaults or created by admins. New behavior applies approved changes to existing running containers by creating reconfigure jobs.

Client changes: add types and queries for resource requests/effective resources, a Resources section in the container form (requesting resources), an admin Resource Requests page to review/approve/deny, and a badge/link in the sidebar showing pending request count. Also register the new router under /api/v1/resource-requests.

Daemon/CLI updates: create-container now consults approved resources when provisioning (cores/memory/swap/rootfs) and reconfigure-container accepts resource flags and will apply them via the Proxmox client. Misc: adjust .dockerignore to use **/node_modules.

Indexes added for efficient lookups (siteId/hostname/username/status) and request defaults/validation are defined on the model.
Introduce a full resource-requests workflow: add a new MyRequestsPage and enhance ResourceRequestsPage with tabs for pending/closed requests, improved tables, and admin actions. Update the sidebar and router to expose /my-requests for non-admin users and rename labels for clarity. Backend: extend API to handle a 'closed' query (approved|denied), validate that a provisioned container exists before approving a request, and send non-blocking notification emails when a request is reviewed. Add sendResourceRequestStatusEmail to utils/email and wire up emailing (with HTML/text templates). Other changes: make reconfigure-container only restart containers when necessary and only update MAC/IP when a restart occurred; debounce hostname input in the container form; tweak some UI styles and layout widths. Includes Sequelize Op/User imports and small refactors to support these features.
@cmyers-mieweb cmyers-mieweb requested a review from runleveldev June 4, 2026 16:30
Comment thread create-a-container/routers/api/v1/resource-requests.js Fixed
Comment thread create-a-container/routers/api/v1/resource-requests.js Fixed
);
const cores = approvedResources.cpus || 4;
const memory = approvedResources.memory || 4096;
const swap = approvedResources.swap !== undefined ? approvedResources.swap : 0;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why isn't this using the same <resource || default> pattern as the previous and following assignments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've modified to keep the consistency

type: Sequelize.STRING(255),
allowNull: false,
},
requestedBy: {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is username and requestedBy not the same thing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They have the same value, but kept it seperated in the migration for ease of identification. I am creating a new migration to drop this in favor username.


// Verify at least one provisioned container exists for this request before approving.
// A container is considered provisioned when it has a Proxmox VMID (containerId is not null).
const provisionedContainer = await Container.findOne({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this check should be moved after setting the request to approved in the database but before applying it to any running container. A user should be able to pre-load resource requests if they know they're going to make a container that will need them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason why this check was included was of a bug I found where if a user requests extra resources during the build form, but does NOT proceed to submit to the container creator and backs out, a request will be received and if approved, the page will break.

);

/**
* Send an approval/denial email to the user who submitted the request.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This scares me a little bit. I don't want to spam people with emails since we don't yet have a way to opt-out. Our domain reputation is still building I don't want to risk spam reports for non-critical notifications.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove the email feature

cmyers-mieweb and others added 4 commits June 4, 2026 14:15
…tion or class'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…tion or class'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Remove the requestedBy column and related notification logic across the app. Adds a migration to drop requestedBy (with a down migration to re-add it), removes the field from the Sequelize model and client types, and updates the frontend to display req.username instead of req.requestedBy. API routes were updated to use username from session/creation and to remove User lookup and notifyRequestReviewed/sendResourceRequestStatusEmail usage; the email helper implementation/export was also removed. Also includes a minor CLI tweak to default swap with a simpler expression in create-container/bin/create-container.js.
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.

Add ability to choose a size of the virtual env size

2 participants