Skip to content

Commit a7eca8f

Browse files
committed
guarantee added
Signed-off-by: Shrutim1505 <shrutimurthy2103@gmail.com>
1 parent 41e7b56 commit a7eca8f

File tree

2 files changed

+61
-430
lines changed

2 files changed

+61
-430
lines changed

frontend/src/components/CreateDialog.jsx

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const CreateDialog = ({
3131
name: "",
3232
weight: "",
3333
reclaimable: true,
34-
guaranteed: { cpu: "", memory: "", scalars: [] },
34+
guarantee: { cpu: "", memory: "", scalars: [] },
3535
capability: { cpu: "", memory: "", scalars: [] },
3636
deserved: { cpu: "", memory: "", scalars: [] },
3737
// Pod-specific fields
@@ -175,25 +175,64 @@ const CreateDialog = ({
175175
reclaimable: queueData.reclaimable,
176176
};
177177

178-
["guaranteed", "capability", "deserved"].forEach((section) => {
179-
const cpu = queueData[section].cpu.trim();
180-
const memory = queueData[section].memory.trim();
181-
const scalars = queueData[section].scalars || [];
182-
const hasStandard = cpu || memory;
183-
const hasScalars = scalars.some(
184-
({ key, value }) => key.trim() && value.trim(),
185-
);
186-
if (hasStandard || hasScalars) {
187-
specSection[section] = {};
188-
if (cpu) specSection[section].cpu = cpu;
189-
if (memory) specSection[section].memory = memory;
190-
scalars.forEach(({ key, value }) => {
191-
if (key.trim() && value.trim()) {
192-
specSection[section][key.trim()] = value.trim();
193-
}
194-
});
195-
}
196-
});
178+
// Handle guarantee (must be nested under resource)
179+
const guaranteeCpu = queueData.guarantee.cpu.trim();
180+
const guaranteeMemory = queueData.guarantee.memory.trim();
181+
const guaranteeScalars = queueData.guarantee.scalars || [];
182+
const hasGuaranteeStandard = guaranteeCpu || guaranteeMemory;
183+
const hasGuaranteeScalars = guaranteeScalars.some(
184+
({ key, value }) => key.trim() && value.trim(),
185+
);
186+
if (hasGuaranteeStandard || hasGuaranteeScalars) {
187+
specSection.guarantee = { resource: {} };
188+
if (guaranteeCpu) specSection.guarantee.resource.cpu = guaranteeCpu;
189+
if (guaranteeMemory)
190+
specSection.guarantee.resource.memory = guaranteeMemory;
191+
guaranteeScalars.forEach(({ key, value }) => {
192+
if (key.trim() && value.trim()) {
193+
specSection.guarantee.resource[key.trim()] = value.trim();
194+
}
195+
});
196+
}
197+
198+
// Handle capability (flattened, not under resource)
199+
const capabilityCpu = queueData.capability.cpu.trim();
200+
const capabilityMemory = queueData.capability.memory.trim();
201+
const capabilityScalars = queueData.capability.scalars || [];
202+
const hasCapabilityStandard = capabilityCpu || capabilityMemory;
203+
const hasCapabilityScalars = capabilityScalars.some(
204+
({ key, value }) => key.trim() && value.trim(),
205+
);
206+
if (hasCapabilityStandard || hasCapabilityScalars) {
207+
specSection.capability = {};
208+
if (capabilityCpu) specSection.capability.cpu = capabilityCpu;
209+
if (capabilityMemory)
210+
specSection.capability.memory = capabilityMemory;
211+
capabilityScalars.forEach(({ key, value }) => {
212+
if (key.trim() && value.trim()) {
213+
specSection.capability[key.trim()] = value.trim();
214+
}
215+
});
216+
}
217+
218+
// Handle deserved (flattened, not under resource)
219+
const deservedCpu = queueData.deserved.cpu.trim();
220+
const deservedMemory = queueData.deserved.memory.trim();
221+
const deservedScalars = queueData.deserved.scalars || [];
222+
const hasDeservedStandard = deservedCpu || deservedMemory;
223+
const hasDeservedScalars = deservedScalars.some(
224+
({ key, value }) => key.trim() && value.trim(),
225+
);
226+
if (hasDeservedStandard || hasDeservedScalars) {
227+
specSection.deserved = {};
228+
if (deservedCpu) specSection.deserved.cpu = deservedCpu;
229+
if (deservedMemory) specSection.deserved.memory = deservedMemory;
230+
deservedScalars.forEach(({ key, value }) => {
231+
if (key.trim() && value.trim()) {
232+
specSection.deserved[key.trim()] = value.trim();
233+
}
234+
});
235+
}
197236

198237
return {
199238
apiVersion: "scheduling.volcano.sh/v1beta1",
@@ -220,7 +259,7 @@ const CreateDialog = ({
220259
name: "",
221260
weight: "",
222261
reclaimable: false,
223-
guaranteed: { cpu: "", memory: "", scalars: [] },
262+
guarantee: { cpu: "", memory: "", scalars: [] },
224263
capability: { cpu: "", memory: "", scalars: [] },
225264
deserved: { cpu: "", memory: "", scalars: [] },
226265
namespace: "default",
@@ -454,9 +493,7 @@ const CreateDialog = ({
454493
{errors.reclaimable}
455494
</Typography>
456495
)}
457-
{["guaranteed", "capability", "deserved"].map(
458-
renderResourceSection,
459-
)}
496+
{["guarantee", "capability", "deserved"].map(renderResourceSection)}
460497
</>
461498
);
462499

0 commit comments

Comments
 (0)