MD device name changing to include “HOSTNAME:” after first reboot. How do I get a consistent name?

On Ubuntu 18.04 I create a RAID 1 array like this:

mdadm --create /dev/md/myarray --level=1 --run --raid-devices=2 /dev/sdc /dev/sdd

I then add the output of mdadm --detail --scan /dev/md/myarray to /etc/mdadm/mdadm.conf. It looks like this:

ARRAY /dev/md/myarray metadata=1.2 name=MYHOSTNAME:myarray UUID=...

The device name has been prefixed with “MYHOSTNAME:”. At this point the symlink /dev/md/myarray still exists, but after the first time I reboot it becomes /dev/md/MYHOSTNAME:myarray, breaking things. To make it worse, this happens only on some machines – on others the symlink remains /dev/md/myarray. All are running Ubuntu 18.04, so I have no idea why.

How do I get a consistent device path for my MD device, ideally the exact one I specified (“/dev/md/myarray”)? I tried editing mdadm.conf to remove the hostname, but even if the line says

ARRAY /dev/md/myarray metadata=1.2 name=myarray UUID=...

the symlink still changes on reboot – on machines that “want” the hostname. I also tried going the other way and adding the hostname in both place:

ARRAY /dev/md/HOSTNAME:myarray metadata=1.2 name=HOSTNAME:myarray UUID=...

but again on machines that “don’t want” the hostname the symlink becomes /dev/md/myarray after a reboot!

I can’t use the numeric device (/dev/md127) either because when there are multiple MD devices created like this they tend to alternate between md126 and md127 as well! This is crazy!