Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/controllers/cronfederatedhpa/cronfederatedhpa_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ func (c *ScalingJob) ScaleFHPA(cronFHPA *autoscalingv1alpha1.CronFederatedHPA) e
fhpa.Spec.MaxReplicas = *c.rule.TargetMaxReplicas
update = true
}
if c.rule.TargetMinReplicas != nil && *fhpa.Spec.MinReplicas != *c.rule.TargetMinReplicas {
*fhpa.Spec.MinReplicas = *c.rule.TargetMinReplicas
if c.rule.TargetMinReplicas != nil && (fhpa.Spec.MinReplicas == nil || *fhpa.Spec.MinReplicas != *c.rule.TargetMinReplicas) {
targetMinReplicas := *c.rule.TargetMinReplicas
fhpa.Spec.MinReplicas = &targetMinReplicas
update = true
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/controllers/cronfederatedhpa/cronfederatedhpa_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,31 @@ func TestScaleFHPA(t *testing.T) {
expectedUpdate: true,
expectedErr: false,
},
{
name: "Initialize Nil MinReplicas",
cronFHPA: &autoscalingv1alpha1.CronFederatedHPA{
ObjectMeta: metav1.ObjectMeta{
Name: "test-cron-fhpa",
Namespace: "default",
},
Spec: autoscalingv1alpha1.CronFederatedHPASpec{
ScaleTargetRef: autoscalingv2.CrossVersionObjectReference{
Name: "test-fhpa",
},
},
},
existingFHPA: &autoscalingv1alpha1.FederatedHPA{
ObjectMeta: metav1.ObjectMeta{
Name: "test-fhpa",
Namespace: "default",
},
},
rule: autoscalingv1alpha1.CronFederatedHPARule{
TargetMinReplicas: new(int32(3)),
},
expectedUpdate: true,
expectedErr: false,
},
{
name: "No Updates Needed",
cronFHPA: &autoscalingv1alpha1.CronFederatedHPA{
Expand Down