Browse Source

Intermediate changes

robot-piglet 1 year ago
parent
commit
cd424968b3

+ 2 - 0
yt/yt/client/bundle_controller_client/bundle_controller_client.cpp

@@ -12,6 +12,8 @@ void TBundleConfigDescriptor::Register(TRegistrar registrar)
         .DefaultNew();
     registrar.Parameter("bundle_constraints", &TThis::ConfigConstraints)
         .DefaultNew();
+    registrar.Parameter("resource_quota", &TThis::ResourceQuota)
+        .DefaultNew();
 }
 
 ////////////////////////////////////////////////////////////////////////////////

+ 1 - 0
yt/yt/client/bundle_controller_client/bundle_controller_client.h

@@ -26,6 +26,7 @@ struct TBundleConfigDescriptor
 
     TBundleTargetConfigPtr Config;
     TBundleConfigConstraintsPtr ConfigConstraints;
+    TResourceQuotaPtr ResourceQuota;
 
     REGISTER_YSON_STRUCT(TBundleConfigDescriptor);
 

+ 35 - 0
yt/yt/client/bundle_controller_client/bundle_controller_settings.cpp

@@ -98,6 +98,24 @@ void TBundleConfigConstraints::Register(TRegistrar registrar)
     registrar.Parameter("tablet_node_sizes", &TThis::TabletNodeSizes)
         .Default();
 }
+
+void TResourceQuota::Register(TRegistrar registrar)
+{
+    registrar.Parameter("cpu", &TThis::Cpu)
+        .GreaterThanOrEqual(0)
+        .Default(0);
+
+    registrar.Parameter("memory", &TThis::Memory)
+        .GreaterThanOrEqual(0)
+        .Default(0);
+}
+
+int TResourceQuota::Vcpu() const
+{
+    const int VFactor = 1000;
+    return static_cast<int>(Cpu * VFactor);
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 namespace NProto {
@@ -267,6 +285,23 @@ void FromProto(TBundleConfigConstraintsPtr bundleConfigConstraints, const NBundl
 
 ////////////////////////////////////////////////////////////////////////////////
 
+void ToProto(NBundleController::NProto::TResourceQuota* protoResourceQuota, const TResourceQuotaPtr resourceQuota)
+{
+    protoResourceQuota->set_vcpu(resourceQuota->Vcpu());
+    protoResourceQuota->set_memory(resourceQuota->Memory);
+}
+
+void FromProto(TResourceQuotaPtr resourceQuota, const NBundleController::NProto::TResourceQuota* protoResourceQuota)
+{
+    YT_FROMPROTO_OPTIONAL_PTR(protoResourceQuota, memory, resourceQuota, Memory);
+    if (protoResourceQuota->has_vcpu()) {
+        int VFactor = 1000;
+        resourceQuota->Cpu = static_cast<double>(protoResourceQuota->vcpu()) / VFactor;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
 } // namespace NProto
 
 } // namespace NYT::NBundleControllerClient

+ 20 - 0
yt/yt/client/bundle_controller_client/bundle_controller_settings.h

@@ -137,6 +137,23 @@ DEFINE_REFCOUNTED_TYPE(TBundleConfigConstraints)
 
 ////////////////////////////////////////////////////////////////////////////////
 
+struct TResourceQuota
+    : public NYTree::TYsonStruct
+{
+    double Cpu;
+    i64 Memory;
+
+    int Vcpu() const;
+
+    REGISTER_YSON_STRUCT(TResourceQuota);
+
+    static void Register(TRegistrar registrar);
+};
+
+DEFINE_REFCOUNTED_TYPE(TResourceQuota)
+
+////////////////////////////////////////////////////////////////////////////////
+
 namespace NProto {
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -162,6 +179,9 @@ void FromProto(TBundleTargetConfigPtr bundleConfig, const NBundleController::NPr
 void ToProto(NBundleController::NProto::TBundleConfigConstraints* protoBundleConfigConstraints, const TBundleConfigConstraintsPtr bundleConfigConstraints);
 void FromProto(TBundleConfigConstraintsPtr bundleConfigConstraints, const NBundleController::NProto::TBundleConfigConstraints* protoBundleConfigConstraints);
 
+void ToProto(NBundleController::NProto::TResourceQuota* protoResourceQuota, const TResourceQuotaPtr resourceQuota);
+void FromProto(TResourceQuotaPtr resourceQuota, const NBundleController::NProto::TResourceQuota* protoResourceQuota);
+
 ////////////////////////////////////////////////////////////////////////////////
 
 } // namespace NProto

+ 2 - 0
yt/yt/client/bundle_controller_client/public.h

@@ -18,6 +18,7 @@ DECLARE_REFCOUNTED_STRUCT(TInstanceSize)
 DECLARE_REFCOUNTED_STRUCT(TBundleTargetConfig)
 DECLARE_REFCOUNTED_STRUCT(TBundleConfigDescriptor)
 DECLARE_REFCOUNTED_STRUCT(TBundleConfigConstraints)
+DECLARE_REFCOUNTED_STRUCT(TResourceQuota)
 
 struct TBundleConfigDescriptor;
 
@@ -28,6 +29,7 @@ struct TDefaultInstanceConfig;
 struct TInstanceSize;
 struct TBundleTargetConfig;
 struct TBundleConfigConstraints;
+struct TResourceQuota;
 
 ////////////////////////////////////////////////////////////////////////////////
 

+ 7 - 0
yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto

@@ -61,6 +61,12 @@ message TBundleConfig
     optional TInstanceResources tablet_node_resource_guarantee = 6;
 }
 
+message TResourceQuota
+{
+    optional int32 vcpu = 1;
+    optional int64 memory = 2;
+}
+
 message TReqGetBundleConfig
 {
     required string bundle_name = 1;
@@ -71,6 +77,7 @@ message TRspGetBundleConfig
     optional string bundle_name = 1;
     optional TBundleConfig bundle_config = 2;
     optional TBundleConfigConstraints bundle_constraints = 3;
+    optional TResourceQuota resource_quota = 4;
 }
 
 message TReqSetBundleConfig