Skip to content

Idle container shutdown (Epic 1/6) Idle shutdown management - #540

Open
cmyers-mieweb wants to merge 5 commits into
mainfrom
cmyers_idle-shutdown
Open

cmyers-mieweb wants to merge 5 commits into
mainfrom
cmyers_idle-shutdown

Conversation

@cmyers-mieweb

@cmyers-mieweb cmyers-mieweb commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Issue: #526

This pull request adds support for managing the "idle shutdown" (idleTime) resource for containers, allowing users to configure how long a container can be idle before being automatically stopped. It introduces new UI elements, validation, and formatting for idleTime, updates the resource request and display logic, and ensures both client and API schemas are consistent. The changes also refactor resource-related constants and formatting utilities for consistency and maintainability.

Idle Time Resource Support

  • Added idleTime as a supported resource type throughout the UI, API schema, and backend model, allowing users to request and view idle shutdown settings for containers. [1] [2] [3] [4]
  • Updated resource request approval rules: for idleTime, only values between 1 and 72 hours are auto-approved, while longer or "never" (0) require admin review.

UI Enhancements & Formatting

  • Added explanations and formatting for idleTime in resource sections and request tables, including user-friendly labels like "Never", "3 days", etc. [1] [2] [3] [4]
  • Updated ResourceValueInput to support custom formatting for preset labels, enabling correct display of idleTime options. [1] [2] [3] [4]

Refactoring & Consistency

  • Centralized resource defaults, labels, and formatting logic into lib/resources.ts, removing duplication from multiple files and ensuring consistent display and validation across the app. [1] [2] [3]
  • Updated all usages of resource defaults and labels in the UI to use the new centralized constants and formatting functions. [1] [2] [3] [4] [5] [6]

API Schema Updates

  • Extended OpenAPI schema to include idleTime in all relevant types, enums, and documentation, clarifying units and approval behavior. [1] [2] [3]

These changes collectively enable users and admins to control and view idle shutdown settings for containers, with clear UI and robust backend support.

Screenshots

  • Resource cards
image * Idle shutdown presets image
  • My requests pending
image
  • my requests history
image
  • admin review pending
image

cmyers-mieweb and others added 5 commits December 2, 2026 08:17
Supertest integration tests for every endpoint ahead of migrating the
legacy route to resources/resource-requests (mvc-manifesto §6 step 1).

Refs #526

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Split the legacy god route into router/controller/service/repository/
validator/serializer per mvc-manifesto §6. Wire contract unchanged and
pinned by the integration suite; validation now goes through zod via the
shared validate() middleware with the legacy per-field messages.

Refs #526

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- idleTime (hours, 0 = never) joins RESOURCE_DEFAULTS; VALID_RESOURCE_TYPES
  is now derived from the defaults so the two can't drift.
- Per-type RESOURCE_POLICIES in the service: idleTime auto-approves 1..72
  (inverted vs capacity types), needs review for >72 or 0, never enqueues
  reconfigure-container.js, and can be approved without a provisioned
  container.
- getIdleTimeHours(container) + IDLE_TIME_NEVER for the idle sweep (#527).
- /resource-requests/effective returns idleTime.
- Client: idle shutdown row on the Resources card (Never / hours / days);
  defaults, labels and formatting consolidated into lib/resources.ts.
- OpenAPI: shared ResourceType/ResourceValue/EffectiveResources schemas.

Closes #526

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Admin approval table for every resource type (incl. idleTime) and a
developer reference for #525 mapping stages to the code building blocks.

Refs #525

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bles

The new 'Idle shutdown' label and '3 days -> 8 hours' amounts wrapped
inside the narrow Resource/Amount columns.

Refs #526

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cmyers-mieweb cmyers-mieweb changed the title Cmyers idle shutdown Idle container shutdown (Epic 1/6) Idle shutdown management Dec 2, 2026
Copilot AI balanced review requested due to automatic review settings December 2, 2026 16:44

Copilot AI 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.

🟡 Changes recommended

Validation failures hide the non-negative-integer requirement, and the UI incorrectly describes which durations require approval.

2 open issues
What changed in this PR

Adds configurable idle-shutdown settings to the existing container resource-request workflow. Automatic shutdown and wake-up remain planned for later stages.

Changes:

  • Adds idleTime defaults, approval policies, API validation, and tests.
  • Adds idle-time controls and shared resource formatting to the UI.
  • Documents approval rules and the broader idle-shutdown design.
File Description
mie-opensource-landing/​zensical.toml Adds idle-shutdown documentation navigation.
mie-opensource-landing/​docs/​developers/​idle-shutdown.md Documents design and implementation stages.
mie-opensource-landing/​docs/​admins/​core-concepts/​containers.md Explains resource approval rules.
create-a-container/​routers/​api/​v1/​resource-requests.js Removes the monolithic router.
create-a-container/​routers/​api/​v1/​index.js Mounts the replacement router.
create-a-container/​resources/​resource-requests/​validator.js Defines request validation schemas.
create-a-container/​resources/​resource-requests/​service.js Centralizes approval and application policies.
create-a-container/​resources/​resource-requests/​serializer.js Defines resource-request responses.
create-a-container/​resources/​resource-requests/​router.js Connects routes, validation, and authorization.
create-a-container/​resources/​resource-requests/​repository.js Encapsulates database access.
create-a-container/​resources/​resource-requests/​controller.js Connects HTTP handlers to services.
create-a-container/​resources/​resource-requests/​__tests__/​service.test.js Tests policies and idle-time defaults.
create-a-container/​resources/​resource-requests/​__tests__/​resource-requests.api.test.js Tests API behavior and job creation.
create-a-container/​openapi.v1.yaml Documents idle-time schemas and approvals.
create-a-container/​models/​resourcerequest.js Adds the idle-time resource default.
create-a-container/​client/​src/​pages/​resource-requests/​ResourceRequestsPage.tsx Uses shared formatting for admin requests.
create-a-container/​client/​src/​pages/​resource-requests/​MyRequestsPage.tsx Uses shared formatting for user requests.
create-a-container/​client/​src/​lib/​types.ts Extends resource types with idle time.
create-a-container/​client/​src/​lib/​resources.ts Centralizes defaults, labels, and formatting.
create-a-container/​client/​src/​components/​containers/​ResourceValueInput.tsx Supports custom preset labels.
create-a-container/​client/​src/​components/​containers/​ResourcesSection.tsx Adds idle-shutdown controls and explanatory text.

Review effort: Balanced

router.get('/', validate({ query: listQuery }), ctrl.list);
router.get('/count', ctrl.count);
router.get('/effective/:siteId/:hostname/:username', validate({ params: effectiveParams }), ctrl.effective);
router.post('/', validate(createRequest), ctrl.create);
Comment on lines +180 to +181
(SSH and direct connections don&apos;t count). Shortening it applies immediately; longer
or Never requires admin approval.
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.

2 participants