Skip to content

Commit 0e51d4d

Browse files
authored
Limit action customization to step functions and remove notion of "custom actions" (#591)
Ref #544 * Add model for ActionParams * Pass `ActionParams` directly to default action and step functions * Create model for ActionSteps Use step model to provide defaults * Remove notion of custom actions Now, we only allow customization through action steps * Update documentation * Remove required_jira_permissions property Since all projects use the default action now, required Jira permissions aren't unique per project * Use `responses` for all Jira service tests * Add ADR 2 * Remove `BugzillaWebhookAttachment` model
1 parent e8b6c4a commit 0e51d4d

24 files changed

+673
-783
lines changed

config/config.prod.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
- whiteboard_tag: addons
44
bugzilla_user_id: tbd
55
description: Addons whiteboard tag for AMO Team
6-
# module: jbi.actions.default
76
parameters:
87
jira_project_key: WEBEXT
98
labels_brackets: both

docs/actions.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Action
2-
The system reads the actions configuration from a YAML file, one per environment. Each entry controls the synchronization between Bugzilla tickets and the Jira issues.
2+
The system reads the action configurations from a YAML file, one per environment. Each entry controls the synchronization between Bugzilla tickets and Jira issues.
33

44
## Configuration
55

6-
Below is a full example of an action configuration:
6+
Below is an example of an action configuration:
77
```yaml
88
- whiteboard_tag: example
99
bugzilla_user_id: 514230
1010
description: example configuration
11-
module: jbi.actions.default
1211
parameters:
1312
jira_project_key: EXMPL
1413
```
@@ -28,33 +27,19 @@ A bit more about the different fields...
2827
- bool [true, false]
2928
- default: true
3029
- If false, matching events will not be synchronized
31-
- `module` (optional)
32-
- string
33-
- default: [jbi.actions.default](jbi/actions/default.py)
34-
- The specified Python module must be available in the `PYTHONPATH`
3530
- `parameters` (optional)
36-
- dict
37-
- default: {}
38-
- The parameters will be validated to ensure the selected action accepts the specified values
31+
- `ActionParams`
32+
- The parameters passed to step functions when the action is run (see below)
3933

4034

4135
[View 'nonprod' configurations here.](../config/config.nonprod.yaml)
4236

4337
[View 'prod' configurations here.](../config/config.prod.yaml)
4438

4539

46-
## Available Actions
47-
48-
### Default
49-
The `jbi.actions.default` action will take the list of steps to be executed when
50-
the Webhook is received from configuration.
51-
When none is specified, it will create or update the Jira issue, publish comments when
52-
assignee, status, or resolution are changed, or when a comment is posted on the Bugzilla ticket.
40+
### Parameters
5341

54-
It will also set the Jira issue URL in the Bugzilla bug `see_also` field, and add a link
55-
to the Bugzilla ticket on the Jira issue.
56-
57-
**Parameters**
42+
Parameters are used by `step` functions to control what Bugzilla data is synced with Jira issues. Possible parameters are:
5843

5944
- `jira_project_key` (**mandatory**)
6045
- string
@@ -88,13 +73,12 @@ Minimal configuration:
8873
jira_project_key: EXMPL
8974
```
9075

91-
Full configuration, that will set assignee, change the Jira issue status and resolution.
76+
A configuration that will set an assignee and change the Jira issue status and resolution.
9277

9378
```yaml
9479
- whiteboard_tag: fidefe
9580
bugzilla_user_id: 514230
9681
description: full configuration
97-
module: jbi.actions.default
9882
parameters:
9983
jira_project_key: FIDEFE
10084
steps:
@@ -159,6 +143,3 @@ linked Jira issue status to "Closed". If the bug changes to a status not listed
159143
- `sync_whiteboard_labels`
160144
- `maybe_update_components`: looks at the component that's set on the bug (if any) and any components added to the project configuration with the `jira_components` parameter (see above). If those components are available on the Jira side as well, they're added to the Jira issue
161145

162-
### Custom Actions
163-
164-
If you're looking for a unique capability for your team's data flow, you can add your own Python methods and functionality[...read more here.](../jbi/actions/README.md)

docs/adrs/002-action-customizaiton.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Restrict Workflow Customization and Validate Default Action Parameters
2+
3+
- Status: Accepted
4+
- Date: 2023-06-23
5+
6+
Tracking issue: [#544](https://github.com/mozilla/jira-bugzilla-integration/issues/544)
7+
8+
## Context and Problem Statement
9+
10+
When JBI was first designed, we envisioned a scenario where a user might want to contribute a Python module to create an entirely custom sync workflow. As we've continued to make workflow customization easier, we've questioned whether this freedom of customization is worth the added complexity of supporting custom modules and action parameters.
11+
12+
## Decision Drivers
13+
14+
- Reduce complexity in handling custom modules
15+
- Prevent bugs due to misconfigured workflows
16+
- Align with the evolved designs that emphasize customization through combining steps
17+
18+
## Considered Options
19+
20+
- Option 1: Maintain the ability to customize workflows through custom modules and parameters
21+
- Option 2: Restrict customization to the default action and validate action parameters with a schema
22+
23+
## Decision Outcome
24+
25+
Considering the positive consequences of Option 2 and the fact that workflow customization is still possible through action steps, it is reasonable to choose Option 2 to simplify workflow customization and focus on improving the reliability and robustness of a single action.
26+
27+
## Pros and Cons of the Options
28+
29+
### Option 1: Maintain the ability to customize workflows through custom modules and parameters
30+
31+
- Good, because it provides flexibility for users to create entirely custom action workflows
32+
- Bad, because it increases complexity in handling different parameter structures and custom module configurations
33+
34+
### Option 2: Restrict customization to the default action and enforce parameters with a schema
35+
36+
- Good, because it validates that configured parameters are useable by step functions
37+
- Good, because we can safely assume that action parameters are of a certain type
38+
- Good, because it aligns with the evolved designs that emphasize customization through action steps
39+
40+
Option 2 also still provides plenty of freedom to customize an action workflow. One can
41+
simply supply one large function that contains all of the logic of that action, e.g.
42+
43+
```yaml
44+
parameters:
45+
jira_project_key: FIDEFE
46+
steps:
47+
new:
48+
- my_giant_big_step
49+
existing:
50+
- my_giant_big_step
51+
```
52+
53+
While this is perhaps less "elegant" than the module-based approached, it still provides an equivalent amount of customization.

docs/deployment.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ GET /whiteboard_tags/
5252
"bugzilla_user_id": 514230,
5353
"description": "Addons whiteboard tag for AMO Team",
5454
"enabled": true,
55-
"module": "jbi.actions.default",
5655
"parameters": {
5756
"jira_project_key": "WEBEXT"
5857
}

jbi/actions/README.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

jbi/actions/__init__.py

Whitespace-only changes.

jbi/actions/default.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

jbi/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def traces_sampler(sampling_context: dict[str, Any]) -> float:
3939

4040
app = FastAPI(
4141
title="Jira Bugzilla Integration (JBI)",
42-
description="Platform providing default and customized synchronization for bugzilla bugs.",
42+
description="Platform providing synchronization of Bugzilla bugs to Jira issues.",
4343
version=version_info["version"],
4444
debug=settings.app_debug,
4545
)

0 commit comments

Comments
 (0)