Merge lp:~wallyworld/launchpad/sharing-job-fflag-protection into lp:launchpad

Proposed by Ian Booth on 2012-06-07
Status: Merged
Approved by: William Grant on 2012-06-07
Approved revision: no longer in the source branch.
Merged at revision: 15374
Proposed branch: lp:~wallyworld/launchpad/sharing-job-fflag-protection
Merge into: lp:launchpad
Diff against target: 126 lines (+26/-14)
6 files modified
lib/lp/bugs/model/bug.py (+6/-4)
lib/lp/bugs/model/bugtask.py (+8/-4)
lib/lp/bugs/model/tests/test_bugtask.py (+1/-0)
lib/lp/bugs/tests/test_bugvisibility.py (+1/-0)
lib/lp/registry/model/teammembership.py (+8/-5)
lib/lp/registry/tests/test_teammembership.py (+2/-1)
To merge this branch: bzr merge lp:~wallyworld/launchpad/sharing-job-fflag-protection
Reviewer Review Type Date Requested Status
William Grant code 2012-06-07 Approve on 2012-06-07
Review via email: mp+109072@code.launchpad.net

Commit Message

Do not create any sharing jobs unless "disclosure.enhanced_sharing.writable" is on.

Description of the Change

== Implementation ==

Guard sharing job creation with "disclosure.enhanced_sharing.writable" feature flag so that jobs don't run on production till qa issues are sorted out.

== Tests ==

Update tests to add feature flag.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/model/bug.py
  lib/lp/bugs/model/bugtask.py
  lib/lp/bugs/model/tests/test_bugtask.py
  lib/lp/bugs/tests/test_bugvisibility.py
  lib/lp/registry/model/teammembership.py
  lib/lp/registry/tests/test_teammembership.py

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bug.py'
2--- lib/lp/bugs/model/bug.py 2012-06-06 20:36:12 +0000
3+++ lib/lp/bugs/model/bug.py 2012-06-07 06:15:25 +0000
4@@ -1809,10 +1809,12 @@
5 self._reconcileAccess()
6 self.updateHeat()
7
8- # As a result of the transition, some subscribers may no longer have
9- # access to the bug. We need to run a job to remove any such
10- # subscriptions.
11- getUtility(IRemoveBugSubscriptionsJobSource).create([self], who)
12+ flag = 'disclosure.enhanced_sharing.writable'
13+ if bool(getFeatureFlag(flag)):
14+ # As a result of the transition, some subscribers may no longer
15+ # have access to the bug. We need to run a job to remove any such
16+ # subscriptions.
17+ getUtility(IRemoveBugSubscriptionsJobSource).create([self], who)
18
19 return True
20
21
22=== modified file 'lib/lp/bugs/model/bugtask.py'
23--- lib/lp/bugs/model/bugtask.py 2012-06-05 02:03:44 +0000
24+++ lib/lp/bugs/model/bugtask.py 2012-06-07 06:15:25 +0000
25@@ -143,6 +143,7 @@
26 SQLBase,
27 sqlvalues,
28 )
29+from lp.services.features import getFeatureFlag
30 from lp.services.helpers import shortlist
31 from lp.services.propertycache import get_property_cache
32 from lp.services.searchbuilder import any
33@@ -1186,10 +1187,13 @@
34 self.maybeConfirm()
35 # END TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
36
37- # As a result of the transition, some subscribers may no longer have
38- # access to the parent bug. We need to run a job to remove any such
39- # subscriptions.
40- getUtility(IRemoveBugSubscriptionsJobSource).create([self.bug], user)
41+ flag = 'disclosure.enhanced_sharing.writable'
42+ if bool(getFeatureFlag(flag)):
43+ # As a result of the transition, some subscribers may no longer
44+ # have access to the parent bug. We need to run a job to remove any
45+ # such subscriptions.
46+ getUtility(IRemoveBugSubscriptionsJobSource).create(
47+ [self.bug], user)
48
49 def updateTargetNameCache(self, newtarget=None):
50 """See `IBugTask`."""
51
52=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
53--- lib/lp/bugs/model/tests/test_bugtask.py 2012-06-05 06:43:41 +0000
54+++ lib/lp/bugs/model/tests/test_bugtask.py 2012-06-07 06:15:25 +0000
55@@ -3342,6 +3342,7 @@
56
57 def setUp(self):
58 self.useFixture(FeatureFixture({
59+ 'disclosure.enhanced_sharing.writable': 'true',
60 'jobs.celery.enabled_classes':
61 'RemoveBugSubscriptionsJob',
62 'disclosure.access_mirror_triggers.removed': 'true',
63
64=== modified file 'lib/lp/bugs/tests/test_bugvisibility.py'
65--- lib/lp/bugs/tests/test_bugvisibility.py 2012-05-22 12:05:51 +0000
66+++ lib/lp/bugs/tests/test_bugvisibility.py 2012-06-07 06:15:25 +0000
67@@ -17,6 +17,7 @@
68
69
70 LEGACY_VISIBILITY_FLAG = {
71+ u"disclosure.enhanced_sharing.writable": "true",
72 u"disclosure.legacy_subscription_visibility.enabled": u"true"}
73 TRIGGERS_REMOVED_FLAG = {
74 u"disclosure.access_mirror_triggers.removed": u"true"}
75
76=== modified file 'lib/lp/registry/model/teammembership.py'
77--- lib/lp/registry/model/teammembership.py 2012-05-22 12:05:51 +0000
78+++ lib/lp/registry/model/teammembership.py 2012-06-07 06:15:25 +0000
79@@ -65,6 +65,7 @@
80 SQLBase,
81 sqlvalues,
82 )
83+from lp.services.features import getFeatureFlag
84 from lp.services.mail.helpers import (
85 get_contact_email_addresses,
86 get_email_template,
87@@ -387,11 +388,13 @@
88 _fillTeamParticipation(self.person, self.team)
89 elif old_status in ACTIVE_STATES:
90 _cleanTeamParticipation(self.person, self.team)
91- # A person has left the team so they may no longer have access to
92- # some artifacts shared with the team. We need to run a job to
93- # remove any subscriptions to such artifacts.
94- getUtility(IRemoveGranteeSubscriptionsJobSource).create(
95- None, self.person, user)
96+ flag = 'disclosure.enhanced_sharing.writable'
97+ if bool(getFeatureFlag(flag)):
98+ # A person has left the team so they may no longer have access
99+ # to some artifacts shared with the team. We need to run a job
100+ # to remove any subscriptions to such artifacts.
101+ getUtility(IRemoveGranteeSubscriptionsJobSource).create(
102+ None, self.person, user)
103
104 else:
105 # Changed from an inactive state to another inactive one, so no
106
107=== modified file 'lib/lp/registry/tests/test_teammembership.py'
108--- lib/lp/registry/tests/test_teammembership.py 2012-05-22 12:05:51 +0000
109+++ lib/lp/registry/tests/test_teammembership.py 2012-06-07 06:15:25 +0000
110@@ -504,7 +504,7 @@
111 The number of db queries should be constant not O(depth).
112 """
113 self.assertStatementCount(
114- 9,
115+ 7,
116 self.team5.setMembershipData, self.no_priv,
117 TeamMembershipStatus.DEACTIVATED, self.team5.teamowner)
118
119@@ -998,6 +998,7 @@
120
121 def setUp(self):
122 self.useFixture(FeatureFixture({
123+ 'disclosure.enhanced_sharing.writable': 'true',
124 'jobs.celery.enabled_classes':
125 'RemoveGranteeSubscriptionsJob',
126 }))