From c7e646efa1d8ced64b886db0b44017ad95bcd02b Mon Sep 17 00:00:00 2001 From: Mengjin Yan Date: Thu, 27 Mar 2025 12:31:51 -0700 Subject: [PATCH 1/4] update the autoscaler schema for scheduling with label selector Signed-off-by: Mengjin Yan --- src/ray/protobuf/autoscaler.proto | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/ray/protobuf/autoscaler.proto b/src/ray/protobuf/autoscaler.proto index 4373c137d209..11b9cd942198 100644 --- a/src/ray/protobuf/autoscaler.proto +++ b/src/ray/protobuf/autoscaler.proto @@ -51,12 +51,43 @@ message PlacementConstraint { optional AffinityConstraint affinity = 2; } +// The type of operator to use for the label constraint. +enum LabelOperator { + LABEL_OPERATOR_UNSPECIFIED = 0; + // This is to support equality or in semantics. + LABEL_OPERATOR_IN = 1; + // This is to support not equal or not in semantics. + LABEL_OPERATOR_NOT_IN = 2; +} + +// A node label constraint with a key, one or a list of values and an operator. +message LabelConstraint { + // The key of the label + string label_key = 1; + // The values to check against. + repeated string label_values = 2; + // The operator to use for the label constraint. + LabelOperator operator = 3; +} + +// A list of node label constraints to be used for specify the label requirements in a +// resource request. +message LabelSelector { + // The list of node label constraints with AND semantics. + repeated LabelConstraint label_constraints = 1; +} + message ResourceRequest { // resource requirements for the request. map resources_bundle = 1; // placement constraint for the request. multiple constraints // form AND semantics. repeated PlacementConstraint placement_constraints = 2; + // The node label requirements for the request. Multiple label selectors are for + // fallback mechanism. When trying to find a node that satisfies the label + // requirements, the first label selector should be tried first, if not found, + // the second label selector should be tried, and so on. + repeated LabelSelector label_selectors = 3; } message ResourceRequestByCount { @@ -64,14 +95,27 @@ message ResourceRequestByCount { int64 count = 2; } -// All bundles in the same resource request require gang +// A bundle selector used to specify the resource bundles that should be +// allocated together. All bundles in the same resource request require gang // allocation semantics: they should be allocated all or nothing. +message BundleSelector { + // The list of resource requests that should be allocated together. + repeated ResourceRequest resource_requests = 1; +} + message GangResourceRequest { // a map from bundles to the number of bundles requested. + // DEPRECATED: bundle_selector should be used instead so that we can support fallback + // mechanism. repeated ResourceRequest requests = 1; // Metadata associated with the request for observability, // e.g. placement group's strategy. string details = 2; + // The bundle requests. Multiple bundle selectors are for fallback mechanism. + // When trying to find nodes that satisfies the bundle selector, the first bundle + // selector should be tried first, if not found, the second bundle selector should be + // tried, and so on. + repeated BundleSelector bundle_selectors = 3; } // Cluster resource constraint represents minimal cluster size requirement, From d67f91c3b6f8dd1476f7648579e59fa859f8377e Mon Sep 17 00:00:00 2001 From: Mengjin Yan Date: Mon, 31 Mar 2025 11:54:39 -0700 Subject: [PATCH 2/4] Update sequence of fields in label selector Co-authored-by: Edward Oakes Signed-off-by: Mengjin Yan --- src/ray/protobuf/autoscaler.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ray/protobuf/autoscaler.proto b/src/ray/protobuf/autoscaler.proto index 11b9cd942198..543e2053f3fd 100644 --- a/src/ray/protobuf/autoscaler.proto +++ b/src/ray/protobuf/autoscaler.proto @@ -64,10 +64,10 @@ enum LabelOperator { message LabelConstraint { // The key of the label string label_key = 1; - // The values to check against. - repeated string label_values = 2; // The operator to use for the label constraint. - LabelOperator operator = 3; + LabelOperator operator = 2; + // The values to check against. + repeated string label_values = 3; } // A list of node label constraints to be used for specify the label requirements in a From 44c5218834956c4c51a019fc41b7e100fc415366 Mon Sep 17 00:00:00 2001 From: Mengjin Yan Date: Mon, 31 Mar 2025 11:55:55 -0700 Subject: [PATCH 3/4] Update comment on label selector Co-authored-by: Edward Oakes Signed-off-by: Mengjin Yan --- src/ray/protobuf/autoscaler.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ray/protobuf/autoscaler.proto b/src/ray/protobuf/autoscaler.proto index 543e2053f3fd..4854ef1b596a 100644 --- a/src/ray/protobuf/autoscaler.proto +++ b/src/ray/protobuf/autoscaler.proto @@ -70,7 +70,7 @@ message LabelConstraint { repeated string label_values = 3; } -// A list of node label constraints to be used for specify the label requirements in a +// A list of node label constraints to specify the label requirements in a // resource request. message LabelSelector { // The list of node label constraints with AND semantics. From afb7a8c60f6d8f9fe4b5f4acc39053f3f173de48 Mon Sep 17 00:00:00 2001 From: Mengjin Yan Date: Fri, 11 Apr 2025 09:02:16 +0800 Subject: [PATCH 4/4] add more note on fallback Signed-off-by: Mengjin Yan --- src/ray/protobuf/autoscaler.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ray/protobuf/autoscaler.proto b/src/ray/protobuf/autoscaler.proto index 4854ef1b596a..d111d113c621 100644 --- a/src/ray/protobuf/autoscaler.proto +++ b/src/ray/protobuf/autoscaler.proto @@ -87,6 +87,9 @@ message ResourceRequest { // fallback mechanism. When trying to find a node that satisfies the label // requirements, the first label selector should be tried first, if not found, // the second label selector should be tried, and so on. + // Note that When the ResourceRequest is used within a BundleSelector for + // GangResourceRequest, the fallback mechanism is done at the BundleSelector level. + // So in that case, the label_selectors will only contain a single LabelSelector. repeated LabelSelector label_selectors = 3; }