label-missed-slo.yml 907 Bytes
Newer Older
1 2 3
resource_rules:
  issues:
    rules:
Mark Fletcher's avatar
Mark Fletcher committed
4
      - name: Add missed slo label to bugs over SLO threshold
5 6 7 8 9
        conditions:
          state: opened
          labels:
            - bug
          forbidden_labels:
Mark Fletcher's avatar
Mark Fletcher committed
10
            - missed-SLO
11
          ruby: |
12
            severity_regex = /^severity::[12]$/
13

14 15 16
            severity_slo_map = {
              "severity::1": 30,
              "severity::2": 60
17 18
            }

19 20 21
            if resource[:labels].grep(severity_regex).present? && labels_chronologically.present?
              severity_label = labels_chronologically.reverse_each.find do |label|
                label.name.match?(severity_regex)
22 23
              end

24
              return false unless severity_label
25

26
              slo = severity_slo_map[severity_label.name.to_sym]
27

28
              severity_label.added_at < slo.days.ago
29 30 31
            end
        actions:
          labels:
Mark Fletcher's avatar
Mark Fletcher committed
32
            - missed-SLO