@@ -101,14 +101,6 @@ sub latest_jobs ($self, $until = undef) {
101101 return @latest ;
102102}
103103
104- sub load_throttling_config ($config_string ) {
105- # convert in hash the prio_throttling_parameters string configured in openqa.ini
106- return unless ($config_string && $config_string =~ / :/ );
107- $config_string =~ s /\s +// g ;
108- my %hash = map { my ($k , $v ) = split /:/, $_ , 2 } split /,/, $config_string ;
109- return \%hash ;
110- }
111-
112104sub create_from_settings ($self , $settings , $scheduled_product_id = undef ) {
113105 my %settings = %$settings ;
114106 my %new_job_args ;
@@ -166,17 +158,21 @@ sub create_from_settings ($self, $settings, $scheduled_product_id = undef) {
166158 $new_job_args {priority } += $malus ;
167159 }
168160 }
169- my $throttling = OpenQA::App-> singleton-> config-> {misc_limits }-> {prio_throttling_parameters };
170- $throttling = load_throttling_config($throttling );
171161 # apply resources throttling control
172- if ($throttling ) {
162+ if (my $throttling = OpenQA::App-> singleton-> config-> {misc_limits }-> {prio_throttling_parameters }) {
163+ my $debug_msg_2 ;
173164 for my $resource (keys %$throttling ) {
174165 next if !defined $settings {$resource };
175- my $malus = int ($settings {$resource } * $throttling -> {$resource });
176- $debug_msg = sprintf ' Adding priority malus to newly created job due to %s (old: %d, malus: %s)' ,
177- $resource , $new_job_args {priority }, $malus ;
178- $new_job_args {priority } += $malus ;
166+ my $scale = $throttling -> {$resource }-> {scale };
167+ my $reference = $throttling -> {$resource }-> {reference };
168+ my $prio = int (($settings {$resource } - $reference ) * $scale );
169+ $debug_msg_2 .= sprintf " %s %s %s ;" ,
170+ $resource , " , scale:$scale " , ($reference ? " , reference:$reference " : ' ' );
171+ $new_job_args {priority } += $prio ;
179172 }
173+ $debug_msg .= sprintf (" \n Adjusting job priority by %s based on resource requirement(s):\n %s " ,
174+ $new_job_args {priority }, $debug_msg_2 )
175+ if $debug_msg_2 ;
180176 }
181177
182178 my $job = $self -> create(\%new_job_args );
0 commit comments