core: introduce activation rate limiting for socket units

This adds two new settings TriggerLimitIntervalSec= and TriggerLimitBurst= that
define a rate limit for activation of socket units. When the limit is hit, the
socket is is put into a failure mode. This is an alternative fix for #2467,
since the original fix resulted in issue #2684.

In a later commit the StartLimitInterval=/StartLimitBurst= rate limiter will be
changed to be applied after any start conditions checks are made. This way,
there are two separate rate limiters enforced: one at triggering time, before
any jobs are queued with this patch, as well as the start limit that is moved
again to be run immediately before the unit is activated. Condition checks are
done in between the two, and thus no longer affect the start limit.
This commit is contained in:
Lennart Poettering
2016-04-29 16:27:48 +02:00
parent 3282493ad0
commit 8b26cdbd2a
6 changed files with 41 additions and 3 deletions
+16
View File
@@ -807,6 +807,22 @@
suffix.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>TriggerLimitIntervalSec=</varname></term>
<term><varname>TriggerLimitIntervalBurst=</varname></term>
<listitem><para>Configures a limit on how often this socket unit my be activated within a specific time
interval. The <varname>TriggerLimitIntervalSec=</varname> may be used to configure the length of the time
interval in the usual time units <literal>us</literal>, <literal>ms</literal>, <literal>s</literal>,
<literal>min</literal>, <literal>h</literal>, … and defaults to 5s (See
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
the various time units available). The <varname>TriggerLimitBurst=</varname> setting takes an integer value and
specifies the numer of permitted activations per time interval, and defaults to 2500 (thus by default
permitting 2500 activations per 5s). Set either to 0 to disable any form of trigger rate limiting. If the limit
is hit, the socket unit is placed into a failure mode, and will not be connectible anymore until
restarted. Note that this limit is enforced before the service activation is enqueued.</para></listitem>
</varlistentry>
</variablelist>
<para>Check