/srv/irclogs.ubuntu.com/2015/10/09/#launchpad-dev.txt

cjwatsonwgrant: I think I've got the webhook privacy code we discussed written, and I'm trying to write tests for negative cases, starting with the situation you suggested where the owner of a branch in a private project leaves the team granting them access to that private project and thus no longer has access to view a branch they own.  I can't quite get the test to work, though, because the owner of a branch always has an artifact grant ...12:07
cjwatson... which doesn't appear to be removed by their leaving the team.  Could you explain how this is meant to work?12:07
cjwatson(the owner of a non-public branch, that is)12:07
wgrantcjwatson: The owner doesn't have an artifact grant if the artifact grant is revoked.12:16
wgrantNor should they have an AAG by default if they already have an APG, though I believe there is a bug or two which can erroneously result in an AAG in some cases.12:17
cjwatsonI think the only thing that would naturally revoke the owner's artifact grant would be unsubscribing from the branch.12:17
wgrantOr direct revocation.12:17
cjwatsonwhich is done by the sharing job, but it only does that if there isn't an artifact grant.12:17
cjwatsonright, or I could do that in the test, I suppose.12:18
wgrantRight, the normal situation is direct revocation from +sharing.12:18
cjwatsonSo that's certainly a good point about having an AAG by default - I wonder why that exists in my case12:20
wgrantIf you can reproduce it, then that is good.12:20
cjwatsonI may have done a stupid thing, since I get a bit lost in the disclosure code.12:21
wgrantThe code is somewhat convoluted, but the concepts are relatively simple.12:21
cjwatsonDo I need to commit after creating the project/team/branch to get Branch.access_{policy,grants} up to date or something?12:29
cjwatsonI thought the triggers happened immediately after the INSERT statement and before any subsequent statement12:31
wgrantIndeed, a flush is sufficient.12:32
wgrantIt is not just security adapter caching?12:32
cjwatsongetVisibleArtifacts should bypass all that, shouldn't it?12:33
cjwatsonI'm not explicitly flushing here12:33
wgrantIt should indeed.12:33
wgrantHave you reviewed the queries and the database state?12:33
wgrant-D and psql are handy12:34
wgrantAnd LP_DEBUG_SQL=112:34
wgrant(do remember to commit before psqling, though)12:34
cjwatsonYeah I'm trawling through LP_DEBUG_SQL_EXTRA=1 now12:34
wgrant_EXTRA? My condolences.12:34
cjwatsonI think possibly there is no AccessPolicyArtifact created before the point where getVisibleArtifacts is called12:35
wgrantOh, during branch creation?12:35
wgrantThat is a possibility.12:35
cjwatsonYes12:35
wgrantAh12:36
wgrantBecause _reconcileAccess is called only after subscribe, perhaps.12:36
wgrantIs the getVisibleArtifacts call within subscribe?12:36
wgrantIt has been some years since I reviewed this code.12:37
cjwatsonRight, it is.  I think BranchNamespace.createBranch is calling those in the wrong order12:39
wgrantI can't think why that would be.12:39
cjwatsonSo the APA is only created after subscribing the owner, which means that the initial subscription of the owner always thinks that the owner doesn't have a policy grant and therefore creates an artifact grant.12:40
cjwatsonReversing those makes my test work.12:41
wgrantI don't quite recall the history here.12:41
wgrantBut I probably wrote that code.12:41
wgrantI don't remember whether that might have been because it was syncing subscribers and AAGs during the migration.12:41
wgrantSo it was important that it was after subscribe.12:41
cjwatsonr15357 seems to be where this was introduced, and doesn't appear to have any evidence of this.  It's structurally more or less the same as today.12:44
wgrantI don't have the code in front of me, will investigate in a bit.12:45
wgrantBut it sounds reasonable.12:45
cjwatsonBut branches weren't the first artifact to be managed this way; maybe bugs had something like that previously.12:45
cjwatsonDo bugs need a similar fix?  APA creation comes after subscribing the owner in that case too.12:47
cjwatsonBlueprints don't have the same problem.12:49
wgrantHm.12:50
wgrantWhat creates the AA?12:50
wgrantIs it automatically created when subscribe() goes to create the AAG?12:51
cjwatsonBoth reconcile_access_for_artifact and SharingService.ensureAccessGrants do getUtility(IAccessArtifactSource).ensure(artifacts)12:52
cjwatsonBranch.subscribe calls SharingService.ensureAccessGrants12:53
wgrantRight.13:05
wgrantfrom experience I don't think bugs have the same problem.13:08
wgrantbut they may accidentally get around it due to tasks13:09
wgrantcreateBug likely calls createTask, possibly before subscribe13:09
cjwatsonIt does13:09
wgrantand createTask is likely to _reconcileAccess or equivalent13:09
cjwatsonAha, yes, I hadn't noticed that13:10
wgrantwhoever duplicated that for bugs may well have just done it exactly the same way13:10
wgranter branches, not bugs13:10
wgrantand it just happened to work for bugs due to the way target setting works13:10
cjwatsonWould still be better to be explicit rather than having a basically useless and misleading _reconcileAccess at the end of bug creation13:10
wgrantcreateTask must be before subscribe for notifications to work13:11
wgrantso that would explain it13:11
cjwatsonIt is13:11
cjwatsonI think I'll delete the explicit bug._reconcileAccess from BugSet.createBug and leave a comment13:13
cjwatsonBecause it's really more about the bug task since that's the thing that's setting up the association with the pillar13:14
wgrantas long as there's no opportunity for privacy/target changes between createTask and _reconcileAccess, and createTask really calls fullblown _reconcileAccess, that sounds fine13:14
cjwatsonit's createTask, subscribe, assignee, importance, milestone, _reconcileAccess; so no13:15
wgrantyay13:15
cjwatsonand yes, removeSecurityProxy(bug)._reconcileAccess() at the end of BugTaskSet.createManyTasks, which does most of the work for createTask13:16
wgrantugh, that's right13:16
wgrantsorry, was roughly on the right track at least13:16
* cjwatson kicks off a test run for -t bugs -t code and goes out to run errands13:16
cjwatsonI'll work out specific tests once I've ensured it doesn't blow up the world13:17
wgranttests are good!13:17
cjwatsonthanks for the help figuring this out13:17
cjwatson(it was making no sense whatsoever yesterday evening, and no wonder ...)13:18
cjwatsonI wonder if we need a way to find all the incorrect AAGs. :-(13:19
wgrantglad my vague recollections led you down the right path!13:19
wgrantthey're not incorrect, just excess.13:19
cjwatsonwell, they mean that people retain access after leaving the team that grants them access13:19
cjwatsonso at least some of them are incorrect13:20
wgrantish13:21
wgrantwhen you're kicking someone out of a project you should be checking +sharing anyway13:21
wgrantfor Canonical employees that's all handled automatically by the leaver process13:21
cjwatsonI guess they have an explicit subscription too13:22
wgrantthe main intent of not creating an AAG was to avoid polluting +sharing13:22
wgrantrather than automatic revocation13:22
cjwatsonok13:22
cjwatsonI won't panic about it then13:22
wgrantanyway, hopefully the test suite will be happy13:23
wgrantHave a good weekend!13:23
cjwatsonyou too13:24

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!