<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le jeu. 17 nov. 2016 à 20:19, Neil Gilmore <<a href="mailto:ngilmore@grammatech.com">ngilmore@grammatech.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi everyone,<br class="gmail_msg">
<br class="gmail_msg">
The anecdote first.<br class="gmail_msg">
<br class="gmail_msg">
So we've been plagued with the non-modifiable scheduler problem. A lot.<br class="gmail_msg">
I finally got to look at that without distraction yesterday.<br class="gmail_msg">
Unfortunately, I didn't find the documentation on the reconfiguration<br class="gmail_msg">
process too useful other than to point me at function names. </blockquote><div><div><br></div><div>Following is the documentation. This is quite deep in the core, so dont expect a tutorial on this, but you still get some detailled description of the buildbot services lifecycle. (hint: everything is a service in buildbot)</div><div><a href="http://docs.buildbot.net/latest/developer/utils.html#buildbot.util.service.BuildbotService">http://docs.buildbot.net/latest/developer/utils.html#buildbot.util.service.BuildbotService</a><br></div><br class="inbox-inbox-Apple-interchange-newline"></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
Now for the unsolicited code.<br class="gmail_msg"></blockquote><div><br></div><div>Every unsolicited code is very welcome by the buildbot community, we are very friendly to all contribution.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
So I first wrote an overriden version of reconfigService() in<br class="gmail_msg">
BaseScheduler. Goody! When I start or reconfig, my version gets called.<br class="gmail_msg">
But I really didn't want to have to create _config_args and<br class="gmail_msg">
_config_kwargs in BaseScheduler. </blockquote><div>No you dont, but you haven't.</div><div><br></div><div>You just have to follow the checkConfig/reconfigService principle for all schedulers and their subclasses.</div><div>It can only work if all the subclasses are following the process.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It looked safe to override<br class="gmail_msg">
reconfigServiceWithSibling in BaseScheduler.</blockquote><div><br></div><div>Arg no! dont I can't see that. please!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> It's nice that all the<br class="gmail_msg">
figuring out whether to reconfig or not is already computed by that<br class="gmail_msg">
point. The resulting function is all of 9 lines:<br class="gmail_msg">
<br class="gmail_msg">
(in class BaseScheduler)<br class="gmail_msg">
def reconfigServiceWithSibling(self, sibling):<br class="gmail_msg">
# only reconfigure if sibling is configured differently.<br class="gmail_msg">
# sibling == self is using ComparableMixin's implementation<br class="gmail_msg">
# only compare compare_attrs<br class="gmail_msg">
if self.configured and sibling == self:<br class="gmail_msg">
<br class="gmail_msg">
return defer.succeed(None)<br class="gmail_msg">
self.configured = True<br class="gmail_msg">
<a href="http://self.name" rel="noreferrer" class="gmail_msg" target="_blank">self.name</a> = <a href="http://sibling.name" rel="noreferrer" class="gmail_msg" target="_blank">sibling.name</a><br class="gmail_msg">
self.builderNames = sibling.builderNames<br class="gmail_msg">
self.properties = sibling.properties<br class="gmail_msg">
self.codesbases = sibling.codebases<br class="gmail_msg">
return defer.succeed(None)<br class="gmail_msg"></blockquote><div><br></div><div>Yes, looks simple, but checkConfig/reconfigService is much more flexible. Both functions can be seen like a contructor.</div><div>The first part of the constructor is the part that do the checks, and the second part that actually store the configs inside the object attributes.</div><div>The good think is that the config part can be an inlineCallbacks, so you can call deferred returning function. This is very powerful and you cannot do that with python constructors.</div><div><br></div><div>The drawback of this method is that it requires a bit of code duplication, as the two methods must have the exact same footprint.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(I know it's not in the form of a patch or anything, but if it helps<br class="gmail_msg">
anyone, got ahead and use it).<br class="gmail_msg"></blockquote><div>I am not sure if you can't contribute because of company policy or anything, but I would recommend to try and contribute a proper fix.</div><div><br></div><div>I started my work with buildbot by doing such hacks in the prod, and after 4 years we have tons of big hacks in it. We can't upgrade our prod to the new awesomeness of nine, and are stuck with 0.8.7. </div><div>This is unfortunaly the case with some other big companies (watch were my eyes rest.).</div><div><br></div><div>Buildbot is helping you a lot, so maybe its time to help Buildbot.</div><div><br></div><div>Regards, </div><div>Pierre</div></div></div>