Hi, everyone!
I'm trying to create a custom health check for Elasticsearch where its status is Down if an index is blocked (read-only, read-only-allow-delete, write) but I can't cover it with tests. This code doesn't work when the index is already blocked:
IndexSettings settings = new IndexSettings.Builder()
.blocks(builder -> builder.readOnly(false)
.readOnlyAllowDelete(false)
.write(false))
esClient.indices().putSettings(builder -> builder.index(INDEX_NAME).settings(settings));
In the test, I change the settings to see that the health-check status is Down
IndexSettings settings = new IndexSettings.Builder()
.blocks(builder -> builder.readOnly(true))
.build();
esClient.indices().putSettings(builder -> builder.index(INDEX_NAME).settings(settings));
But I can't reverse this operation with readOnly(false)
to reset the state and I'm wondering why? I'm having co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.put_settings] failed: [cluster_block_exception] index [test_index] blocked by: [FORBIDDEN/5/index read-only (api)];
Can someone help with this, please?