Skip to content

Commit

Permalink
Fix system_repository setting is restored after cluster metadata reco…
Browse files Browse the repository at this point in the history
…very from local disk

Signed-off-by: bansvaru <bansvaru@amazon.com>
  • Loading branch information
linuxpi committed Oct 11, 2023
1 parent 8bb11a6 commit 6ce854b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import org.opensearch.core.xcontent.XContentParser;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken;

Expand Down Expand Up @@ -83,7 +83,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.startObject();
repositories.toXContent(
builder,
new DelegatingMapParams(Collections.singletonMap(RepositoriesMetadata.HIDE_GENERATIONS_PARAM, "true"), params)
new DelegatingMapParams(
Map.of(RepositoriesMetadata.HIDE_GENERATIONS_PARAM, "true", RepositoriesMetadata.HIDE_SYSTEM_REPOSITORY_SETTING, "true"),

Check warning on line 87 in server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java#L87

Added line #L87 was not covered by tests
params
)
);
builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class RepositoriesMetadata extends AbstractNamedDiffable<Custom> implemen
* in {@link org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse}.
*/
public static final String HIDE_GENERATIONS_PARAM = "hide_generations";
public static final String HIDE_SYSTEM_REPOSITORY_SETTING = "hide_system_repository_setting";

private final List<RepositoryMetadata> repositories;

Expand Down Expand Up @@ -291,7 +292,7 @@ public static void toXContent(RepositoryMetadata repository, XContentBuilder bui
repository.cryptoMetadata().toXContent(repository.cryptoMetadata(), builder, params);
}
Settings settings = repository.settings();
if (SYSTEM_REPOSITORY_SETTING.get(settings)) {
if (SYSTEM_REPOSITORY_SETTING.get(settings) && params.paramAsBoolean(HIDE_SYSTEM_REPOSITORY_SETTING, false)) {
settings = repository.settings().filter(s -> !s.equals(SYSTEM_REPOSITORY_SETTING.getKey()));
}
builder.startObject("settings");
Expand Down

0 comments on commit 6ce854b

Please sign in to comment.