@@ -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 ;
@@ -167,16 +159,19 @@ sub create_from_settings ($self, $settings, $scheduled_product_id = undef) {
167159 }
168160 }
169161 my $throttling = OpenQA::App-> singleton-> config-> {misc_limits }-> {prio_throttling_parameters };
170- $throttling = load_throttling_config($throttling );
171162 # apply resources throttling control
172- if ($throttling ) {
163+ if ($throttling ref eq ' HASH' ) {
164+ my $debug_msg_2 ;
173165 for my $resource (keys %$throttling ) {
174166 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 ;
167+ my $prio
168+ = int (( $settings { $resource } - $throttling -> { $resource } -> { reference }) * $throttling -> { $resource } -> { scale });
169+ $debug_msg_2 .= sprintf ' %s, scale: %s; ' , $resource , $prio ;
170+ $new_job_args {priority } += $prio ;
179171 }
172+ $debug_msg .= sprintf (' \nAdding priority scale to base prio %s of the job due to:\n %s' ,
173+ $new_job_args {priority }, $debug_msg_2 )
174+ if $debug_msg_2 ;
180175 }
181176
182177 my $job = $self -> create(\%new_job_args );
0 commit comments