This is the x-pack side of elastic/elasticsearch#25486. Original commit: elastic/x-pack-elasticsearch@c90a3e096b