Re: [ClusterLabs] [Linux-HA] fence_ec2 agent

2015-10-01 Thread Dejan Muhamedagic
Hi Kazuhiko-san,

On Mon, Sep 28, 2015 at 02:22:02PM +0900, 東一彦 wrote:
> Hi Dejan,
> 
> I made a patch file as unified diff by "hg export tip" command.
> 
> Would you please marge it ?

Merged. I just modified a bit the summary and patch description
beforehand. Many thanks!

Cheers,

Dejan

> 
> 
> Regards,
> Kazuhiko Higashi
> 
> On 2015/09/25 0:04, Dejan Muhamedagic wrote:
> >Hi Kazuhiko-san,
> >
> >On Wed, Mar 25, 2015 at 10:47:01AM +0900, 東一彦 wrote:
> >>Hi Markus,
> >>
> >>I implemented it for trial.
> >>
> >>[diff from http://hg.linux-ha.org/glue/rev/9da0680bc9c0 ]
> >>50d49
> >>< port_default=""
> >>60c59
> >>< ec2_tag=${tag}
> >>---
> >>>[ -n "$tag" ] && ec2_tag="$tag"
> >>63d61
> >>< : ${port=${port_default}}
> >>97c95
> >><   
> >>---
> >>>   
> >>105c103
> >><   
> >>---
> >>>   
> >>132c130
> >><   
> >>---
> >>>   
> >>142c140
> >><   
> >>---
> >>>   
> >>221a220,224
> >>>function monitor()
> >>>{
> >>>   # Is the device ok?
> >>>   aws ec2 describe-instances $options | grep INSTANCES &> 
> >>> /dev/null
> >>>}
> >>267a271
> >>>[ -n "$2" ] && node_to_fence=$2
> >>326a331,334
> >>>if [ -z "$port" ]; then
> >>>   port="$node_to_fence"
> >>>fi
> >>>
> >>379,380c387
> >><   # Is the device ok?
> >><   aws ec2 describe-instances $options | grep INSTANCES &> 
> >>/dev/null
> >>---
> >>>   monitor
> >>391c398
> >><   instance_status $instance > /dev/null
> >>---
> >>>   monitor
> >>
> >>
> >>
> >>It works fine on my environment with 2 patterns settings below.
> >>
> >>[pattern No.1]
> >>Without "port" and "tag" parameters.
> >>And instances has "Name=" tag.
> >>
> >>
> >>primitive prmStonith1-2 stonith:external/ec2 \
> >>  params \
> >>  pcmk_off_timeout="120s" \
> >>  op start interval="0s" timeout="60s" \
> >>  op monitor interval="3600s" timeout="60s" \
> >>  op stop interval="0s" timeout="60s"
> >>
> >>
> >>
> >>[pattern No.2]
> >>With only "tag" parameter.(Without "port" parameter.)
> >>And, The 1st instance(node01) has "Cluster1=node01" tag.
> >>The 2nd instance(node02) has "Cluster1=node02" tag.
> >>
> >>
> >>primitive prmStonith1-2 stonith:external/ec2 \
> >>  params \
> >>  pcmk_off_timeout="120s" \
> >>  tag="Cluster1" \
> >>  op start interval="0s" timeout="60s" \
> >>  op monitor interval="3600s" timeout="60s" \
> >>  op stop interval="0s" timeout="60s"
> >>
> >
> >Sounds good. Sorry for the delay, but would it be possible that
> >you provide a patch as unified diff or similar so that we can
> >apply it.
> >
> >Cheers,
> >
> >Dejan
> >
> >>
> >>Regards,
> >>Kazuhiko Higashi
> >>
> >>
> >>On 2015/03/24 20:48, 東一彦 wrote:
> >>>Hi Markus,
> >>>
> >>>Thank you for the comment.
> >>>
> Would it be possible, to implement this idea as an additional 
> configuration method to the fence_ec2 agent?
> >>>I think that your idea is good.
> >>>
> >>>So, I tries to implement it.
> >>>I'm going to change the fence_ec2(ec2) the following points.
> >>>
> >>>  - the "tag" and the "port" options will be "not" required.
> >>>
> >>>  - if the "port" option is not set, the 2nd argument of ec2 will use as 
> >>> the "port".
> >>>- the 2nd argument of ec2 is "node to fence".
> >>>
> >>>  - the "stat" and "status" action will be same the "monitor" action.
> >>>(for do not use the "port" parameter in "stat" action.)
> >>>
> >>>
> >>>By the above modifications, If it is described uname in the Name tag,
> >>>the setting of the "tag" and "port" parameters are no longer necessary.
> >>>
> >>>
> >>>primitive prmStonith1-2 stonith:external/ec2 \
> >>> params \
> >>> pcmk_off_timeout="120s" \
> >>> op start interval="0s" timeout="60s" \
> >>> op monitor interval="3600s" timeout="60s" \
> >>> op stop interval="0s" timeout="60s"
> >>>
> >>>
> >>>
> >>>You can use "tag" parameter like your "Clustername" tag.
> >>>If cluster nodes(instances) have "Cluster1" tag, and uname is described in 
> >>>that tag,
> >>>it works just like you to expect.
> >>>
> >>>
> >>>primitive prmStonith1-2 stonith:external/ec2 \
> >>> params \
> >>> pcmk_off_timeout="120s" \
> >>> tag="Cluster1" \
> >>> op start interval="0s" timeout="60s" \
> >>> op monitor interval="3600s" timeout="60s" \
> >>> op stop interval="0s" timeout="60s"
> >>>
> >>>
> >>>The 1st instance have "Cluster1=node01" tag-key.
> >>>The 2nd instance have "Cluster1=node02" tag-key.
> >>>The 3rd instance have "Cluster1=node03" tag-key.
> >>>...
> >>>The prmStonith1-2 can fence node01 , node02 and node03.
> >>>
> >>>
> >>>If you like above, I will implement that.
> >>>
> >>>
> >>>Regards,
> >>>Kazuhiko Higashi
> >>>
> >>>
> >>>On 2015/03/19 1:03, Markus Guertler wrote:
> Hi Kazuhiko, Dejan,
> 

Re: [ClusterLabs] [Linux-HA] fence_ec2 agent

2015-09-27 Thread 東一彦

Hi Dejan,

I made a patch file as unified diff by "hg export tip" command.

Would you please marge it ?


Regards,
Kazuhiko Higashi

On 2015/09/25 0:04, Dejan Muhamedagic wrote:

Hi Kazuhiko-san,

On Wed, Mar 25, 2015 at 10:47:01AM +0900, 東一彦 wrote:

Hi Markus,

I implemented it for trial.

[diff from http://hg.linux-ha.org/glue/rev/9da0680bc9c0 ]
50d49
< port_default=""
60c59
< ec2_tag=${tag}
---

[ -n "$tag" ] && ec2_tag="$tag"

63d61
< : ${port=${port_default}}
97c95
<   
---

   

105c103
<   
---

   

132c130
<   
---

   

142c140
<   
---

   

221a220,224

function monitor()
{
   # Is the device ok?
   aws ec2 describe-instances $options | grep INSTANCES &> /dev/null
}

267a271

[ -n "$2" ] && node_to_fence=$2

326a331,334

if [ -z "$port" ]; then
   port="$node_to_fence"
fi


379,380c387
<   # Is the device ok?
<   aws ec2 describe-instances $options | grep INSTANCES &> 
/dev/null
---

   monitor

391c398
<   instance_status $instance > /dev/null
---

   monitor




It works fine on my environment with 2 patterns settings below.

[pattern No.1]
Without "port" and "tag" parameters.
And instances has "Name=" tag.


primitive prmStonith1-2 stonith:external/ec2 \
  params \
  pcmk_off_timeout="120s" \
  op start interval="0s" timeout="60s" \
  op monitor interval="3600s" timeout="60s" \
  op stop interval="0s" timeout="60s"



[pattern No.2]
With only "tag" parameter.(Without "port" parameter.)
And, The 1st instance(node01) has "Cluster1=node01" tag.
The 2nd instance(node02) has "Cluster1=node02" tag.


primitive prmStonith1-2 stonith:external/ec2 \
  params \
  pcmk_off_timeout="120s" \
  tag="Cluster1" \
  op start interval="0s" timeout="60s" \
  op monitor interval="3600s" timeout="60s" \
  op stop interval="0s" timeout="60s"



Sounds good. Sorry for the delay, but would it be possible that
you provide a patch as unified diff or similar so that we can
apply it.

Cheers,

Dejan



Regards,
Kazuhiko Higashi


On 2015/03/24 20:48, 東一彦 wrote:

Hi Markus,

Thank you for the comment.


Would it be possible, to implement this idea as an additional configuration 
method to the fence_ec2 agent?

I think that your idea is good.

So, I tries to implement it.
I'm going to change the fence_ec2(ec2) the following points.

  - the "tag" and the "port" options will be "not" required.

  - if the "port" option is not set, the 2nd argument of ec2 will use as the 
"port".
- the 2nd argument of ec2 is "node to fence".

  - the "stat" and "status" action will be same the "monitor" action.
(for do not use the "port" parameter in "stat" action.)


By the above modifications, If it is described uname in the Name tag,
the setting of the "tag" and "port" parameters are no longer necessary.


primitive prmStonith1-2 stonith:external/ec2 \
 params \
 pcmk_off_timeout="120s" \
 op start interval="0s" timeout="60s" \
 op monitor interval="3600s" timeout="60s" \
 op stop interval="0s" timeout="60s"



You can use "tag" parameter like your "Clustername" tag.
If cluster nodes(instances) have "Cluster1" tag, and uname is described in that 
tag,
it works just like you to expect.


primitive prmStonith1-2 stonith:external/ec2 \
 params \
 pcmk_off_timeout="120s" \
 tag="Cluster1" \
 op start interval="0s" timeout="60s" \
 op monitor interval="3600s" timeout="60s" \
 op stop interval="0s" timeout="60s"


The 1st instance have "Cluster1=node01" tag-key.
The 2nd instance have "Cluster1=node02" tag-key.
The 3rd instance have "Cluster1=node03" tag-key.
...
The prmStonith1-2 can fence node01 , node02 and node03.


If you like above, I will implement that.


Regards,
Kazuhiko Higashi


On 2015/03/19 1:03, Markus Guertler wrote:

Hi Kazuhiko, Dejan,

the new resource agent is very good. Since there were a couple of days between 
my original question and the answer from
Kazuhiko, I also have written a stonith agent proof of concept (attached to 
this email) in order to continue in my
project. However, I think that your fence_ec2 agent is better from a 
development perspective and it doesn't make sense
to have two different agents for the same use case.

Nevertheless, I've implemented an idea, that is very useful in EC2 environments 
with clusters that have more than two
nodes: All EC2 instances that belong to a cluster get a unique cluster name via 
an EC2 instance tag. The agent uses this
tag to determine all cluster nodes that belong to his own cluster

--- SNIP ---
 gethosts)
 # List of hostnames of this cluster
 init_agent
 ec2-describe-instances --filter "tag-key=Clustername" --filter 
"tag-value=$clustername" | grep "^TAG" |grep

Re: [ClusterLabs] [Linux-HA] fence_ec2 agent

2015-09-24 Thread Dejan Muhamedagic
Hi Kazuhiko-san,

On Wed, Mar 25, 2015 at 10:47:01AM +0900, 東一彦 wrote:
> Hi Markus,
> 
> I implemented it for trial.
> 
> [diff from http://hg.linux-ha.org/glue/rev/9da0680bc9c0 ]
> 50d49
> < port_default=""
> 60c59
> < ec2_tag=${tag}
> ---
> > [ -n "$tag" ] && ec2_tag="$tag"
> 63d61
> < : ${port=${port_default}}
> 97c95
> <   
> ---
> >   
> 105c103
> <   
> ---
> >   
> 132c130
> <   
> ---
> >   
> 142c140
> <   
> ---
> >   
> 221a220,224
> > function monitor()
> > {
> >   # Is the device ok?
> >   aws ec2 describe-instances $options | grep INSTANCES &> 
> > /dev/null
> > }
> 267a271
> > [ -n "$2" ] && node_to_fence=$2
> 326a331,334
> > if [ -z "$port" ]; then
> >   port="$node_to_fence"
> > fi
> >
> 379,380c387
> <   # Is the device ok?
> <   aws ec2 describe-instances $options | grep INSTANCES &> 
> /dev/null
> ---
> >   monitor
> 391c398
> <   instance_status $instance > /dev/null
> ---
> >   monitor
> 
> 
> 
> It works fine on my environment with 2 patterns settings below.
> 
> [pattern No.1]
> Without "port" and "tag" parameters.
> And instances has "Name=" tag.
> 
> 
> primitive prmStonith1-2 stonith:external/ec2 \
>  params \
>  pcmk_off_timeout="120s" \
>  op start interval="0s" timeout="60s" \
>  op monitor interval="3600s" timeout="60s" \
>  op stop interval="0s" timeout="60s"
> 
> 
> 
> [pattern No.2]
> With only "tag" parameter.(Without "port" parameter.)
> And, The 1st instance(node01) has "Cluster1=node01" tag.
> The 2nd instance(node02) has "Cluster1=node02" tag.
> 
> 
> primitive prmStonith1-2 stonith:external/ec2 \
>  params \
>  pcmk_off_timeout="120s" \
>  tag="Cluster1" \
>  op start interval="0s" timeout="60s" \
>  op monitor interval="3600s" timeout="60s" \
>  op stop interval="0s" timeout="60s"
> 

Sounds good. Sorry for the delay, but would it be possible that
you provide a patch as unified diff or similar so that we can
apply it.

Cheers,

Dejan

> 
> Regards,
> Kazuhiko Higashi
> 
> 
> On 2015/03/24 20:48, 東一彦 wrote:
> >Hi Markus,
> >
> >Thank you for the comment.
> >
> > > Would it be possible, to implement this idea as an additional 
> > > configuration method to the fence_ec2 agent?
> >I think that your idea is good.
> >
> >So, I tries to implement it.
> >I'm going to change the fence_ec2(ec2) the following points.
> >
> >  - the "tag" and the "port" options will be "not" required.
> >
> >  - if the "port" option is not set, the 2nd argument of ec2 will use as the 
> > "port".
> >- the 2nd argument of ec2 is "node to fence".
> >
> >  - the "stat" and "status" action will be same the "monitor" action.
> >(for do not use the "port" parameter in "stat" action.)
> >
> >
> >By the above modifications, If it is described uname in the Name tag,
> >the setting of the "tag" and "port" parameters are no longer necessary.
> >
> >
> >primitive prmStonith1-2 stonith:external/ec2 \
> > params \
> > pcmk_off_timeout="120s" \
> > op start interval="0s" timeout="60s" \
> > op monitor interval="3600s" timeout="60s" \
> > op stop interval="0s" timeout="60s"
> >
> >
> >
> >You can use "tag" parameter like your "Clustername" tag.
> >If cluster nodes(instances) have "Cluster1" tag, and uname is described in 
> >that tag,
> >it works just like you to expect.
> >
> >
> >primitive prmStonith1-2 stonith:external/ec2 \
> > params \
> > pcmk_off_timeout="120s" \
> > tag="Cluster1" \
> > op start interval="0s" timeout="60s" \
> > op monitor interval="3600s" timeout="60s" \
> > op stop interval="0s" timeout="60s"
> >
> >
> >The 1st instance have "Cluster1=node01" tag-key.
> >The 2nd instance have "Cluster1=node02" tag-key.
> >The 3rd instance have "Cluster1=node03" tag-key.
> >...
> >The prmStonith1-2 can fence node01 , node02 and node03.
> >
> >
> >If you like above, I will implement that.
> >
> >
> >Regards,
> >Kazuhiko Higashi
> >
> >
> >On 2015/03/19 1:03, Markus Guertler wrote:
> >>Hi Kazuhiko, Dejan,
> >>
> >>the new resource agent is very good. Since there were a couple of days 
> >>between my original question and the answer from
> >>Kazuhiko, I also have written a stonith agent proof of concept (attached to 
> >>this email) in order to continue in my
> >>project. However, I think that your fence_ec2 agent is better from a 
> >>development perspective and it doesn't make sense
> >>to have two different agents for the same use case.
> >>
> >>Nevertheless, I've implemented an idea, that is very useful in EC2 
> >>environments with clusters that have more than two
> >>nodes: All EC2 instances that belong to a cluster get a unique cluster name 
> >>via an EC2 instance tag. The agent uses this
> >>tag to determine all clust