-
Notifications
You must be signed in to change notification settings - Fork 13
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
broken sort order for plugins, priority_plugins not honored #13
Comments
I should point out the particular failure case here is that on Vicki's machine 'tabletop' plugin is loading before its dependency of 'panels', and it causes it to crash. |
this should probably be fixed in two ways:
|
My confusion here is that:
Unrelatedly, why is glob() returning something different inside vagrant? I thought the whole point of vagrant was to NOT have these issues. :\ |
Interesting... FWIW, Sideboard doesn't rely on I can now see that the bug is that the That line should be changed from
to
which will prevent this from happening. |
@EliAndrewC That was actually one of the first things I tried. I tried it again and it still didn't make a difference. Something's wrong with the key= bit though for sure - maybe it's broken only here because of a Python update or something? |
So to clarify, suppose we had 5 plugins: To answer why |
I fixed it. |
The problem was that plugin_dirs is a list that looks like this:
That line checks each item in that list against the
One of these things is not like the other~ Anyway, I'll commit and PR a fix shortly. |
Ahhhh, good catch! |
In some cases, Sideboard was comparing a full path (e.g. '/home/vagrant/uber/sideboard/plugins/uber') with a plugin name (e.g. 'uber') to sort plugins. Doing so would break priority plugins settings. Fixes #13.
Also of course a million thanks to @binary1230 for helping debug this - I wasn't getting anywhere until he got on my machine and worked on this for like two hours. It was only after this issue was filed that I was able to puzzle anything out. |
btw (guessing) glob() might be returning something different inside vagrant because that folder is being shared into the VM, which means there's some reliance on the host OS filesystem stuff. if your host OS is using a different filesystem than what vagrant or prod ubuntu uses, that could explain it. As for how this could have worked before: For panels plugin: Tabletop requires panels plugin to be around, but it never directly imports anything from panels. Thus, it really will crash if panels stuff (like the Events model) doesn't exist. If you look at the two different outputs, on staging2, panels is indeed loaded before tabletop whereas on yours it was tabletop then panels. |
I still would like to see us immediately sort the glob() output by basename so that the ordering is consistent (even though we don't need to do this to get uber to start and it works fine as-is) That way, even if there's system dependent ordering from glob(), ALL sideboard instances everywhere still load plugins in the exact same order (despite us not needing to do this). That way if we ever encounter weird system-specific+plugin-order-specific behavior again, we should hopefully see it fail everywhere instead of just failing on one random computer. |
made a separate issue for the idea of sorting the gloab() output #15 |
Have taken my discussion of sorting over to #15 On Wed, May 25, 2016 at 12:10 PM, Dominic Cerquetti <
|
This one's fun :) This is one of those bugs where it's literally been busted for years but has by certain system-dependent miracles worked correctly and we never noticed. I need to double check this, but I'm now pretty confident this is real.
TLDR: sideboard doesn't honor the order of priority_plugins
"BUT wait!" I hear you say. "If that were true, it should have been crashing for years, right? How did we never notice??"
We never noticed it wasn't working because on literally every box we've ever run, glob() (which returns an unordered result) happened by PURE CHANCE to return a plugin load order that happened to work despite our sorting not working.
glob() ordering is arbitrary, it is not sorted in any way:
"By checking the source code of glob.glob you see that it internally calls os.listdir, described here:
http://docs.python.org/library/os.html?highlight=os.listdir#os.listdir
Key sentence: os.listdir(path) Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory."
that non-ordering shouldn't be a problem because our code is supposed to re-order things so the prioritized plugins get loaded first.
but that's not what happens, here's the result of an instrumented build which spits out some debug info about this process (https://github.com/magfest/sideboard/blob/ordering_testing_NEVERUSE/sideboard/internal/imports.py)
glob() results on Vicki's machine: returns a BROKEN LOAD ORDERING
NOTE: BROKEN: panels needs to load before tabletop, else tabletop crashes startup
same test but run on staging2 with identical set of plugins and priority_plugins results in a DIFFERENT LOAD ORDER (BUG)
That load order is a valid order.
solution: uber's code should be handling this case correctly on Vicki's machine but isn't, so it's a legit bug we need to fix. Should be an easy fix, and we should probably unit test the hell out of this to make sure it loads things correctly.
The text was updated successfully, but these errors were encountered: