<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>When do we need negative durations ?</div>

<div>Is it because iso8601 must be able to handle negative durations ?</div>

<div>What is the expected reaction on setting a negative interval in the monitor operation ?</div>

<div>&nbsp;</div>

<div>Just to know what i can expect from the test.</div>

<div>&nbsp;</div>

<div>Rainer
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b>&nbsp;Montag, 05. Mai 2014 um 06:37 Uhr<br/>
<b>Von:</b>&nbsp;&quot;Andrew Beekhof&quot; &lt;andrew@beekhof.net&gt;<br/>
<b>An:</b>&nbsp;&quot;The Pacemaker cluster resource manager&quot; &lt;pacemaker@oss.clusterlabs.org&gt;<br/>
<b>Betreff:</b>&nbsp;Re: [Pacemaker] Interval-origin in monitor operations does not work</div>

<div name="quoted-content"><br/>
On 2 May 2014, at 4:55 pm, Andrew Beekhof &lt;andrew@beekhof.net&gt; wrote:<br/>
<br/>
&gt;<br/>
&gt; On 15 Apr 2014, at 4:12 am, Rainer Brestan &lt;rainer.brestan@gmx.net&gt; wrote:<br/>
&gt;<br/>
&gt;&gt; Of course, I can.<br/>
&gt;&gt; &lt;primitive class=&quot;ocf&quot; id=&quot;resD&quot; provider=&quot;heartbeat&quot; type=&quot;Dummy&quot;&gt;<br/>
&gt;&gt; &lt;operations&gt;<br/>
&gt;&gt; &lt;op id=&quot;resD-start-0&quot; interval=&quot;0&quot; name=&quot;start&quot; timeout=&quot;20&quot;/&gt;<br/>
&gt;&gt; &lt;op id=&quot;resD-stop-0&quot; interval=&quot;0&quot; name=&quot;stop&quot; timeout=&quot;20&quot;/&gt;<br/>
&gt;&gt; &lt;op id=&quot;resD-monitor-1h&quot; interval=&quot;1h&quot; interval-origin=&quot;00:34&quot; name=&quot;monitor&quot; timeout=&quot;60&quot;/&gt;<br/>
&gt;&gt; &lt;/operations&gt;<br/>
&gt;&gt; &lt;meta_attributes id=&quot;resD-meta_attributes&quot;&gt;<br/>
&gt;&gt; &lt;nvpair id=&quot;resD-meta_attributes-failure-timeout&quot; name=&quot;failure-timeout&quot; value=&quot;15m&quot;/&gt;<br/>
&gt;&gt; &lt;nvpair id=&quot;resD-meta_attributes-migration-threshold&quot; name=&quot;migration-threshold&quot; value=&quot;3&quot;/&gt;<br/>
&gt;&gt; &lt;/meta_attributes&gt;<br/>
&gt;&gt; &lt;/primitive&gt;<br/>
&gt;&gt;<br/>
&gt;&gt; Yes, the origin is in the future, but consider above monitor configuration.<br/>
&gt;&gt; The monitor operation shall run every hour at 34 minutes.<br/>
&gt;&gt; If i would specifiy a full date in the past then pengine has to run a number of while(rc&lt;0) loops in unpack_operation.<br/>
&gt;&gt; One year after full date exactly 8760 and this for every call of unpack_operation.<br/>
&gt;&gt; Thats why i specified the first possible run time every day and then they are maximum of 23 while loop runs.<br/>
&gt;&gt;<br/>
&gt;&gt; If unpack_operation is called between 00:00 and 00:34 the described situation happens.<br/>
&gt;&gt; Origin is later than now.<br/>
&gt;&gt;<br/>
&gt;&gt; Applying this patch will help.<br/>
&gt;<br/>
&gt; It will, but as I suspected it will also cause:<br/>
&gt;<br/>
&gt; iso8601 -d &#39;2014-01-01 00:00:30Z&#39; -D P-1D -E &#39;2013-12-31 00:00:30Z&#39;<br/>
&gt;<br/>
&gt; to fail with:<br/>
&gt;<br/>
&gt; Date: 2014-01-01 00:00:30Z<br/>
&gt; Duration: 0000-01--01 00:00:00Z<br/>
&gt; Duration ends at: 2014-01-00 00:00:30Z<br/>
&gt;<br/>
&gt; which isn&#39;t right :)<br/>
&gt;<br/>
&gt; I&#39;m working on a true fix now...<br/>
<br/>
These are the resulting patches in <a href="https://github.com/beekhof/pacemaker" target="_blank">https://github.com/beekhof/pacemaker</a>:<br/>
<br/>
+ Andrew Beekhof (14 seconds ago) 44af669: Test: PE: Correctly handle origin offsets in the future (HEAD, master)<br/>
+ Andrew Beekhof (27 minutes ago) 3f20485: Fix: PE: Correctly handle origin offsets in the future<br/>
+ Andrew Beekhof (4 minutes ago) d39bad6: Test: iso8601: Improved logging of durations<br/>
+ Andrew Beekhof (29 minutes ago) afb6c16: Fix: iso8601: Different logic is needed when logging and calculating durations<br/>
<br/>
&gt;<br/>
&gt;<br/>
&gt;&gt; diff --git a/lib/common/iso8601.c b/lib/common/iso8601.c<br/>
&gt;&gt; index 7dc2495..742de70 100644<br/>
&gt;&gt; --- a/lib/common/iso8601.c<br/>
&gt;&gt; +++ b/lib/common/iso8601.c<br/>
&gt;&gt; @@ -1137,7 +1137,7 @@ crm_time_add_days(crm_time_t * a_time, int extra)<br/>
&gt;&gt; ydays = crm_time_leapyear(a_time-&gt;years) ? 366 : 365;<br/>
&gt;&gt; }<br/>
&gt;&gt; - while (a_time-&gt;days &lt;= 0) {<br/>
&gt;&gt; + while (a_time-&gt;days &lt; 0) {<br/>
&gt;&gt; a_time-&gt;years--;<br/>
&gt;&gt; a_time-&gt;days += crm_time_leapyear(a_time-&gt;years) ? 366 : 365;<br/>
&gt;&gt; }<br/>
&gt;&gt;<br/>
&gt;&gt; Rainer<br/>
&gt;&gt; Gesendet: Mittwoch, 09. April 2014 um 08:57 Uhr<br/>
&gt;&gt; Von: &quot;Andrew Beekhof&quot; &lt;andrew@beekhof.net&gt;<br/>
&gt;&gt; An: &quot;The Pacemaker cluster resource manager&quot; &lt;pacemaker@oss.clusterlabs.org&gt;<br/>
&gt;&gt; Betreff: Re: [Pacemaker] Interval-origin in monitor operations does not work<br/>
&gt;&gt;<br/>
&gt;&gt; On 1 Apr 2014, at 5:10 am, Rainer Brestan &lt;rainer.brestan@gmx.net&gt; wrote:<br/>
&gt;&gt;<br/>
&gt;&gt;&gt; Using interval-origin in monitor operation definition does not work any more.<br/>
&gt;&gt;&gt; Veryfied on Pacemaker 1.1.10, but we think it does not work since 1.1.8 until now.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; Pengine calculates start delay in function unpack_operation and calls there crm_time_subtract.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; The call to crm_time_subtract with<br/>
&gt;&gt;&gt; origin=2014-03-31 19:20:00Z<br/>
&gt;&gt;&gt; date_set-&gt;now=2014-03-31 17:31:04Z<br/>
&gt;&gt;&gt; result in<br/>
&gt;&gt;&gt; delay=-0001-12-31 01:48:56Z<br/>
&gt;&gt;&gt; delay_s=31456136<br/>
&gt;&gt;&gt; start_delay=31456136000<br/>
&gt;&gt;&gt; which is almost a year in the future.<br/>
&gt;&gt;<br/>
&gt;&gt; To be fair, the origin was also in the future.<br/>
&gt;&gt; I don&#39;t think that was expected.<br/>
&gt;&gt;<br/>
&gt;&gt; Can you supply your cib so I can experiment?<br/>
&gt;&gt;<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; The function crm_time_subtract calculates this by the crm_time_add_* functions.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; The buggy statement is in crm_time_add_days.<br/>
&gt;&gt;&gt; If the calculated number of days is zero, it subtracts one year and add the number of days, in this case 365.<br/>
&gt;&gt;&gt; But if a_time-&gt;days is zero, it must not do anything.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; The function crm_time_get_seconds, which is called by unpack_operation cannot handle negative years, so it ignores the year -1 but adds 365 days.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; There are two solutions.<br/>
&gt;&gt;&gt; One is the add handling on negative years to crm_time_get_seconds.<br/>
&gt;&gt;&gt; The other is to exchange line 1140 in iso8601.c<br/>
&gt;&gt;&gt; while (a_time-&gt;days &lt;= 0) {<br/>
&gt;&gt;&gt; by<br/>
&gt;&gt;&gt; while (a_time-&gt;days &lt; 0) {<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; Second solution is verified to bring the expected result, start-delay of little less than two hours.<br/>
&gt;&gt;&gt; Handling of negative years in crm_time_get_seconds might not be a proper solution as the return value of the function is unsigned long long and what to report if the complete calculation gives a negative number of seconds.<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; Rainer<br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; _______________________________________________<br/>
&gt;&gt;&gt; Pacemaker mailing list: Pacemaker@oss.clusterlabs.org<br/>
&gt;&gt;&gt; <a href="http://oss.clusterlabs.org/mailman/listinfo/pacemaker" target="_blank">http://oss.clusterlabs.org/mailman/listinfo/pacemaker</a><br/>
&gt;&gt;&gt;<br/>
&gt;&gt;&gt; Project Home: <a href="http://www.clusterlabs.org" target="_blank">http://www.clusterlabs.org</a><br/>
&gt;&gt;&gt; Getting started: <a href="http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf" target="_blank">http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf</a><br/>
&gt;&gt;&gt; Bugs: <a href="http://bugs.clusterlabs.org" target="_blank">http://bugs.clusterlabs.org</a><br/>
&gt;&gt;<br/>
&gt;&gt; _______________________________________________<br/>
&gt;&gt; Pacemaker mailing list: Pacemaker@oss.clusterlabs.org<br/>
&gt;&gt; <a href="http://oss.clusterlabs.org/mailman/listinfo/pacemaker" target="_blank">http://oss.clusterlabs.org/mailman/listinfo/pacemaker</a><br/>
&gt;&gt;<br/>
&gt;&gt; Project Home: <a href="http://www.clusterlabs.org" target="_blank">http://www.clusterlabs.org</a><br/>
&gt;&gt; Getting started: <a href="http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf" target="_blank">http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf</a><br/>
&gt;&gt; Bugs: <a href="http://bugs.clusterlabs.org" target="_blank">http://bugs.clusterlabs.org</a><br/>
&gt;&gt; _______________________________________________<br/>
&gt;&gt; Pacemaker mailing list: Pacemaker@oss.clusterlabs.org<br/>
&gt;&gt; <a href="http://oss.clusterlabs.org/mailman/listinfo/pacemaker" target="_blank">http://oss.clusterlabs.org/mailman/listinfo/pacemaker</a><br/>
&gt;&gt;<br/>
&gt;&gt; Project Home: <a href="http://www.clusterlabs.org" target="_blank">http://www.clusterlabs.org</a><br/>
&gt;&gt; Getting started: <a href="http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf" target="_blank">http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf</a><br/>
&gt;&gt; Bugs: <a href="http://bugs.clusterlabs.org" target="_blank">http://bugs.clusterlabs.org</a><br/>
<br/>
_______________________________________________<br/>
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org<br/>
<a href="http://oss.clusterlabs.org/mailman/listinfo/pacemaker" target="_blank">http://oss.clusterlabs.org/mailman/listinfo/pacemaker</a><br/>
<br/>
Project Home: <a href="http://www.clusterlabs.org" target="_blank">http://www.clusterlabs.org</a><br/>
Getting started: <a href="http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf" target="_blank">http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf</a><br/>
Bugs: <a href="http://bugs.clusterlabs.org" target="_blank">http://bugs.clusterlabs.org</a></div>
</div>
</div>
</div></div></body></html>