Percona-Lab/pacemaker-replication-agents

Failed Detection of Ticket Leader when there are Multiple Tickets

Closed this issue · 4 comments

If I have multiple tickets on a single GEO setup, detection of is_master_side from the agent always returns true if one of the ticket is granted on the site:

[root@node ~]# booth client list
ticket: ticketSessions, leader: 192.168.56.96, expires: 2014-09-05 01:38:24
ticket: ticketHistorical, leader: 192.168.56.97, expires: 2014-09-05 01:38:39

Here's an excerpt from the trace file, the problem is that newlines from the output is being removed:

+ is_master_side
+ local ticket crmTicketRet
+ '[' 13 -gt 0 ']'
++ /usr/sbin/crm_ticket --info
+ crmTicketRet='ticketHistorical        granted           last-granted='\''Fri Sep  5 00:26:37 2014'\''
ticketSessions  revoked           last-granted='\''Fri Sep  5 00:17:16 2014'\'''
+ '[' 0 -ne 0 ']'
++ grep -c granted
++ awk '{ print $2 }'
++ grep ticketSessions
++ echo ticketHistorical granted 'last-granted='\''Fri' Sep 5 00:26:37 '2014'\''' ticketSessions revoked 'last-granted='\''Fri' Sep 5 00:17:16 '2014'\'''
+ ticket=1
+ '[' 1 -eq 1 ']'
+ return 0
+ glb_master_side=0
+ '[' 13 -gt 0 -a 0 -ne 0 ']'

Here is a simpler test case:

[root@node ~]# crmTicket=`crm_ticket --info 2> /dev/null`
[root@node ~]# echo $crmTicket | grep ticketSessions |awk '{ print $2 }' | grep -c granted
1
[root@node ~]# echo $crmTicket
ticketHistorical granted last-granted='Fri Sep 5 00:26:37 2014' ticketSessions revoked last-granted='Fri Sep 5 00:17:16 2014'
[root@node ~]#

Submitted PR #24

I now understand why you went the PIPESTATUS way. I'll modify the test for the version, I could use "file" like:

[root@db ~]# file /usr/sbin/crm_ticket
/usr/sbin/crm_ticket: Bourne-Again shell script text executable

only the old version is a shell script.

I modified using file test, the grep for the ticket is now not on the variable but on the command line, that should filter correctly the multiple tickets, please confirm.