Hello,
I'd like to raise a possible problem I recently ran into in an internal application, and which I see the current Curator implementation mirrors as well (curator/curator/utils.py at v5.8.4 · elastic/curator · GitHub, lines 1744–1756).
Although I've read the documentation (Restore a snapshot | Elasticsearch Guide [7.17] | Elastic), it's not clear to me how exactly you can make sure a RESTORE has completed successfully.
I assume a combination of REST requests is needed, and I'd like to confirm that my understanding is correct.
From what I understand, the following mechanism would be required.
GET my-index/_recovery
=> this returns stages such as INIT/INDEX/VERIFY_INDEX/TRANSLOG/FINALIZE/DONE, but there is no FAILED value.
The trap: if all the shards in the response show DONE, that does not automatically mean the restore finished successfully. Why? Because shards that fail disappear from the response (the shard is deallocated — UNASSIGNED/ALLOCATION_FAILED — and drops out of the /_recovery response entirely). So if a shard failed, you will not get that information from this endpoint. It will tell you that all the remaining shards are DONE, but that does not mean the restore succeeded.
From what I've read in the documentation, a possible and correct solution would be to continue the verification:
GET _cluster/health
If we get GREEN or YELLOW after _recovery has shown the snapshot recoveries completed, then all primary shards are allocated and the restore is complete.
If the status is RED, there are 2 cases:
- the error is recoverable
- the error is not recoverable
To find out which case we are in, we need to callGET _cluster/allocation/explainand interpret the data there.
However, both our internal implementation and the one in Curator assume that if all stages are "DONE" in the GET /_recovery response, the restore finished successfully.
This is not true when dealing with errors such as IOException: No space left on device.
Versions: Elasticsearch 7.17.27, RHEL 9