Fix init with elasticsearch and companion reindex
AbstractElasticIndex: use the real (raw) index name in markReady
(setReady, towards index config), rather than the one formatted with
prefix and version suffix. Indeed, setReady assumes no prefix in index
config and already appends the version -independently of the raw index
name.
Concatenating the prefix with index names (alongside versions) is
already assumed internally within gerrit when interacting with its
Elasticsearch indices. Such a dynamic, on-the-fly behaviour is based on:
1. the prefix -for this site instance, configured in gerrit.config, and
2. index names with version suffixes, configured in gerrit_index.config.
VersionManager classes: align the Elasticsearch implementation with the
one for Lucene. Namely, make the 'dirtiness' of Elastic versions
consistent with Lucene's. Meaning, align the existence nature of an
index between the two implementations: have an Elasticsearch index exist
only if part of the Elasticsearch server indices, even if listed as a
known schema version. The lucene implementation does this through the
existence of a corresponding index directory, within the site.
Before the aforementioned co-fixes, reindexing a site just initialized
with elasticsearch failed, by means of extra indices generated within
gerrit_index.config:
1. some with previous schema versions and ready = false set for them,
2. and some others with wrongfully prefixed index names, which also had
their version suffix doubled; e.g., [index "gerrit_changes_0039_0039"],
which reads [index "changes_0039"] and appears only once after this fix
(also expectedly set as ready = true).
The above sample exposes the fact that such a 'gerrit_' prefix does not
match the default 'gerrit' (no trailing underscore). A follow-up change
could consider changing that default to a more readable gerrit_ prefix.
The current Elasticsearch implementation still requires a reindex after
a site init, as per the ui console message already shown -telling the
init user about such a necessity. So, a reindex is required in order to
generate gerrit_index.config after an init, and this very change is to
properly generate that file, for the site to work with Elasticsearch.
Bug: Issue 8553
Change-Id: I33d0f02fcca1bacb9d66c57f3d0bc3fa3b233197
5 files changed