Do not apply cost factor discount on Win/Mac runners
Problem
Since Backend: Set OSS plan cost factor to .5 (!93046 - merged) our algorithm that selects the cost factor for a build uses the lowest cost factor based on some applicable conditions:
def for_project(project)
return DISABLED unless @runner_matcher.instance_type?
return DISABLED unless project.ci_minutes_usage.limit_enabled?
cost_factors = [for_visibility(project.visibility_level)]
cost_factors << PUBLIC_OPEN_SOURCE if public_open_source?(project)
cost_factors.min
end
This algorithm will need to take in consideration new special shared runners like Windows and MacOS runners. These shared runners should have cost factors public_projects_minutes_cost_factor
and private_projects_minutes_cost_factor
both greater than 1
(our standard cost factor for Linux runners), since those are more expensive runners.
Since we always select the lowest applicable cost factor we should make these special runners (with cost factor >1) not eligible for this discount.
Proposal
Example:
- A public project on Open Source plan could use a cost factor
PUBLIC_OPEN_SOURCE: 0.5
when using standard Linux runners. If the project uses Windows runners we should not apply the discount.
STANDARD = 1
def for_project(project)
return DISABLED unless @runner_matcher.instance_type?
return DISABLED unless project.ci_minutes_usage.limit_enabled?
runner_cost_factor = for_visibility(project.visibility_level)
return runner_cost_factor unless eligible_for_discount?(runner_cost_factor)
cost_factors = [runner_cost_factor]
cost_factors << PUBLIC_OPEN_SOURCE if public_open_source?(project)
cost_factors.min
end
def eligible_for_discount?(runner_cost_factor)
runner_cost_factor <= STANDARD
end