Repository navigation
Feat per role resource custom - #138
Conversation
1. Shared resource discovery, form-layer round-trip, and validation — resources.ts
• helmResources parses merged defaults + overrides from the dry-run compose (helmValues) to extract top-level resources.requests, resources.limits, and model.gpuResource / model.gpus (plus pd.prefill / pd.decode GPU counts when pd.enabled is true).
• gpuRequestSummary combines the selected form.gpuResource / vendor default with helmValues / cluster perPod GPUs so the requested GPU resource appears cleanly as the top read-only row.
• resourceEditsFromLayer, applyResourceEdits, and dropClearedResources round-trip edits through form.resources -> overrides.resources, dropping cleared scalar overrides on upgrade while preserving explicit null deletions.
• useResourceRows drives ordered Resource | Request | Limit rows: effective defaults appear as Tab-acceptable placeholders (Suggest), custom rows suggest common keys (cpu, memory, ephemeral-storage, hugepages-2Mi, hugepages-1Gi, rdma/hca_shared), entering the
active GPU resource key (gpuReserved) or duplicate/existing keys is flagged inline, and hugepages-* without cpu/memory displays the Kubernetes / _pod.tpl compute hint.
2. Reused the existing open/refresh dry-run query — useImageSlots.ts
• previewForm strips resources overrides alongside images and edits so dry-run previews always reflect underlying chart/catalog/site defaults without extra /api/v2/compose calls.
• useImageSlots returns resources?: HelmResources alongside slots.
3. UI integration in both modules + i18n
• DeploySettings.tsx, Deploy.tsx, Upgrade.tsx: wired Form.resources, planRequest, formFromPlan, and the Resources row in Advanced right after GPU capacity.
• DeployForm.tsx, DeploySheet.tsx, en-US.json, zh-CN.json: added ResourceRows inside Resources and scheduling right after CapacityHint alongside GPU resource selection.
huskcass
left a comment
There was a problem hiding this comment.
No blockers. CI is green apart from publish, which is still pending. Checked at f211264.
Medium
- Overdesign in
swiss/lib/resources.ts.useResourceRowsmirrors draft rows into local state and keeps them in sync withvalueusinglastEmittedRef,prevBaseKeysRefand an effect that reseeds or filters the drafts. That is a lot of machinery for a small table. Hold the custom rows in the form as an ordered array and derive the edits from it when planning. That removes the refs and the effect, andreplaceCustomResources,customResourceRowsandclearResourceOverridemostly go with them. - Speculative extras that can be cut: the
COMMON_RESOURCE_KEYSdropdown plusSWISS_RESOURCE_LABELSandkeyChoicesFor, andneedsHugepageComputeHint, which is chart-internal knowledge copied into the UI. The issue asks for image, affinity and environment settings, not a hugepages assistant. - Duplicated logic in
pdRoles.ts.extractStandaloneGpuTermandextractAnyGpuProductswalk the same affinity tree with different filters.applyPdOverridescarries a long branch that rebuilds or nullsaffinityReplacefor the clear case. Writing the one role term and clearing it by removing that term would be much smaller. Several helpers (parseNonNegNumber,parsePosInt,hasAnyAffinityRule,expandProductValues,canonicalizeProducts) guard shapes that the dry-run output never produces. - The compose dry run used to be gated on opening Images. It now always runs once the form is seeded, and again on target changes. That is an extra compose call on every Deploy/Upgrade open. It matches the commit "dryRun moved to window first open", so confirm that is intended. The new header "Refresh" button on both routes is a second control that does the same thing as the old Images refresh.
Low
onRefresh ?? (() => {})inPdRolesRowshides a missing prop. Make it optional onCapacityLine, or make it required.resources.test.ts,pdRoles.test.tsandDeploySettings.pd.test.tsxadd about 700 lines, mostly testing the helpers listed above. They will shrink once the helpers do.- Custom rows whose key matches the GPU resource or a base key are dropped from the emitted edits without a trace. That is only visible as the inline warning while the row is on screen.
Solid
- Old behaviour is kept: images still go through the form layer,
dropClearedResourcesonly removes scalars the form owns, and colocate mode keeps the top-level scheduling. - The Images section moving into Advanced matches the issue.
Verdict: OK to merge as is. The Medium items are simplifications I would make before this grows further.
— Review Golden
Hold custom resource rows on the form as an ordered array and derive edits at plan time, dropping the draft-state sync. The custom-row key is a plain text input. PD affinity overrides now write or remove one role term. Capacity refresh is optional, and conflicting custom keys are kept in the edits with the existing inline warning. Co-authored-by: aceforeverd <11715200+aceforeverd@users.noreply.github.com>
huskcass
left a comment
There was a problem hiding this comment.
No blockers.
The previous Medium cuts landed: custom rows now live in the form as an ordered array (no draft state, refs or effect), the key dropdown, labels and hugepage hint are gone, pdRoles.ts reads affinity in one walk and the clear path just removes the role's term. expandProductValues/canonicalizeProducts are on the write path (applyPdOverrides), so keeping them is right. Conflicting custom rows are now kept with a warning.
- Low:
clearRoleGpuTermre-checksnodeAffinity/ required being maps afternodeSelectorTermsOfalready found terms; those two guards can go.formRoleGpuis a thin wrapper that can be inlined. - Low: custom rows use
key={i}; removing a middle row reuses the next row's inputs. Fine for controlled inputs, just noting it. - Low: dry run on first open plus the header Refresh is unchanged; fine as the intended behaviour.
Verdict: good to merge.
— Review Golden
modelsphere/modelsphere#57