From 8e8bcf3064448d86c20678519c0bd9da5bd18d90 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Mon, 3 Nov 2025 09:46:58 +0100 Subject: [PATCH] Move `RegisteredPolicySnapshots` XContent registry entry to `ClusterModule` This `ProjectCustom` class is currently registered as a writeable in `ClusterModule` and its XContent entry is registered in the SLM plugin. We use `RegisteredPolicySnapshots` in the `SnapshotsService`, so we should move its XContent entry to `ClusterModule` as well. This avoids the following warning from showing up in some tests: > Skipping unknown custom [ProjectCustom] object with type registered_snapshots --- .../main/java/org/elasticsearch/cluster/ClusterModule.java | 7 +++++++ .../org/elasticsearch/xpack/slm/SnapshotLifecycle.java | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java index 3c53d063aac6c..f1ca84bccdfa4 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java @@ -412,6 +412,13 @@ public static List getNamedXWriteables() { StreamsMetadata::fromXContent ) ); + entries.add( + new NamedXContentRegistry.Entry( + Metadata.ProjectCustom.class, + new ParseField(RegisteredPolicySnapshots.TYPE), + RegisteredPolicySnapshots::parse + ) + ); return entries; } diff --git a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java index 0e18d562cde70..dc926d738fdf5 100644 --- a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java +++ b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java @@ -30,7 +30,6 @@ import org.elasticsearch.reservedstate.ReservedClusterStateHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.snapshots.RegisteredPolicySnapshots; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.ParseField; @@ -166,11 +165,6 @@ private static List xContentEntries() { Metadata.ProjectCustom.class, new ParseField(SnapshotLifecycleMetadata.TYPE), parser -> SnapshotLifecycleMetadata.PARSER.parse(parser, null) - ), - new NamedXContentRegistry.Entry( - Metadata.ProjectCustom.class, - new ParseField(RegisteredPolicySnapshots.TYPE), - RegisteredPolicySnapshots::parse ) ); }