There is a work in progress script to automate a safe master failover from on server to another.
https://gerrit.wikimedia.org/r/#/c/operations/software/wmfmariadbpy/+/439871/
Do some production testing on passive hosts (codfw) before using for real on es1014 and db1052.