From 9347e4ae0f2cea10d14af7e04bf3528ca14bf312 Mon Sep 17 00:00:00 2001 From: Garrybest Date: Sun, 16 Jan 2022 00:28:55 +0800 Subject: [PATCH] add proto files for descheduler Signed-off-by: Garrybest --- pkg/estimator/pb/service.proto | 1 + pkg/estimator/pb/types.go | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/pkg/estimator/pb/service.proto b/pkg/estimator/pb/service.proto index 5d8bdfde9..dfcee8870 100644 --- a/pkg/estimator/pb/service.proto +++ b/pkg/estimator/pb/service.proto @@ -9,4 +9,5 @@ option go_package = "pb"; service Estimator { rpc MaxAvailableReplicas(MaxAvailableReplicasRequest) returns (MaxAvailableReplicasResponse) {} + rpc GetUnschedulableReplicas(UnschedulableReplicasRequest) returns (UnschedulableReplicasResponse) {} } diff --git a/pkg/estimator/pb/types.go b/pkg/estimator/pb/types.go index 29b19851f..b6e07e09c 100644 --- a/pkg/estimator/pb/types.go +++ b/pkg/estimator/pb/types.go @@ -1,6 +1,8 @@ package pb import ( + "time" + corev1 "k8s.io/api/core/v1" ) @@ -47,3 +49,46 @@ type MaxAvailableReplicasResponse struct { // +required MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,1,opt,name=maxReplicas"` } + +// UnschedulableReplicasRequest represents the request that sent by gRPC client to calculate unschedulable replicas. +type UnschedulableReplicasRequest struct { + // Cluster represents the cluster name. + // +required + Cluster string `json:"cluster" protobuf:"bytes,1,opt,name=cluster"` + // Resource represents the Kubernetes resource to be propagated. + // +required + Resource ObjectReference `json:"resource" protobuf:"bytes,2,opt,name=resource"` + // UnschedulableThreshold represents the period threshold of pod unscheduable condition. + // This value is considered as a classification standard of unscheduable replicas. + // +optional + UnschedulableThreshold time.Duration `json:"unschedulableThreshold,omitempty" protobuf:"varint,3,opt,name=unschedulableThreshold,casttype=time.Duration"` +} + +// ObjectReference contains enough information to locate the referenced object inside current cluster. +type ObjectReference struct { + // APIVersion represents the API version of the referent. + // +required + APIVersion string `json:"apiVersion" protobuf:"bytes,1,opt,name=apiVersion"` + + // Kind represents the Kind of the referent. + // +required + Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"` + + // Namespace represents the namespace for the referent. + // For non-namespace scoped resources(e.g. 'ClusterRole'),do not need specify Namespace, + // and for namespace scoped resources, Namespace is required. + // If Namespace is not specified, means the resource is non-namespace scoped. + // +required + Namespace string `json:"namespace" protobuf:"bytes,3,opt,name=namespace"` + + // Name represents the name of the referent. + // +required + Name string `json:"name" protobuf:"bytes,4,opt,name=name"` +} + +// UnschedulableReplicasResponse represents the response that sent by gRPC server to calculate unschedulable replicas. +type UnschedulableReplicasResponse struct { + // UnschedulableReplicas represents the unschedulable replicas that the object contains. + // +required + UnschedulableReplicas int32 `json:"maxUnschedulableReplicas" protobuf:"varint,1,opt,name=maxUnschedulableReplicas"` +}