Skip to content
Merged
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
22 changes: 12 additions & 10 deletions docs/stack_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ spec:
object.
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
scheduleGroups:
description: |-
ScheduleGroups limits the schedule metric to the specified groups.
An empty list matches all groups for backwards compatibility.
items:
type: string
type: array
required:
- name
type: object
Expand Down Expand Up @@ -1991,11 +1998,6 @@ spec:
Note that this field cannot be set when spec.os.name is windows.
properties:
localhostProfile:
description: |-
Comment thread
mikkeloscar marked this conversation as resolved.
localhostProfile indicates a profile loaded on the node that should be used.
The profile must be preconfigured on the node to work.
Must match the loaded name of the profile.
Must be set if and only if type is "Localhost".
type: string
type:
type: string
Expand Down Expand Up @@ -3331,6 +3333,11 @@ spec:
Note that this field cannot be set when spec.os.name is windows.
properties:
localhostProfile:
description: |-
localhostProfile indicates a profile loaded on the node that should be used.
The profile must be preconfigured on the node to work.
Must match the loaded name of the profile.
Must be set if and only if type is "Localhost".
type: string
type:
type: string
Expand Down Expand Up @@ -4748,11 +4755,6 @@ spec:
Note that this field cannot be set when spec.os.name is windows.
properties:
localhostProfile:
description: |-
localhostProfile indicates a profile loaded on the node that should be used.
The profile must be preconfigured on the node to work.
Must match the loaded name of the profile.
Must be set if and only if type is "Localhost".
type: string
type:
type: string
Expand Down
32 changes: 17 additions & 15 deletions docs/stackset_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ spec:
object.
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
scheduleGroups:
description: |-
ScheduleGroups limits the schedule metric to the specified groups.
An empty list matches all groups for backwards compatibility.
items:
type: string
type: array
required:
- name
type: object
Expand Down Expand Up @@ -2384,11 +2391,6 @@ spec:
type: integer
service:
default: ""
description: |-
Service is the name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).

If this is not specified, the default behavior is defined by gRPC.
type: string
required:
- port
Expand Down Expand Up @@ -3303,11 +3305,6 @@ spec:
type: integer
service:
default: ""
description: |-
Service is the name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).

If this is not specified, the default behavior is defined by gRPC.
type: string
required:
- port
Expand Down Expand Up @@ -3724,6 +3721,11 @@ spec:
type: integer
service:
default: ""
description: |-
Service is the name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).

If this is not specified, the default behavior is defined by gRPC.
type: string
required:
- port
Expand Down Expand Up @@ -4499,11 +4501,6 @@ spec:
type: integer
service:
default: ""
description: |-
Service is the name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).

If this is not specified, the default behavior is defined by gRPC.
type: string
required:
- port
Expand Down Expand Up @@ -5155,6 +5152,11 @@ spec:
type: integer
service:
default: ""
description: |-
Service is the name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).

If this is not specified, the default behavior is defined by gRPC.
type: string
required:
- port
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/zalando.org/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ type MetricsClusterScalingSchedule struct {
// The name of the referenced ClusterScalingSchedule object.
// +kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
Name string `json:"name"`
// ScheduleGroups limits the schedule metric to the specified groups.
// An empty list matches all groups for backwards compatibility.
// +optional
ScheduleGroups []string `json:"scheduleGroups,omitempty"`
}

// MetricRequestsPerSecond specifies basic information to scale based on
Expand Down
7 changes: 6 additions & 1 deletion pkg/apis/zalando.org/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion pkg/core/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
sqsQueueNameTag = "queue-name"
sqsQueueRegionTag = "region"
scalingScheduleAPIVersion = "zalando.org/v1"
scheduleGroupLabel = "schedule-group"
)

var (
Expand Down Expand Up @@ -496,7 +497,18 @@ func clusterScalingScheduleMetric(metrics zv1.AutoscalerMetrics, stackName, name
return nil, errMissingClusterScalingScheduleName
}

return generateScalingScheduleMetricSpec("ClusterScalingSchedule", name, average), nil
metric := generateScalingScheduleMetricSpec("ClusterScalingSchedule", name, average)
if len(metrics.ClusterScalingSchedule.ScheduleGroups) > 0 {
values := append([]string(nil), metrics.ClusterScalingSchedule.ScheduleGroups...)
metric.Object.Metric.Selector = &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{{
Key: scheduleGroupLabel,
Operator: metav1.LabelSelectorOpIn,
Values: values,
}},
}
}
return metric, nil
}

func generateScalingScheduleMetricSpec(kind, name string, average resource.Quantity) *autoscaling.MetricSpec {
Expand Down
16 changes: 16 additions & 0 deletions pkg/core/autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,22 @@ func TestStackSetController_ReconcileAutoscalersScalingSchedule(t *testing.T) {
validateHpa(t, "ClusterScalingSchedule", ssc)
})

t.Run("generate ClusterScalingSchedule HPA with schedule groups", func(t *testing.T) {
ssc.Stack.Spec.StackSpec.Autoscaler.Metrics[0].ClusterScalingSchedule.ScheduleGroups = []string{
"load-test",
"cyber-week",
}
hpa, err := ssc.GenerateHPA()
require.NoError(t, err)
require.Len(t, hpa.Spec.Metrics, 1)
selector := hpa.Spec.Metrics[0].Object.Metric.Selector
require.NotNil(t, selector)
require.Equal(t, []metav1.LabelSelectorRequirement{{
Key: scheduleGroupLabel, Operator: metav1.LabelSelectorOpIn,
Values: []string{"load-test", "cyber-week"},
}}, selector.MatchExpressions)
})

}

func TestStackSetController_ReconcileAutoscalersExternalRPS(t *testing.T) {
Expand Down
Loading