Solved [Solved] Upgrade to v10 CARP and HAST with new devd.conf

Hi All,

I have upgraded 1 of the 2 FreeBSD that are working in failover for the moment from 9.3 -> 10. The other one is still on 9.3. I modify the CARP config on /etc/rc.conf to work with V10 and CARP is working pretty well. The problem that I have is with the configuration of devd.conf. Before I was using this config devd.conf:
Code:
notify 30 {
	match "system" "IFNET";
	match "subsystem" "carp0";
	match "type" "LINK_UP";
	action "/usr/local/sbin/carp-hast-switch master";
};

notify 30 {
	match "system" "IFNET";
	match "subsystem" "carp0";
	match "type" "LINK_DOWN";
	action "/usr/local/sbin/carp-hast-switch slave";
};

I have seen that configuration of devd() changed for the V10 in this URL http://www.freebsd.org/cgi/man.cgi?...=FreeBSD+10.0-stable&arch=default&format=html. I change a little bit to fit and changed the carp-hast-switch to work with MASTER and BACKUP arguments:
Code:
	   notify 0 {
		   match "system"	   "CARP";
		   match "subsystem"	   "[0-9]+@[0-9a-z]+";
		   match "type"		   "(MASTER|BACKUP)";
		   action "/usr/local/sbin/carp-hast-switch	$type";
	   };

On this URL http://www.freebsd.org/doc/handbook/disks-hast.html it's written that I just should keep the name of the CARP-configured interface and so keep the old devd() config. Something like:
Code:
notify 30 {
	match "system" "IFNET";
	match "subsystem" "em0_alias0";
	match "type" "LINK_UP";
	action "/usr/local/sbin/carp-hast-switch MASTER";
};

notify 30 {
	match "system" "IFNET";
	match "subsystem" "em0_alias0";
	match "type" "LINK_DOWN";
	action "/usr/local/sbin/carp-hast-switch BACKUP";
};


I tried both configs and it doesn't work. When I run the script /usr/local/sbin/carp-hast-switch MASTER/BACKUP it works perfectly. The Master and Backup state of my CARP switch also perfectly.

My last question is about the place of the devd.conf. On 9.3 it was working at this place /usr/local/etc/devd/devd.conf, on V10 I tried /usr/local/etc/devd/devd.conf and add at the end of /etc/devd.conf without success.

I'm sure I'm close to the solution but I haven't seen a lot of doc on the net and I have nothing on the /var/log/messages that can help me.

Thanks,
 
I'm not experienced on the carp side of things but checking for link up/down status on an interface alias seems strange to me. Link status relates to the port so you may as well just tie the events to em0 itself.

My initial thought would be to put devd in debug mode and actually see what events are logged when you emulate the master failing (unplug master and watch events on backup). That way you can see what events devd is raising and the system/subsystem/type details. Assuming events are actually triggered in relation to your carp interface, it shouldn't take much to write the devd rules from there.

From what I can see, you're almost certainly going to want to use the new 'CARP' devd rules instead of the 'IFNET' ones. em0 and em0_alias0 will be in the UP state on both machines at the same time. The old system had an independent carpX interface that was DOWN when in slave mode, and UP in master mode, so you could use the UP/DOWN state to toggle your applications. In the new method, carp is configured directly on the real interface, which is always going to be in the UP state, so they've provided new devd events to notify when the carp state changes.

Regarding the last question, I don't see that anything has changed regarding the path to devd configuration files.
/etc/devd.conf contains the following which, to me, suggests that it will read all files in the listed directories. So you could call your file /usr/local/etc/devd/carp.conf, and it should be processed. This is backed up by the fact that the first directory, /etc/devd, contains a few built-in configuration files with various names.

Code:
	# Each "directory" directive adds a directory to the list of
	# directories that we scan for files.  Files are loaded in the order
	# that they are returned from readdir(3).  The rule-sets are combined
	# to create a DFA that's used to match events to actions.
	directory "/etc/devd";
	directory "/usr/local/etc/devd";

If your rules are not processed, I would expect that to be one of the following:

  • An error in the file causing devd to ignore it
  • The rules being wrong so they don't actually match anything
  • Permissions on the file. I wouldn't be surprised if devd ignores files that have dangerous permissions. You don't want any old user being able to mess with your devd rules... (although I'd expect something in /var/log/messages)
 
You save my day. It's helped me a lot saying devd can't use the interface up and down anymore because this interface doesn't exist (logical but I didn't realise that).

With stopping the service and running devd in the command line with debug mode devd -d I saw that it was calling my command. I tried so much configuration and maybe I didn't restart the service correctly with the good configuration.

Here is the good devd configuration for freebsd FreeBSD 10 if it can help someone else:
Create file /usr/local/etc/devd/devd.conf
Code:
     match "system"      "CARP";
     match "subsystem"      "[0-9]+@[0-9a-z]+";
     match "type"         "(MASTER|BACKUP)";
     action "/usr/local/sbin/carp-hast-switch   $type";
    };

Is it possible to edit the http://www.freebsd.org/doc/handbook/disks-hast.html where the note (18.14.2.1. Failover Configuration) about V10 is not correct. I don't know who can edit that :s

Thanks again !
 
No problem, glad you got it sorted.

I see what you mean about the note in the handbook now, and why you tried what you did. I hadn't read it previously.

Out of interest, did you see what the subsystem came up as while you were testing? In a system with multiple CARP interfaces, you'd need to use that to determine which CARP address the event relates to. Looking at the format (numbers following by @, followed by numbers/letters), it's not obvious to me what that would be. My best guess would be vhid@interface
 
Back
Top