From 9e51142d69e487867b77a729d59aa2f4878bc4c8 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 24 Feb 2026 19:08:57 +0300 Subject: [PATCH] container: Support initial placement policy Closes #352. Signed-off-by: Leonard Lyubich --- CHANGELOG.md | 1 + netmap/types.proto | 35 +++++++++++++++++++++++++++++++++++ proto-docs/netmap.md | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 434278ce..fa9eb12e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Added +- Support for initial placement policy of containers (#381) ### Changed diff --git a/netmap/types.proto b/netmap/types.proto index 80b73637..5cc5845f 100644 --- a/netmap/types.proto +++ b/netmap/types.proto @@ -178,6 +178,41 @@ message PlacementPolicy { } // Erasure coding rules. Limited to 4 items. repeated ECRule ec_rules = 6 [json_name = "ecRules"]; + + // Rules applied during initial data placement. + // + // `replica_limits` allows to override `Replica.count` and EC partitions. If + // set, `replica_limits` must have a length equal to the sum of `replicas` + // (`RN`) and `ec_rules` length. Each of first `RN` elements of + // `replica_limits` must be less than or equal to corresponding + // `Replica.count`. The remaining elements must be either 0 (corresponding + // EC rule is skipped) or 1 (done). At least one `replica_limits` element + // must be non-zero. + // + // `max_replicas` allows to limit total number of replicas and EC partitions + // for successful operation. If set, `max_replicas` must not overflow total + // replica limit (`replica_limits` or main ones). + // + // `prefer_local` allows to tell server to try to store `MaxReplicas` + // replicas in locations that include this server. `prefer_local` must be set + // along with `max_replicas` only. + // + // Either `replica_limits` or `max_replicas` must be specified. + // + // Initial policy must not repeat the main one. In particular, policy with + // `replica_limits` equal to main ones only is invalid. + message Initial { + // Limits on the number of replicas and EC partitions + repeated uint32 replica_limits = 1 [json_name = "replicaLimits"]; + + // Maximum total number of replicas + uint32 max_replicas = 2 [json_name = "maxReplicas"]; + + // Flag to prefer local placement over regular one + bool prefer_local = 3 [json_name = "preferLocal"]; + } + // Initial placement rules. + Initial initial = 7 [json_name = "initial"]; } // NeoFS node description diff --git a/proto-docs/netmap.md b/proto-docs/netmap.md index c492958c..7a247c60 100644 --- a/proto-docs/netmap.md +++ b/proto-docs/netmap.md @@ -34,6 +34,7 @@ - [NodeInfo.Attribute](#neo.fs.v2.netmap.NodeInfo.Attribute) - [PlacementPolicy](#neo.fs.v2.netmap.PlacementPolicy) - [PlacementPolicy.ECRule](#neo.fs.v2.netmap.PlacementPolicy.ECRule) + - [PlacementPolicy.Initial](#neo.fs.v2.netmap.PlacementPolicy.Initial) - [Replica](#neo.fs.v2.netmap.Replica) - [Selector](#neo.fs.v2.netmap.Selector) @@ -488,6 +489,7 @@ storage policy definition languages. | filters | [Filter](#neo.fs.v2.netmap.Filter) | repeated | List of named filters to reference in selectors | | subnet_id | [neo.fs.v2.refs.SubnetID](#neo.fs.v2.refs.SubnetID) | | DEPRECATED. Was used for subnetwork ID to select nodes from, currently ignored. | | ec_rules | [PlacementPolicy.ECRule](#neo.fs.v2.netmap.PlacementPolicy.ECRule) | repeated | Erasure coding rules. Limited to 4 items. | +| initial | [PlacementPolicy.Initial](#neo.fs.v2.netmap.PlacementPolicy.Initial) | | Initial placement rules. | @@ -537,6 +539,40 @@ because they have no payload. | selector | [string](#string) | | Name of the linked selector | + + +### Message PlacementPolicy.Initial +Rules applied during initial data placement. + +`replica_limits` allows to override `Replica.count` and EC partitions. If +set, `replica_limits` must have a length equal to the sum of `replicas` +(`RN`) and `ec_rules` length. Each of first `RN` elements of +`replica_limits` must be less than or equal to corresponding +`Replica.count`. The remaining elements must be either 0 (corresponding +EC rule is skipped) or 1 (done). At least one `replica_limits` element +must be non-zero. + +`max_replicas` allows to limit total number of replicas and EC partitions +for successful operation. If set, `max_replicas` must not overflow total +replica limit (`replica_limits` or main ones). + +`prefer_local` allows to tell server to try to store `MaxReplicas` +replicas in locations that include this server. `prefer_local` must be set +along with `max_replicas` only. + +Either `replica_limits` or `max_replicas` must be specified. + +Initial policy must not repeat the main one. In particular, policy with +`replica_limits` equal to main ones only is invalid. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| replica_limits | [uint32](#uint32) | repeated | Limits on the number of replicas and EC partitions | +| max_replicas | [uint32](#uint32) | | Maximum total number of replicas | +| prefer_local | [bool](#bool) | | Flag to prefer local placement over regular one | + + ### Message Replica