turbonomic / kubeturbo

140 stars 75 forks source link

[TRB-45953]: Updated SLO policy logic to revert to default values when min replicas > max #939

Closed amd-ibm closed 1 year ago

amd-ibm commented 1 year ago

Intent

Revert min/max replicas to the default values when the SLOHorizontalScale policy defines the min as greater than the max.

Background

Older versions of Kubernetes do not support the new x-kubernetes-validations validation rules that all use to ensure that the minReplicas are less than or equal to the the maxReplicas on the SLOHorizontalScale CR. For those older versions, we will revert to the default values (as if the user had not specified them on the CR) and log a warning.

Testing

Debugged kubeturbo locally against appliance.

Deployed the following SLOHorizontalScale CR to test the updated logic:

apiVersion: policy.turbonomic.io/v1alpha1
kind: SLOHorizontalScale
metadata:
  name: slo-horizontal-scale-sample
spec:
  minReplicas: 10
  maxReplicas: 1
  objectives:
    - name: ResponseTime
      value: 300
    - name: Transaction
      value: 20
  behavior:
    scaleUp: Automatic
    scaleDown: Disabled

Verified that the logs warn that the values were "invalid" and it is reverting to the defaults: Screenshot 2023-09-06 at 3 32 15 PM

Verified that the policy displayed in the UI also displays the defaults: Screenshot 2023-09-06 at 3 33 27 PM

Added unit tests for updated methods.

Checklist

These are the items that must be done by the developer and by reviewers before the change is ready to merge. Please strikeout any items that are not applicable, but don't delete them

Audience

@libai98 @ading1977 @KevinWang0204