8
8
package org .elasticsearch .xpack .searchablesnapshots .action ;
9
9
10
10
import org .elasticsearch .ElasticsearchException ;
11
+ import org .elasticsearch .Version ;
11
12
import org .elasticsearch .action .ActionListener ;
12
13
import org .elasticsearch .action .StepListener ;
13
14
import org .elasticsearch .action .admin .cluster .snapshots .restore .RestoreSnapshotRequest ;
@@ -126,7 +127,8 @@ private static Settings buildIndexSettings(
126
127
String repoName ,
127
128
SnapshotId snapshotId ,
128
129
IndexId indexId ,
129
- MountSearchableSnapshotRequest .Storage storage
130
+ MountSearchableSnapshotRequest .Storage storage ,
131
+ Version minNodeVersion
130
132
) {
131
133
final Settings .Builder settings = Settings .builder ();
132
134
@@ -145,9 +147,17 @@ private static Settings buildIndexSettings(
145
147
.put (INDEX_RECOVERY_TYPE_SETTING .getKey (), SearchableSnapshotsConstants .SNAPSHOT_RECOVERY_STATE_FACTORY_KEY );
146
148
147
149
if (storage == MountSearchableSnapshotRequest .Storage .SHARED_CACHE ) {
150
+ if (minNodeVersion .before (Version .V_7_12_0 )) {
151
+ throw new IllegalArgumentException ("shared cache searchable snapshots require minimum node version " + Version .V_7_12_0 );
152
+ }
148
153
settings .put (SearchableSnapshotsConstants .SNAPSHOT_PARTIAL_SETTING .getKey (), true )
149
- .put (DiskThresholdDecider .SETTING_IGNORE_DISK_WATERMARKS .getKey (), true )
150
- .put (ShardLimitValidator .INDEX_SETTING_SHARD_LIMIT_GROUP .getKey (), ShardLimitValidator .FROZEN_GROUP );
154
+ .put (DiskThresholdDecider .SETTING_IGNORE_DISK_WATERMARKS .getKey (), true );
155
+
156
+ // we cannot apply this setting during rolling upgrade.
157
+ // todo: update version after backport
158
+ if (minNodeVersion .onOrAfter (Version .V_8_0_0 )) {
159
+ settings .put (ShardLimitValidator .INDEX_SETTING_SHARD_LIMIT_GROUP .getKey (), ShardLimitValidator .FROZEN_GROUP );
160
+ }
151
161
}
152
162
153
163
return settings .build ();
@@ -228,7 +238,16 @@ protected void masterOperation(
228
238
.put (IndexMetadata .SETTING_AUTO_EXPAND_REPLICAS , false ) // can be overridden
229
239
.put (DataTierAllocationDecider .INDEX_ROUTING_PREFER , getDataTiersPreference (request .storage ()))
230
240
.put (request .indexSettings ())
231
- .put (buildIndexSettings (repoData .getUuid (), request .repositoryName (), snapshotId , indexId , request .storage ()))
241
+ .put (
242
+ buildIndexSettings (
243
+ repoData .getUuid (),
244
+ request .repositoryName (),
245
+ snapshotId ,
246
+ indexId ,
247
+ request .storage (),
248
+ state .nodes ().getMinNodeVersion ()
249
+ )
250
+ )
232
251
.build ();
233
252
234
253
// todo: restore archives bad settings, for now we verify just the data tiers, since we know their dependencies are available
0 commit comments