Skip to content

Commit

Permalink
Jsonnet: change newResourceScaledObject() signature to allow to pass …
Browse files Browse the repository at this point in the history
…extra_matchers instead of pod_regex (#9920)

Signed-off-by: Marco Pracucci <[email protected]>
  • Loading branch information
pracucci authored Nov 15, 2024
1 parent 6ca9c52 commit f505b0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mimir {
with_ready_trigger=with_ready_trigger,
weight=weight,
container_name=container,
pod_regex=pod_regex
extra_matchers=(if pod_regex != '' then 'pod=~"%s"' % pod_regex else '')
)
for with_cortex_prefix in [false, true]
for with_ready_trigger in [false, true]
Expand Down
18 changes: 10 additions & 8 deletions operations/mimir/autoscaling.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@
scale_down_period=null,
extra_triggers=[],
container_name='',
pod_regex='',
extra_matchers='',
):: self.newScaledObject(
name, $._config.namespace, {
local queryParameters = {
container: if container_name != '' then container_name else name,
namespace: $._config.namespace,
extra_matchers: if pod_regex == '' then '' else ',pod=~"%s"' % pod_regex,
extra_matchers: if extra_matchers == '' then '' else ',%s' % extra_matchers,
},

min_replica_count: replicasWithWeight(min_replicas, weight),
Expand Down Expand Up @@ -569,7 +569,7 @@
{}
),

newDistributorScaledObject(name, pod_regex='')::
newDistributorScaledObject(name, extra_matchers='')::
$.newResourceScaledObject(
name=name,
container_name='distributor',
Expand All @@ -581,7 +581,7 @@
memory_target_utilization=$._config.autoscaling_distributor_memory_target_utilization,
with_cortex_prefix=true,
with_ready_trigger=true,
pod_regex=pod_regex,
extra_matchers=extra_matchers,
) + (
{
spec+: {
Expand Down Expand Up @@ -644,31 +644,33 @@
local isDistributorAutoscalingZoneCEnabled = isDistributorMultiZoneEnabled && isDistributorAutoscalingEnabled && std.length($._config.multi_zone_availability_zones) >= 3,

distributor_scaled_object: if !isDistributorAutoscalingSingleZoneEnabled then null else
$.newDistributorScaledObject('distributor'),
// When both single-zone and multi-zone coexists, the single-zone scaling metrics shouldn't
// match the multi-zone pods.
$.newDistributorScaledObject('distributor', extra_matchers=(if isDistributorMultiZoneEnabled then 'pod!~"distributor-zone.*"' else '')),

distributor_deployment: overrideSuperIfExists(
'distributor_deployment',
if !isDistributorAutoscalingSingleZoneEnabled then {} else $.removeReplicasFromSpec
),

distributor_zone_a_scaled_object: if !isDistributorAutoscalingZoneAEnabled then null else
$.newDistributorScaledObject('distributor-zone-a', 'distributor-zone-a.*'),
$.newDistributorScaledObject('distributor-zone-a', 'pod=~"distributor-zone-a.*"'),

distributor_zone_a_deployment: overrideSuperIfExists(
'distributor_zone_a_deployment',
if !isDistributorAutoscalingZoneAEnabled then {} else $.removeReplicasFromSpec
),

distributor_zone_b_scaled_object: if !isDistributorAutoscalingZoneBEnabled then null else
$.newDistributorScaledObject('distributor-zone-b', 'distributor-zone-b.*'),
$.newDistributorScaledObject('distributor-zone-b', 'pod=~"distributor-zone-b.*"'),

distributor_zone_b_deployment: overrideSuperIfExists(
'distributor_zone_b_deployment',
if !isDistributorAutoscalingZoneBEnabled then {} else $.removeReplicasFromSpec
),

distributor_zone_c_scaled_object: if !isDistributorAutoscalingZoneCEnabled then null else
$.newDistributorScaledObject('distributor-zone-c', 'distributor-zone-c.*'),
$.newDistributorScaledObject('distributor-zone-c', 'pod=~"distributor-zone-c.*"'),

distributor_zone_c_deployment: overrideSuperIfExists(
'distributor_zone_c_deployment',
Expand Down

0 comments on commit f505b0d

Please sign in to comment.