<div dir="ltr">the start function, need to start the resource when monitor doesn't return success<br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-12 23:38 GMT+02:00 Bishoy Mikhael <span dir="ltr"><<a href="mailto:b.s.mikhael@gmail.com" target="_blank">b.s.mikhael@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>I'm trying to create a resource agent to promote a standby HDFS namenode to active when the virtual IP failover to another node.</div><div><br></div><div>I've taken the skeleton from the Dummy OCF agent.</div><div><br></div><div>The modifications I've done to the Dummy agent are as follows:</div><div><br></div><div><div>HDFSHA_start() {</div><div>    HDFSHA_monitor</div><div>    if [ $? =  $OCF_SUCCESS ]; then</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">                        </span>/opt/hadoop/sbin/hdfs-ha.sh start</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">                   </span>return $OCF_SUCCESS</div><div>    fi</div><div>}</div><div><br></div><div>HDFSHA_stop() {</div><div>    HDFSHA_monitor</div><div>    if [ $? =  $OCF_SUCCESS ]; then</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">                   </span>/opt/hadoop/sbin/hdfs-ha.sh stop</div><div>    fi</div><div>    return $OCF_SUCCESS</div><div>}</div><div><br></div><div>HDFSHA_monitor() {</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">   </span># Monitor _MUST!_ differentiate correctly between running</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">   </span># (SUCCESS), failed (ERROR) or _cleanly_ stopped (NOT RUNNING).</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">     </span># That is THREE states, not just yes/no.</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>active_nn=$(hdfs haadmin -getAllServiceState | grep active | cut -d":" -f 1)</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>current_node=$(uname -n)</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>if [[ ${active_nn} == ${current_node} ]]; then</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>    return $OCF_SUCCESS</div><div><span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>fi</div><div>}</div><div><br></div><div>HDFSHA_validate() {</div><div><br></div><div>    return $OCF_SUCCESS</div><div>}</div></div><div><br></div><div><br></div><div>I've created the resource as follows:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"># pcs resource create hdfs-ha ocf:heartbeat:HDFSHA op monitor interval=30s</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small">The resource fails right away as follows:</span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"># pcs status</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Cluster name: hdfs_cluster</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Stack: corosync</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Current DC: taulog (version 1.1.16-12.el7_4.8-94ff4df) - partition with quorum</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Last updated: Thu Apr 12 03:30:57 2018</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Last change: Thu Apr 12 03:30:54 2018 by root via cibadmin on lingcod</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">3 nodes configured</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">2 resources configured</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Online: [ dentex lingcod taulog ]</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Full list of resources:</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> VirtualIP<span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>(ocf::heartbeat:IPaddr2):<span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>Started taulog</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> hdfs-ha<span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>(ocf::heartbeat:HDFSHA):<span class="m_-6960609335043998177gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>FAILED (blocked)[ taulog dentex ]</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Failed Actions:</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">* hdfs-ha_stop_0 on taulog 'insufficient privileges' (4): call=12, status=complete, exitreason='none',</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    last-rc-change='Thu Apr 12 03:17:37 2018', queued=0ms, exec=1ms</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">* hdfs-ha_stop_0 on dentex 'insufficient privileges' (4): call=10, status=complete, exitreason='none',</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    last-rc-change='Thu Apr 12 03:17:43 2018', queued=0ms, exec=1ms</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Daemon Status:</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">  corosync: active/enabled</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">  pacemaker: active/enabled</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">


























</p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">  pcsd: active/enabled</span></p></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">I debug the resource as follows, and it returns 0<br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"># pcs resource debug-monitor hdfs-ha</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Operation monitor for hdfs-ha (ocf:heartbeat:HDFSHA) returned 0</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> >  stderr: DEBUG: hdfs-ha monitor : 0</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"># pcs resource debug-stop hdfs-ha</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Operation stop for hdfs-ha (ocf:heartbeat:HDFSHA) returned 0</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> >  stderr: DEBUG: hdfs-ha stop : 0</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"># pcs resource debug-start hdfs-ha</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Operation start for hdfs-ha (ocf:heartbeat:HDFSHA) returned 0</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> >  stderr: DEBUG: hdfs-ha start : 0</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:arial,sans-serif;font-size:small;color:rgb(34,34,34)">I don't understand what am I doing wrong!</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small">Regards,</span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small">Bishoy Mikhael</span></p></span></div></div>
<br>______________________________<wbr>_________________<br>
Users mailing list: <a href="mailto:Users@clusterlabs.org">Users@clusterlabs.org</a><br>
<a href="https://lists.clusterlabs.org/mailman/listinfo/users" rel="noreferrer" target="_blank">https://lists.clusterlabs.org/<wbr>mailman/listinfo/users</a><br>
<br>
Project Home: <a href="http://www.clusterlabs.org" rel="noreferrer" target="_blank">http://www.clusterlabs.org</a><br>
Getting started: <a href="http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf" rel="noreferrer" target="_blank">http://www.clusterlabs.org/<wbr>doc/Cluster_from_Scratch.pdf</a><br>
Bugs: <a href="http://bugs.clusterlabs.org" rel="noreferrer" target="_blank">http://bugs.clusterlabs.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">  .~.<br>  /V\<br> //  \\<br>/(   )\<br>^`~'^</div>
</div>