<div dir="ltr">I like the idea of being able to trigger failures stochastically. I'll integrate this into whatever we settle on for Juju's failure injection.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 14 August 2014 02:29, Gustavo Niemeyer <span dir="ltr"><<a href="mailto:gustavo.niemeyer@canonical.com" target="_blank">gustavo.niemeyer@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ah, and one more thing: when developing the chaos-injection mechanism<br>
in the mgo/txn package, I also added both a "chance" parameter for<br>
either killing or slowing down a given breakpoint. It sounds like it<br>
would be useful for juju's mechanism too. If you kill every time, it's<br>
hard to tell whether the system would know how to retry properly.<br>
Killing or slowing down just sometimes, or perhaps the first 2 times<br>
out of every 3, for example, would enable the system to recover<br>
itself, and an external agent to ensure it continues to work properly.<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Aug 13, 2014 at 11:25 AM, Gustavo Niemeyer<br>
<<a href="mailto:gustavo.niemeyer@canonical.com">gustavo.niemeyer@canonical.com</a>> wrote:<br>
> That's a nice direction, Menno.<br>
><br>
> The main thing that comes to mind is that it sounds quite inconvenient<br>
> to turn the feature on. It may sound otherwise because it's so easy to<br>
> drop files at arbitrary places in our local machines, but when dealing<br>
> with a distributed system that knows how to spawn its own resources<br>
> up, suddenly the "just write a file" becomes surprisingly boring and<br>
> race prone.<br>
><br>
> What about:<br>
><br>
>     juju inject-failure [--unit=unit] [--service=service] <failure name>"?<br>
>     juju deploy [--inject-failure=name] ...<br>
><br>
><br>
><br>
> On Wed, Aug 13, 2014 at 7:17 AM, Menno Smits <<a href="mailto:menno.smits@canonical.com">menno.smits@canonical.com</a>> wrote:<br>
>> There's been some discussion recently about adding some feature to Juju to<br>
>> allow developers or CI tests to intentionally trigger otherwise hard to<br>
>> induce failures in specific parts of Juju. The idea is that sometimes we<br>
>> need some kind of failure to happen in a CI test or when manually testing<br>
>> but those failures can often be hard to make happen.<br>
>><br>
>> For example, for changes Juju's upgrade mechanics that I'm working on at the<br>
>> moment I would like to ensure that an upgrade is cleanly aborted if one of<br>
>> the state servers in a HA environment refuses to start the upgrade. This<br>
>> logic is well unit tested but there's nothing like seeing it actually work<br>
>> in a real environment to build confidence - however, it isn't easy to make a<br>
>> state server misbehave in this way.<br>
>><br>
>> To help with this kind of testing scenario, I've created a new top-level<br>
>> package called "wrench" which lets us "drop a wrench in the works" so to<br>
>> speak. It's very simple with one main API which can be called from<br>
>> judiciously chosen points in Juju's execution to decide whether some failure<br>
>> should be triggered.<br>
>><br>
>> The module looks for files in $jujudatadir/wrench (typically<br>
>> /var/lib/juju/wrench) on the local machine. If I wanted to trigger the<br>
>> upgrade failure described above I could drop a file in that directory on one<br>
>> of the state servers named say "machine-agent" with the content:<br>
>><br>
>> refuse-upgrade<br>
>><br>
>> Then in some part of jujud's upgrade code there could be a check like:<br>
>><br>
>> if wrench.IsActive("machine-agent", "refuse-upgrade") {<br>
>>      // trigger the failure<br>
>> }<br>
>><br>
>> The idea is this check would be left in the code to aid CI tests and future<br>
>> manual tests.<br>
>><br>
>> You can see the incomplete wrench package here:<br>
>> <a href="https://github.com/juju/juju/pull/508" target="_blank">https://github.com/juju/juju/pull/508</a><br>
>><br>
>> There are a few issues to nut out.<br>
>><br>
>> 1. It needs to be difficult/impossible for someone to accidentally or<br>
>> maliciously activate this feature, especially in production environments. I<br>
>> have almost finished (but not pushed to Github) some changes to the wrench<br>
>> package which make it strict about the ownership and permissions on the<br>
>> wrench files. This should make it harder for the wrong person to drop files<br>
>> in to the wrench directory.<br>
>><br>
>> The idea has also been floated to only enable this functionality in<br>
>> non-stable builds. This certainly gives a good level of protection but I'm<br>
>> slightly wary of this approach because it makes it impossible for CI to take<br>
>> advantage of the wrench feature when testing stable release builds. I'm<br>
>> happy to be convinced that the benefit is worth the cost.<br>
>><br>
>> Other ideas on how to better handle this are very welcome.<br>
>><br>
>> 2. The wrench functionality needs to be disabled during unit test runs<br>
>> because we don't want any wrench files a developer may have lying around to<br>
>> affect Juju's behaviour during test runs. The wrench package has a global<br>
>> on/off switch so I plan on switching it off in BaseSuite's setup or similar.<br>
>><br>
>> 3. The name is a bikeshedding magnet :)  Other names that have been bandied<br>
>> about for this feature are "chaos" and "spanner". I don't care too much so<br>
>> if there's a strong consensus for another name let's use that. I chose<br>
>> "wrench" over "spanner" because I believe that's the more common usage in<br>
>> the US and because Spanner is a DB from Google. Let's not get carried<br>
>> away...<br>
>><br>
>> All comments, ideas and concerns welcome.<br>
>><br>
>> - Menno<br>
>><br>
>><br>
>><br>
>> --<br>
>> Juju-dev mailing list<br>
>> <a href="mailto:Juju-dev@lists.ubuntu.com">Juju-dev@lists.ubuntu.com</a><br>
>> Modify settings or unsubscribe at:<br>
>> <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
>><br>
><br>
> --<br>
> gustavo @ <a href="http://niemeyer.net" target="_blank">http://niemeyer.net</a><br>
<br>
<br>
<br>
--<br>
gustavo @ <a href="http://niemeyer.net" target="_blank">http://niemeyer.net</a><br>
</div></div></blockquote></div><br></div>