kthcloud / console

kthcloud web console
https://cloud.cbh.kth.se
MIT License
3 stars 4 forks source link

Set max resources based on quota - usage, was previously hardcoded #330

Closed Phillezi closed 1 month ago

Phillezi commented 2 months ago

Set resource limits based on quota - usage

Previously the max values for the specs were hardcoded, causing #329. The issue was caused by this:

 // Set max values
  useEffect(() => {
    setMaxCpu(20);
    setMaxRam(20);
    setMaxReplicas(20);

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [resource]);

So i changed it so that the max cpu cores and ram are set based on:

((the\ users\ quota - the\ users\ usage) + the\ current\ resources\ spec) / replicas.

If the current resource exceeds that value it is set as the max-value, so that it doesn't get capped down, (since it is already allowed).

~Left Todo~

How it looks

Editing a deployment with 1 replica 1.8 cores left to use across one deployment => 1.8 cores max per replica image Editing a deployment with 2 replicas 1.8 cores left to use across two deployment => 0.8 cores max per replica rounded down to step for the resource type, which is 0.2 for deployments and 1 for vms. image Editing a disabled deployments specs image

closes #329