Skip to content

Commit 8e87f46

Browse files
feat: Add fallback option when Jira exporter can not determine application (#998)
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
1 parent 4acda1d commit 8e87f46

19 files changed

Lines changed: 92 additions & 54 deletions

File tree

charts/operators/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ type: application
1414

1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
17-
version: 2.0.10-rc.5
17+
version: 2.0.10-rc.6

charts/pelorus/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: exporters
33
repository: file://./charts/exporters
4-
version: 2.0.10-rc.5
5-
digest: sha256:81bd39a2f18c82e32cf006453b20b0e7bb16b343b10e48a196d480463973ef68
6-
generated: "2023-05-15T16:12:35.760966639+02:00"
4+
version: 2.0.10-rc.6
5+
digest: sha256:cb161faa5586bbb5112e63c731f0178f1d611529687225eb570ae1a49c1e6bd6
6+
generated: "2023-05-31T09:55:35.954667465-03:00"

charts/pelorus/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ type: application
1414

1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
17-
version: 2.0.10-rc.5
17+
version: 2.0.10-rc.6
1818

1919
dependencies:
2020
- name: exporters
21-
version: 2.0.10-rc.5
21+
version: 2.0.10-rc.6
2222
repository: file://./charts/exporters

charts/pelorus/charts/exporters/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ type: application
1414

1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
17-
version: 2.0.10-rc.5
17+
version: 2.0.10-rc.6

charts/pelorus/charts/exporters/templates/_deploymentconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ spec:
6060

6161
{{- if and (not .source_ref) (not .source_url) }}
6262
- name: PELORUS_IMAGE_TAG
63-
value: {{ .app_name }}:{{ .image_tag | default "v2.0.10-rc.5" }}
63+
value: {{ .app_name }}:{{ .image_tag | default "v2.0.10-rc.6" }}
6464
{{- end }}
6565

6666
{{- if .extraEnv }}

charts/pelorus/charts/exporters/templates/_imagestream_from_image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
name: {{ .image_name }}:{{ .image_tag | default "latest" }}
2424
{{- end }}
2525
{{- else }}
26-
name: quay.io/pelorus/pelorus-{{ .exporter_type }}-exporter:{{ .image_tag | default "v2.0.10-rc.5" }}
26+
name: quay.io/pelorus/pelorus-{{ .exporter_type }}-exporter:{{ .image_tag | default "v2.0.10-rc.6" }}
2727
# .image_name
2828
{{- end }}
2929
name: {{ .image_tag | default "stable" }}

docs/GettingStarted/configuration/ExporterFailure.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ This is the list of options that can be applied to `env_from_secrets`, `env_from
5656
| [API_USER](#api_user) | no | - |
5757
| [TOKEN](#token) | yes | - |
5858
| [APP_LABEL](#app_label) | no | `app.kubernetes.io/name` |
59+
| [APP_NAME](#app_name) | no | - |
5960
| [APP_FIELD](#app_field) | no | `u_application` |
6061
| [PROJECTS](#projects) | no | - |
6162
| [PELORUS_DEFAULT_KEYWORD](#pelorus_default_keyword) | no | `default` |
@@ -117,6 +118,14 @@ This is the list of options that can be applied to `env_from_secrets`, `env_from
117118

118119
: Changes the label used to identify applications.
119120

121+
###### APP_NAME
122+
123+
- **Required:** no
124+
- Only applicable for [PROVIDER](#provider) set to `jira`
125+
- **Type:** string
126+
127+
: Set fallback option when Jira exporter can not determine application related to collected issues. Otherwise, applications that can not be determined from issues are stored as `unknown` and do not appear in Grafana dashboards.
128+
120129
###### APP_FIELD
121130

122131
- **Required:** no

exporters/failure/collector_jira.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class JiraFailureCollector(AbstractFailureCollector):
8888

8989
query_result_fields_string: str = field(default=QUERY_RESULT_FIELDS, init=False)
9090

91+
app_name: Optional[str] = field(default=None, metadata=env_vars("APP_NAME"))
92+
9193
def __attrs_post_init__(self):
9294
# Do not mix projects with custom JQL query
9395
# Gather all fields and projects
@@ -279,4 +281,6 @@ def get_app_name(self, issue: Issue) -> str:
279281
matcher = f"{self.app_label}="
280282
if label.startswith(matcher):
281283
return label.replace(matcher, "")
282-
return "unknown"
284+
if self.app_name is None:
285+
return "unknown"
286+
return self.app_name

exporters/tests/test_failure_exporter.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ def setup_jira_collector(
4343
token: str = "WIEds4uZHiCGnrtmgQPn9E7D",
4444
projects: Optional[str] = None,
4545
jql_query_string: str = DEFAULT_JQL_SEARCH_QUERY,
46+
app_name: Optional[str] = None,
4647
) -> JiraFailureCollector:
4748
return JiraFailureCollector(
4849
tracker_api=JIRA_SERVER,
4950
username=username,
5051
token=token,
5152
projects=projects,
5253
jql_query_string=jql_query_string,
54+
app_name=app_name,
5355
)
5456

5557

@@ -77,6 +79,28 @@ def test_jira_search_with_projects(projects):
7779

7880
assert context is None
7981
assert len(issues) == 103
82+
assert len([issue for issue in issues if issue.app == "unknown"]) == 4
83+
84+
85+
@pytest.mark.integration
86+
@pytest.mark.skipif(
87+
not JIRA_USERNAME, reason="No Jira username set, run export JIRA_USERNAME=username"
88+
)
89+
@pytest.mark.skipif(
90+
not JIRA_TOKEN, reason="No Jira token set, run export JIRA_TOKEN=token"
91+
)
92+
def test_jira_search_with_app_name():
93+
collector = setup_jira_collector(
94+
JIRA_USERNAME, JIRA_TOKEN, projects="Test", app_name="robotron"
95+
)
96+
97+
with nullcontext() as context:
98+
issues = collector.search_issues()
99+
100+
assert context is None
101+
assert len(issues) == 103
102+
assert len([issue for issue in issues if issue.app == "unknown"]) == 0
103+
assert len([issue for issue in issues if issue.app == "robotron"]) == 4
80104

81105

82106
@pytest.mark.parametrize(
@@ -126,6 +150,7 @@ def test_jira_search_with_jql(jql):
126150

127151
assert context is None
128152
assert len(issues) == 103
153+
assert len([issue for issue in issues if issue.app == "unknown"]) == 4
129154

130155

131156
@pytest.mark.parametrize(

pelorus-operator/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.7-rc.5
6+
VERSION ?= 0.0.7-rc.6
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")

0 commit comments

Comments
 (0)