Skip to content

Commit

Permalink
Update iptables calls with -w
Browse files Browse the repository at this point in the history
If iptables is currently being called outside of the ocf script, the
iptables call will fail because it cannot get a lock. This change
updates the iptables call to include the -w flag which will wait until
the lock can be established and not just exit with an error.
  • Loading branch information
Alex Schultz committed Aug 15, 2016
1 parent 87a214d commit 8c9cf68
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/rabbitmq-server-ha.ocf
Expand Up @@ -691,7 +691,7 @@ block_client_access()
# do not add temporary RMQ blocking rule, if it is already exist
# otherwise, try to add a blocking rule with max of 5 retries
local tries=5
until $(iptables -nvL | grep -q 'temporary RMQ block') || [ $tries -eq 0 ]; do
until $(iptables -nvwL | grep -q 'temporary RMQ block') || [ $tries -eq 0 ]; do
tries=$((tries-1))
iptables -I INPUT -p tcp -m tcp --dport ${OCF_RESKEY_node_port} -m state --state NEW,RELATED,ESTABLISHED \
-m comment --comment 'temporary RMQ block' -j REJECT --reject-with tcp-reset
Expand All @@ -707,7 +707,7 @@ block_client_access()
unblock_client_access()
{
# remove all temporary RMQ blocking rules, if there are more than one exist
for i in $(iptables -nvL --line-numbers | awk '/temporary RMQ block/ {print $1}'); do
for i in $(iptables -nvwL --line-numbers | awk '/temporary RMQ block/ {print $1}'); do
iptables -D INPUT -p tcp -m tcp --dport ${OCF_RESKEY_node_port} -m state --state NEW,RELATED,ESTABLISHED \
-m comment --comment 'temporary RMQ block' -j REJECT --reject-with tcp-reset
done
Expand Down

0 comments on commit 8c9cf68

Please sign in to comment.