From 02382b61f71cec9e98d1cf1b98f8f0612be08a45 Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Fri, 4 Aug 2017 09:59:40 -0400 Subject: [PATCH] Update rescheduler strategies types. --- pkg/api/types.go | 24 ++++++++++++++---------- pkg/api/v1alpha1/types.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 8068229b4..f7289bbe0 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -20,7 +20,7 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/kubernetes/pkg/api/v1" + "k8s.io/kubernetes/pkg/api" ) type ReschedulerPolicy struct { @@ -30,14 +30,13 @@ type ReschedulerPolicy struct { ReschedulingInterval time.Duration // Strategies - Strategies []ReschedulerStrategy + Strategies StrategyList } +type StrategyName string +type StrategyList map[StrategyName]ReschedulerStrategy + type ReschedulerStrategy struct { - - // Name of strategy - Name string - // Enabled or disabled Enabled bool @@ -48,10 +47,15 @@ type ReschedulerStrategy struct { Params StrategyParameters } -type percentage int -type ResourceUtilizationThresholds map[v1.ResourceName]percentage - // Only one of its members may be specified type StrategyParameters struct { - ResourceUtilizationThresholds *ResourceUtilizationThresholds + NodeResourceUtilizationThresholds *NodeResourceUtilizationThresholds +} + +type Percentage int +type ResourceThresholds map[api.ResourceName]Percentage + +type NodeResourceUtilizationThresholds struct { + Thresholds ResourceThresholds + TargetThresholds ResourceThresholds } diff --git a/pkg/api/v1alpha1/types.go b/pkg/api/v1alpha1/types.go index e14643967..8bb6f452b 100644 --- a/pkg/api/v1alpha1/types.go +++ b/pkg/api/v1alpha1/types.go @@ -17,7 +17,10 @@ limitations under the License. package v1alpha1 import ( + "time" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kubernetes/pkg/api/v1" ) type ReschedulerPolicy struct { @@ -25,4 +28,34 @@ type ReschedulerPolicy struct { // Time interval for rescheduler to run ReschedulingInterval time.Duration `json:"reschedulingInterval,omitempty"` + + // Strategies + Strategies StrategyList `json:"strategies,omitempty"` +} + +type StrategyName string +type StrategyList map[StrategyName]ReschedulerStrategy + +type ReschedulerStrategy struct { + // Enabled or disabled + Enabled bool `json:"enabled,omitempty"` + + // Weight + Weight int `json:"weight,omitempty"` + + // Strategy parameters + Params StrategyParameters `json:"params,omitempty"` +} + +// Only one of its members may be specified +type StrategyParameters struct { + NodeResourceUtilizationThresholds *NodeResourceUtilizationThresholds `json:"nodeResourceUtilizationThresholds,omitempty"` +} + +type Percentage int +type ResourceThresholds map[v1.ResourceName]Percentage + +type NodeResourceUtilizationThresholds struct { + Thresholds ResourceThresholds `json:"thresholds,omitempty"` + TargetThresholds ResourceThresholds `json:"targetThresholds,omitempty"` }