### CI Link

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

### Repro line

./gradlew ':x-pack:qa:full-cluster-restart:v7.0.0#bwcTest' -Dtests.class="org.elasticsearch.xpack.restart.MlHiddenIndicesFullClusterRestartIT" -Dtests.method="testMlIndicesBecomeHidden {cluster=OLD}" -Dtests.seed=5D8A0FD3D02DB77A -Dtests.bwc=true -Dtests.locale=nl-NL -Dtests.timezone=US/Central -Druntime.java=17

### Does it reproduce?

Didn't try

### Applicable branches

main, 8.6

### Failure history

_No response_

### Failure excerpt

[2023-02-06T03:51:59,572][WARN ][r.suppressed             ] [test-cluster-1] path: /_ml/anomaly_detectors/ml-hidden-indices-old-cluster-job/_open, params: {job_id=ml-hidden-indices-old-cluster-job}
org.elasticsearch.transport.RemoteTransportException: [test-cluster-0][127.0.0.1:46061][cluster:admin/xpack/ml/job/open]
Caused by: org.elasticsearch.ElasticsearchException: Unexpected job state [failed] while waiting for job to be opened
	at org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper.serverError(ExceptionsHelper.java:38) ~[?:?]
	at org.elasticsearch.xpack.ml.action.TransportOpenJobAction$JobPredicate.test(TransportOpenJobAction.java:779) ~[?:?]
	at org.elasticsearch.xpack.ml.action.TransportOpenJobAction$JobPredicate.test(TransportOpenJobAction.java:733) ~[?:?]
	at org.elasticsearch.persistent.PersistentTasksService.lambda$waitForPersistentTaskCondition$2(PersistentTasksService.java:155) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.clusterChanged(ClusterStateObserver.java:188) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.cluster.service.ClusterApplierService.lambda$callClusterStateListeners$6(ClusterApplierService.java:486) ~[elasticsearch-7.0.0.jar:7.0.0]
	at java.util.concurrent.ConcurrentHashMap$KeySpliterator.forEachRemaining(ConcurrentHashMap.java:3566) ~[?:?]
	at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?]
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[?:?]
	at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateListeners(ClusterApplierService.java:483) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.cluster.service.ClusterApplierService.applyChanges(ClusterApplierService.java:472) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.cluster.service.ClusterApplierService.runTask(ClusterApplierService.java:413) ~[elasticsearch-7.0.0.jar:7.0.0]
[2023-02-06T03:51:59,572][WARN ][o.e.p.PersistentTasksNodeService] [test-cluster-0] task job-ml-hidden-indices-old-cluster-job failed with an exception
	at org.elasticsearch.cluster.service.ClusterApplierService$UpdateTask.run(ClusterApplierService.java:164) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:681) ~[elasticsearch-7.0.0.jar:7.0.0]
org.elasticsearch.ElasticsearchException: Failed to launch autodetect for job ml-hidden-indices-old-cluster-job
	at org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper.serverError(ExceptionsHelper.java:42) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createNativeProcess(NativeAutodetectProcessFactory.java:115) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createAutodetectProcess(NativeAutodetectProcessFactory.java:65) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.create(AutodetectProcessManager.java:558) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.createProcessAndSetRunning(AutodetectProcessManager.java:514) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.access$200(AutodetectProcessManager.java:101) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager$3.doRun(AutodetectProcessManager.java:465) ~[?:?]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-7.0.0.jar:7.0.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:835) [?:?]
Caused by: java.io.FileNotFoundException: Cannot open /var/lib/jenkins/workspace/elastic+elasticsearch+main+multijob+platform-support-unix/x-pack/qa/full-cluster-restart/build/testrun/v7.0.0_bwcTest/temp/org.elasticsearch.xpack.restart.MlHiddenIndicesFullClusterRestartIT/test-cluster/test-cluster-0/tmp/autodetect_ml-hidden-indices-old-cluster-job_input_620131 (No such file or directory)
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStreamUnix(NamedPipeHelper.java:249) ~[?:?]
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStream(NamedPipeHelper.java:174) ~[?:?]
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStream(NamedPipeHelper.java:160) ~[?:?]
	at org.elasticsearch.xpack.ml.process.ProcessPipes.connectStreams(ProcessPipes.java:137) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createNativeProcess(NativeAutodetectProcessFactory.java:111) ~[?:?]
	... 10 more
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252) ~[elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215) ~[elasticsearch-7.0.0.jar:7.0.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	at java.lang.Thread.run(Thread.java:835) [?:?]
[2023-02-06T03:51:59,593][WARN ][o.e.p.PersistentTasksClusterService] [test-cluster-0] persistent task job-ml-hidden-indices-old-cluster-job failed
org.elasticsearch.ElasticsearchException: Failed to launch autodetect for job ml-hidden-indices-old-cluster-job
	at org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper.serverError(ExceptionsHelper.java:42) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createNativeProcess(NativeAutodetectProcessFactory.java:115) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createAutodetectProcess(NativeAutodetectProcessFactory.java:65) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.create(AutodetectProcessManager.java:558) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.createProcessAndSetRunning(AutodetectProcessManager.java:514) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager.access$200(AutodetectProcessManager.java:101) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager$3.doRun(AutodetectProcessManager.java:465) ~[?:?]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-7.0.0.jar:7.0.0]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.0.jar:7.0.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:835) [?:?]
Caused by: java.io.FileNotFoundException: Cannot open /var/lib/jenkins/workspace/elastic+elasticsearch+main+multijob+platform-support-unix/x-pack/qa/full-cluster-restart/build/testrun/v7.0.0_bwcTest/temp/org.elasticsearch.xpack.restart.MlHiddenIndicesFullClusterRestartIT/test-cluster/test-cluster-0/tmp/autodetect_ml-hidden-indices-old-cluster-job_input_620131 (No such file or directory)
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStreamUnix(NamedPipeHelper.java:249) ~[?:?]
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStream(NamedPipeHelper.java:174) ~[?:?]
	at org.elasticsearch.xpack.ml.utils.NamedPipeHelper.openNamedPipeOutputStream(NamedPipeHelper.java:160) ~[?:?]
	at org.elasticsearch.xpack.ml.process.ProcessPipes.connectStreams(ProcessPipes.java:137) ~[?:?]
	at org.elasticsearch.xpack.ml.job.process.autodetect.NativeAutodetectProcessFactory.createNativeProcess(NativeAutodetectProcessFactory.java:111) ~[?:?]
	... 10 more
[2023-02-06T03:51:59,640][INFO ][o.e.x.r.MlHiddenIndicesFullClusterRestartIT] [testMlIndicesBecomeHidden] [cluster=OLD] after test
REPRODUCE WITH: ./gradlew ':x-pack:qa:full-cluster-restart:v7.0.0#bwcTest' -Dtests.class="org.elasticsearch.xpack.restart.MlHiddenIndicesFullClusterRestartIT" -Dtests.method="testMlIndicesBecomeHidden {cluster=OLD}" -Dtests.seed=5D8A0FD3D02DB77A -Dtests.bwc=true -Dtests.locale=nl-NL -Dtests.timezone=US/Central -Druntime.java=17
x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/MlHiddenIndicesFullClusterRestartIT.java
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */
package org.elasticsearch.xpack.restart;
import com.carrotsearch.randomizedtesting.annotations.Name;