### CI Link

https://gradle-enterprise.elastic.co/s/yp56iltyyinha

### Repro line

./gradlew ':x-pack:plugin:ilm:qa:multi-node:javaRestTest' --tests "org.elasticsearch.xpack.ilm.ChangePolicyforIndexIT.testChangePolicyForIndex" -Dtests.seed=8825024EAE3089DD -Dtests.locale=en-PH -Dtests.timezone=Asia/Karachi -Druntime.java=16

### Does it reproduce?

No

### Applicable branches

7.17 (probably all 8+)

### Failure history

_No response_

### Failure excerpt

This is rather concerning
```
java.lang.AssertionError: policy step registry cache failed sanity check
	at org.elasticsearch.xpack.ilm.PolicyStepsRegistry.getStep(PolicyStepsRegistry.java:378) ~[?:?]
	at org.elasticsearch.xpack.ilm.IndexLifecycleRunner.getCurrentStep(IndexLifecycleRunner.java:108) ~[?:?]
	at org.elasticsearch.xpack.ilm.IndexLifecycleRunner.runPolicyAfterStateChange(IndexLifecycleRunner.java:430) ~[?:?]
	at org.elasticsearch.xpack.ilm.IndexLifecycleService.triggerPolicies(IndexLifecycleService.java:416) ~[?:?]
	at org.elasticsearch.xpack.ilm.IndexLifecycleService.clusterChanged(IndexLifecycleService.java:319) ~[?:?]
	at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateListener(ClusterApplierService.java:573) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateListeners(ClusterApplierService.java:559) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.cluster.service.ClusterApplierService.applyChanges(ClusterApplierService.java:519) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.cluster.service.ClusterApplierService.runTask(ClusterApplierService.java:428) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.cluster.service.ClusterApplierService.access$000(ClusterApplierService.java:56) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.cluster.service.ClusterApplierService$UpdateTask.run(ClusterApplierService.java:154) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:718) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:262) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:225) ~[elasticsearch-7.17.2-SNAPSHOT.jar:7.17.2-SNAPSHOT]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]
[2022-03-15T09:34:09.657115416Z] [BUILD] Stopping node
```
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java
.nodes(DiscoveryNodes.builder().localNodeId(nodeId).masterNodeId(nodeId).add(masterNode).build())
                .build();
            registry.update(currentState.metadata().custom(IndexLifecycleMetadata.TYPE));
            assertThat(registeredStepsForPolicy.get(step.getKey()), equalTo(step));
            assertThat(registry.getStep(metadata.index(index), step.getKey()), equalTo(step));
        }
        Map<String, LifecyclePolicyMetadata> registryPolicyMap = registry.getLifecyclePolicyMap();
        Map<String, Step> registryFirstStepMap = registry.getFirstStepMap();
        Map<String, Map<Step.StepKey, Step>> registryStepMap = registry.getStepMap();
        registry.update(currentState.metadata().custom(IndexLifecycleMetadata.TYPE));
        assertThat(registry.getLifecyclePolicyMap(), equalTo(registryPolicyMap));
        assertThat(registry.getFirstStepMap(), equalTo(registryFirstStepMap));
        assertThat(registry.getStepMap(), equalTo(registryStepMap));
        
        lifecycleMetadata = new IndexLifecycleMetadata(Collections.emptyMap(), OperationMode.RUNNING);
        currentState = ClusterState.builder(currentState)
            .metadata(Metadata.builder(metadata).putCustom(IndexLifecycleMetadata.TYPE, lifecycleMetadata))
            .build();
        registry.update(currentState.metadata().custom(IndexLifecycleMetadata.TYPE));
        assertTrue(registry.getLifecyclePolicyMap().isEmpty());
        assertTrue(registry.getFirstStepMap().isEmpty());
        assertTrue(registry.getStepMap().isEmpty());
    }
    public void testUpdateChangedPolicy() {
        Client client = mock(Client.class);
        Mockito.when(client.settings()).thenReturn(Settings.EMPTY);
        String policyName = randomAlphaOfLengthBetween(5, 10);
        LifecyclePolicy newPolicy = LifecyclePolicyTests.randomTestLifecyclePolicy(policyName);
        Map<String, String> headers = new HashMap<>();
        if (randomBoolean()) {