-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notification Support for Workflow Approval Nodes #4657
Notification Support for Workflow Approval Nodes #4657
Conversation
Build failed.
|
Build failed.
|
Build failed.
|
Build failed.
|
7e08bfc
to
93831b4
Compare
Build failed.
|
93831b4
to
570aa1e
Compare
Build succeeded.
|
Build succeeded.
|
Build failed.
|
recheck |
migrations.AlterField( | ||
model_name='workflowjobnode', | ||
name='do_not_run', | ||
field=models.BooleanField(default=False, help_text='Indicates that a job will not be created when True. Workflow runtime semantics will mark this True if the node is in a path that will decidedly not be ran. A value of False means the node may not run.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anybody else notices this, looks like it's just a help_text
typo.
Build succeeded.
|
awx/main/models/workflow.py
Outdated
.filter(unifiedjobtemplate_notification_templates_for_approvals__in=[self])) | ||
# Get Organization NotificationTemplates | ||
if self.organization is not None: | ||
error_notification_templates = set(error_notification_templates + list(base_notification_templates.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this commit, it looks like the failure
, success
, and started
notification templates for workflows don't inherit from the Organization. Maybe that could be considered a bug (cc @AlanCoding @wenottingham)? I think for the purposes of this PR, though, we probably don't want to introduce that behavioral change.
We do, however, want to keep the line you added for inheriting approval notifications from the org because that is something we've explicitly said we want to support w/ this new feature:
approval_notification_templates = set(
approval_notification_templates + list(base_notification_templates.filter(
# etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this commit, it looks like the failure, success, and started notification templates for workflows don't inherit from the Organization. Maybe that could be considered a bug
fwiw, sounds like a bug to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that without the
error_notification_templates = set(error_notification_templates + list(base_notification_templates.filter(
organization_notification_templates_for_errors=self.organization)))
started_notification_templates = set(started_notification_templates + list(base_notification_templates.filter(
organization_notification_templates_for_started=self.organization)))
success_notification_templates = set(success_notification_templates + list(base_notification_templates.filter(
organization_notification_templates_for_success=self.organization)))
code, the "start" "success" and "error" notifications do NOT send on an org level. Will fix this bug in a separate PR, per discussion above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matburt @wenottingham can you confirm that this is a bug, or is there a reason for this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for workflows with an explicit org? It would appear to be a bug for that case, but I also believe you can still have orgless workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we think we've discovered that WFJTs w/ an explicit org will not inherit Notification Templates from that org (at all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def send_approval_notification(self, status): | ||
from awx.main.tasks import send_notifications # avoid circular import | ||
if self.workflow_job_template is None: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good idea
subject.append((' was denied. {}').format(workflow_url)) | ||
subject = " ".join(subject) | ||
body = self.notification_data() | ||
body['body'] = subject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me 👍 @jladdjr you have any other thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryanpetrello - @beeankha and I took a look at this last week - this looks like it's doing the right thing 👍
url = reverse('api:workflow_job_template_notification_templates_approvals_list', kwargs={'pk': workflow_job_template.pk}) | ||
response = get(url, admin) | ||
assert response.status_code == 200 | ||
assert len(response.data['results']) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
assert response.status_code == 204 | ||
response = get(url, admin) | ||
assert response.status_code == 200 | ||
assert len(response.data['results']) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
url = reverse('api:organization_notification_templates_approvals_list', kwargs={'pk': organization.pk}) | ||
response = get(url, admin) | ||
assert response.status_code == 200 | ||
assert len(response.data['results']) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Build succeeded.
|
8f9563f
to
4a1c1ed
Compare
Build succeeded.
|
...and also add a migration file.
...and customize default messages
...workflow jobs notifications endpoint
f942d4c
to
3182197
Compare
Build succeeded.
|
Build succeeded (gate pipeline).
|
Summary
This feature enhancement will enable notifications to be sent out whenever an approval node needs to be approved, as well as whenever they get approved/denied/are timed out.
Follow-up to PR #4264.
ISSUE TYPE
COMPONENT NAME
AWX VERSION