-
Notifications
You must be signed in to change notification settings - Fork 100
fix: add CPU field to resolvedOfferings and change QuotaRequests to use resolvedOfferings #2462
Conversation
This will have overlap with #2454. I will merge that one first but want to open this up for review. |
pkg/controller/appdefinition/testdata/computeclass/all-set/existing.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 quick comment but otherwise LGTM
min: 100Mi # 1Mi | ||
max: 200Mi # 2Mi | ||
default: 100Mi # 1Mi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the comments here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resolved offerings get recalculated only when the app's generation changes. I believe that means that, after this change goes in, there will be apps that don't have CPUScaler
(because it is being removed) nor CPU
(because it's not being set). Are we OK with this? Should we handle this case?
pkg/controller/quota/quota.go
Outdated
quotaRequest.Spec.Resources.CPU.Add(cpu) | ||
quotaRequest.Spec.Resources.Memory.Add(memory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: cal we use the Mul
method here instead of this loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, that change logic is being done in a different PR.
The resolvedOfferings CPUScaler is currently not utilized anywhere in our codebase, including any dependencies of runtime. Therefore, removing it will have no impact on existing applications. It's worth noting that while there will be instances where resolvedOfferings.CPU is not set for an application, this is acceptable because the scheduling section will ensure the retention of the previously defined request. Once that application updates it will go through the process of getting resolvedOfferings.CPU instead. |
b74db86
to
9926d71
Compare
…se resolvedOfferings This change makes it so that we always quota against the resolvedOfferings instead of the scheduling for the app. This is because the scheduling for the app is always accurate to what is actually running, but the resolvedOfferings is what the user requested. This change also adds a CPU field to the resolvedOfferings so that we can quota against the CPU that the user requested from one place instead of having to calculate it from the cpuScaler. Signed-off-by: tylerslaton <[email protected]>
quotaRequest.Spec.Resources.Memory.Add(requirements.Requests["memory"]) | ||
} | ||
// Multiply the memory/cpu requests by the scale of the container | ||
cpu.Mul(replicas(container.Scale)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously in the ComputeClass quota PR but I just brought it here instead.
Forgive me if my memory is failing, but even though I previously approved this PR, I find this choice confusing. I think it makes the most sense to just continue using the |
This all revolves around a recent field addition that we made to defining memory in ComputeClasses,
I added this mainly since it is nicer to have |
Thanks for the explanation. That makes sense now. Idk why I got so confused on Saturday lol. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One non-blocking question.
CPUScaler: appInstance.Status.ResolvedOfferings.Containers[""].CPUScaler, | ||
Class: appInstance.Status.ResolvedOfferings.Containers[""].Class, | ||
Memory: appInstance.Spec.Memory[""], | ||
CPU: z.Pointer(cpuQuantity.MilliValue()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious: is there a behavioral difference between nil
and a pointer to a zero value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline. This reflects a weirder issue in quota. I'm going to make an issue for that, merge this, and come back to fix what this points to.
This PR adjusts two main things.
cpuScaler
field from ResolvedOfferings in favor of a newcpu
field.These two things are necessary for ComputeClasses that define a requestScaler on memory as we want to quota against the requested amount, not the incoming scaled down amount.
Checklist
This is a title (#1216)
. Here's an example