ClusterLabs / fence-agents

Fence agents
104 stars 160 forks source link

fence_kdump: chained -v flags are not recognized #429

Closed nrwahl2 closed 3 years ago

nrwahl2 commented 3 years ago

Demo:

[root@fastvm-rhel-8-0-23 pacemaker]# fence_kdump -vv -n node2
[debug]: waiting for message from '192.168.22.24'
^C

[root@fastvm-rhel-8-0-23 pacemaker]# fence_kdump -v -v -n node2
[debug]: options {        
[debug]:     nodename = node2
[debug]:     ipport   = 7410
[debug]:     family   = 0
[debug]:     count    = 0
[debug]:     interval = 10
[debug]:     timeout  = 60
[debug]:     verbose  = 2
[debug]: }                
[debug]: node {       
[debug]:     name = node2
[debug]:     addr = 192.168.22.24
[debug]:     port = 7410
[debug]:     info = 0x55699847de70
[debug]: }            
[debug]: waiting for message from '192.168.22.24'
^C

[root@fastvm-rhel-8-0-23 pacemaker]# fence_kdump -v 2 -n node2
[debug]: options {        
[debug]:     nodename = node2
[debug]:     ipport   = 7410
[debug]:     family   = 0
[debug]:     count    = 0
[debug]:     interval = 10
[debug]:     timeout  = 60
[debug]:     verbose  = 1
[debug]: }                
[debug]: node {       
[debug]:     name = node2
[debug]:     addr = 192.168.22.24
[debug]:     port = 7410
[debug]:     info = 0x56176cf95e70
[debug]: }            
[debug]: waiting for message from '192.168.22.24'

I assume this is a quirk of getopt and I'm not sure if there's a way to fix it as long as verbose takes an optional argument. I don't have time to look further into it right now, so I'm just documenting it here.

oalbrigt commented 3 years ago

That's strange. -vv seems to be working fine for me.

nrwahl2 commented 3 years ago

I think the issue is that it's trying to set the verbosity level to "v", which isn't a number and thus gets converted to 0.

oalbrigt commented 3 years ago

Oh. It's fence_kdump. I thought it was the other agents using the library.

Yeah, that might be the issue.

oalbrigt commented 3 years ago

Ah. I see the issue. Shouldnt be hard to fix.

oalbrigt commented 3 years ago

Just use a counter if optarg is NULL: https://github.com/ClusterLabs/fence-agents/blob/master/agents/kdump/fence_kdump.c#L453-L455

nrwahl2 commented 3 years ago

I think the second v is treated as optarg.

oalbrigt commented 3 years ago

Yep. Coffee didnt get to my brain yet. So I guess if optarg isnt int we'll have to do a for to count the v's.

oalbrigt commented 3 years ago

I've made a PR that should solve the issue. Tell me if it's adecuate, or if there's any edge cases worth adding logic for.