Skip to content
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

Remove the "Any" State from Notifications #4022

Closed
beeankha opened this issue Jun 6, 2019 · 5 comments
Closed

Remove the "Any" State from Notifications #4022

beeankha opened this issue Jun 6, 2019 · 5 comments

Comments

@beeankha
Copy link
Contributor

beeankha commented Jun 6, 2019

ISSUE TYPE

Remove the any state from unifiedjobtemplate_notification_templates and organization_notification_templates.

SUMMARY

The any state does not apply to all states, it only applies to one of two finished states (success/error). This can be confusing.

Removing the any state will enable the user to define what they mean by any, e.g., it's truly ALL of the states or it's only on job finish (the success/error/started states are additive, so they can select as many as they want).

Note on backwards compatibility: After the related data migration has been applied, all of the _any relationships will automatically be turned into two relationships, one success and one error.

@beeankha
Copy link
Contributor Author

This issue is currently being worked on in PR #3982.

@Spredzy
Copy link
Contributor

Spredzy commented Jun 19, 2019

verified

@ryanpetrello
Copy link
Contributor

ryanpetrello commented Jun 19, 2019

@Spredzy did we actually test upgrade/migrations for these relationships on upgrade? I found a subtle bug while reviewing the PR that would have caused us to lose data on organization-wide any notifications on upgrade:

#3982 (comment)

I'd really like to see testing that involves setting up "any" relationships on:

  • Organizations
  • Job Templates
  • Inventory Syncs
  • Project Updates
  • System Job Templates

And verifying that post-upgrade they all were converted to one success and one error.

@ryanpetrello
Copy link
Contributor

@Spredzy we're merging a fix for this:

#4098

@Spredzy
Copy link
Contributor

Spredzy commented Jun 20, 2019

-----
Tower Version: 3.5.0
-----
Organizations remove_any_org_3

Notif Any: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Success: []
Notif Error: []


Job Templates remove_any_jt_3

Notif Any: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Success: []
Notif Error: []


Projects remove_any_proj_3

Notif Any: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Success: []
Notif Error: []


Inventory Sources remove_any_invetory_source_3

Notif Any: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Success: []
Notif Error: []


System Job Templates Cleanup Job Details

Notif Any: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Success: []
Notif Error: []

-----
Tower version: 3.6.0
-----
Organizations remove_any_org_3

Notif Success: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Error: ['NotificationTemplate (slack) - ActorPipe쒃']


Job Templates remove_any_jt_3

Notif Success: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Error: ['NotificationTemplate (slack) - ActorPipe쒃']


Projects remove_any_proj_3

Notif Success: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Error: ['NotificationTemplate (slack) - ActorPipe쒃']


Inventory Sources remove_any_invetory_source_3

Notif Success: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Error: ['NotificationTemplate (slack) - ActorPipe쒃']


System Job Templates Cleanup Job Details

Notif Success: ['NotificationTemplate (slack) - ActorPipe쒃']
Notif Error: ['NotificationTemplate (slack) - ActorPipe쒃']

Load script:

tower_version = v2.ping.get().instances[0].version                                                                                                                                             
                                                                                                                                                                                               
notif = v2.notification_templates.create(notif='test_remove_any_3')
org = v2.organizations.create(name='remove_any_org_3')
jt = v2.job_templates.create(name='remove_any_jt_3')
proj = v2.projects.create(name='remove_any_proj_3')
inv = v2.inventory_sources.create(name='remove_any_invetory_source_3')                                                                                                                         
sjt = v2.system_job_templates.get(id=1).results[0]                                                                                                                                             
                                                                                                                                                                                               
notif.associate(org)
notif.associate(jt)                                                                            
notif.associate(proj)                                                                                                                                                                          
notif.associate(inv)
notif.associate(sjt)

print("")
print("")
print("")
print("-----")
print("Tower version: %s" % tower_version)
print("-----")
print("Organizations %s" % org.name)
print("")
print("Notif Any: %s" % str([notif.name for notif in org.related.get('notification_templates_any').get().results]))
print("Notif Success: %s" % str([notif.name for notif in org.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in org.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Job Templates %s" % jt.name)
print("")
print("Notif Any: %s" % str([notif.name for notif in jt.related.get('notification_templates_any').get().results]))
print("Notif Success: %s" % str([notif.name for notif in jt.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in jt.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Projects %s" % proj.name)
print("")
print("Notif Any: %s" % str([notif.name for notif in proj.related.get('notification_templates_any').get().results]))
print("Notif Success: %s" % str([notif.name for notif in proj.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in proj.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Inventory Sources %s" % inv.name)
print("")
print("Notif Any: %s" % str([notif.name for notif in inv.related.get('notification_templates_any').get().results]))
print("Notif Success: %s" % str([notif.name for notif in inv.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in inv.related.get('notification_templates_error').get().results]))
print("")
print("")
print("System Job Templates %s" % sjt.name)
print("")
print("Notif Any: %s" % str([notif.name for notif in sjt.related.get('notification_templates_any').get().results])) 
print("Notif Success: %s" % str([notif.name for notif in sjt.related.get('notification_templates_success').get().results])) 
print("Notif Error: %s" % str([notif.name for notif in sjt.related.get('notification_templates_error').get().results]))

Verify script:

tower_version = v2.ping.get().instances[0].version

org = v2.organizations.get(name='remove_any_org_3').results[0]
jt = v2.job_templates.get(name='remove_any_jt_3').results[0]
proj = v2.projects.get(name='remove_any_proj_3').results[0]
inv = v2.inventory_sources.get(name='remove_any_invetory_source_3').results[0]
sjt = v2.system_job_templates.get(id=1).results[0]


print("")
print("")
print("")
print("-----")
print("Tower version: %s" % tower_version)
print("-----")
print("Organizations %s" % org.name)
print("")
print("Notif Success: %s" % str([notif.name for notif in org.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in org.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Job Templates %s" % jt.name)
print("")
print("Notif Success: %s" % str([notif.name for notif in jt.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in jt.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Projects %s" % proj.name)
print("")
print("Notif Success: %s" % str([notif.name for notif in proj.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in proj.related.get('notification_templates_error').get().results]))
print("")
print("")
print("Inventory Sources %s" % inv.name)
print("")
print("Notif Success: %s" % str([notif.name for notif in inv.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in inv.related.get('notification_templates_error').get().results]))
print("")
print("")
print("System Job Templates %s" % sjt.name)
print("")
print("Notif Success: %s" % str([notif.name for notif in sjt.related.get('notification_templates_success').get().results]))
print("Notif Error: %s" % str([notif.name for notif in sjt.related.get('notification_templates_error').get().results]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants