Migrate shared runner minutes to separate table

This MR fixes the problem with resetting the quota, but this solution is suboptimal: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2275.

We should create a new table which would hold runner quotas (for groups and jobs) per-month and instead of "deleteing"/"resetting" just append a new data to the table.

Proposal

Create two tables:

group_shared_runner_minutes:
 - group_id: integer
 - year: integer,
 - month: integer,
 - minutes: integer

project_shared_runner_minutes:
 - project_id: integer
 - year: integer,
 - month: integer,
 - minutes: integer

We would key the group minutes by: group_id, year, month of time when we check the limits.

We should have an index on project_id and project_id+year+month.

We should add a cron job run monthly that would evict data older than 12 months. Effectively it is the change of ClearSharedRunnerMinutesWorker behaviour.

Edited Jun 29, 2017 by Kamil Trzciński
Assignee Loading
Time tracking Loading