feat: add pod clique pod index to pod names#634
Conversation
ab1c617 to
d161433
Compare
814344e to
02d199a
Compare
renormalize
left a comment
There was a problem hiding this comment.
Thanks for the PR! A few comments from me.
02d199a to
9a14940
Compare
renormalize
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments @steved!
The PR looks good now - just a couple nits. We can push this in once we have more approvals from reviewers.
Thanks for taking a look @renormalize! |
| if err := validatePodNameConstraints(v.pcs.Name, pcsgName, pclqName); err != nil { | ||
| maxPCLQReplicas := int32(1) | ||
| if templateSpec := componentutils.FindPodCliqueTemplateSpecByName(v.pcs, pclqName); templateSpec != nil { | ||
| maxPCLQReplicas = templateSpec.Spec.MaxReplicas() |
There was a problem hiding this comment.
If HPA is not used but lets say dynamo planner is used, then ScaleConfig is not set. This means that at best you will take template replicas. This is not an accurate representation of real time replicas since PCLQ and PCSG have their own Scale subresources and any scale-out will directly change the PCLQ and PCSG replicas and will never be reflected in PCS. So at best this check is only valuable when you solely look at PCS spec (using templates) - but with scale-outs this no longer provides any guard.
Therefore MaxReplicas name for the function is highly misleading - as it gives an impression that it always returns an accurate value during the lifetime of the PCS but that is not really true.
On top of that the doc string:
// MaxReplicas returns the maximum number of replicas for this PodClique.
is also very misleading.
| maxPCLQReplicas = templateSpec.Spec.MaxReplicas() | ||
| } | ||
|
|
||
| if err := validatePodNameConstraints(v.pcs.Name, v.pcs.Spec.Replicas, scalingGroupConfig.Name, scalingGroupConfig.MaxReplicas(), pclqName, maxPCLQReplicas); err != nil { |
There was a problem hiding this comment.
If you wish to keep this then clearly document that this is best-effort and pre-flight and does not reflect the current state of PCS and its constituent PCLQs and PCSGs.
|
|
||
| func validatePodResourceClaimReferenceNames(ownerName string, maxReplicas int32, refs []grovecorev1alpha1.ResourceSharingSpec, fldPath *field.Path) field.ErrorList { | ||
| allErrs := field.ErrorList{} | ||
| maxReplicaIndex := int(max(0, maxReplicas-1)) |
There was a problem hiding this comment.
maxReplicas is not the correct representation of what the actual max is. This value is solely derived from template spec.
| } | ||
|
|
||
| // MaxAllowedReplicas returns the maximum number of replicas that can be configured for this PodClique. | ||
| func (p *PodCliqueSpec) MaxAllowedReplicas() int32 { |
There was a problem hiding this comment.
Grove allows external pluggable horizontal autoscalers. ScaleConfig is only applicable when you wish to use HPA, otherwise this is not set (is nil). Dynamo uses planner to horizontally scale replicas. So in this case the max allowed will be limited by spec.Replicas which will not be correct.
There was a problem hiding this comment.
Just so I understand - theoretically, this is still accurate, but because we're not validating the PCLQ and /scale admission we're missing changes that are applied directly? Would you recommend we add validation to those admission paths?
There was a problem hiding this comment.
Bump @unmarshall if you have any thoughts, thanks!
| } | ||
|
|
||
| // MaxAllowedReplicas returns the maximum number of replicas that can be configured with this scaling group config. | ||
| func (p *PodCliqueScalingGroupConfig) MaxAllowedReplicas() int32 { |
What type of PR is this?
/kind feature
What this PR does / why we need it:
For better at-a-glance visibility, we'd like to encode the PCLQ pod index in the pod name.
Which issue(s) this PR fixes:
Fixes #635
Special notes for your reviewer:
GenerateNameand into Grove.Rather than appending a 5-char suffix, we can rely on the randomness of 3 characters since pod names can only conflict with their same index./scaleAPI callsDoes this PR introduce a API change?
Additional documentation e.g., enhancement proposals, usage docs, etc.:
N/A