Skip to content

Commit

Permalink
release v1.3.0 (#7)
Browse files Browse the repository at this point in the history
Signed-off-by: saintube <saintube@foxmail.com>
  • Loading branch information
saintube committed Aug 30, 2023
1 parent 8477e45 commit e0f3f00
Show file tree
Hide file tree
Showing 27 changed files with 1,011 additions and 200 deletions.
6 changes: 5 additions & 1 deletion config/v1alpha1/cluster_colocation_profile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand All @@ -38,6 +39,10 @@ type ClusterColocationProfileSpec struct {
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`

// Probability indicates profile will make effect with a probability.
// +optional
Probability *intstr.IntOrString `json:"probability,omitempty"`

// QoSClass describes the type of Koordinator QoS that the Pod is running.
// The value will be injected into Pod as label koordinator.sh/qosClass.
// Options are LSE/LSR/LS/BE/SYSTEM.
Expand All @@ -50,7 +55,6 @@ type ClusterColocationProfileSpec struct {
// The PriorityClassName, priority value in PriorityClassName and
// KoordinatorPriority will affect the scheduling, preemption and
// other behaviors of Koordinator system.
// +kubebuilder:validation:Enum=koord-prod;koord-mid;koord-batch;koord-free
// +optional
PriorityClassName string `json:"priorityClassName"`

Expand Down
6 changes: 6 additions & 0 deletions config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package extension
package configuration

import (
"github.com/mohae/deepcopy"
Expand Down Expand Up @@ -43,7 +43,7 @@ type NodeCfgProfile struct {
// +k8s:deepcopy-gen=true
type ColocationCfg struct {
ColocationStrategy `json:",inline"`
NodeConfigs []NodeColocationCfg `json:"nodeConfigs,omitempty"`
NodeConfigs []NodeColocationCfg `json:"nodeConfigs,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
Expand All @@ -55,7 +55,7 @@ type NodeColocationCfg struct {
// +k8s:deepcopy-gen=true
type ResourceThresholdCfg struct {
ClusterStrategy *slov1alpha1.ResourceThresholdStrategy `json:"clusterStrategy,omitempty"`
NodeStrategies []NodeResourceThresholdStrategy `json:"nodeStrategies,omitempty"`
NodeStrategies []NodeResourceThresholdStrategy `json:"nodeStrategies,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
Expand All @@ -73,7 +73,7 @@ type NodeCPUBurstCfg struct {
// +k8s:deepcopy-gen=true
type CPUBurstCfg struct {
ClusterStrategy *slov1alpha1.CPUBurstStrategy `json:"clusterStrategy,omitempty"`
NodeStrategies []NodeCPUBurstCfg `json:"nodeStrategies,omitempty"`
NodeStrategies []NodeCPUBurstCfg `json:"nodeStrategies,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
Expand All @@ -85,13 +85,13 @@ type NodeSystemStrategy struct {
// +k8s:deepcopy-gen=true
type SystemCfg struct {
ClusterStrategy *slov1alpha1.SystemStrategy `json:"clusterStrategy,omitempty"`
NodeStrategies []NodeSystemStrategy `json:"nodeStrategies,omitempty"`
NodeStrategies []NodeSystemStrategy `json:"nodeStrategies,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
type ResourceQOSCfg struct {
ClusterStrategy *slov1alpha1.ResourceQOSStrategy `json:"clusterStrategy,omitempty"`
NodeStrategies []NodeResourceQOSStrategy `json:"nodeStrategies,omitempty"`
NodeStrategies []NodeResourceQOSStrategy `json:"nodeStrategies,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
Expand Down Expand Up @@ -196,16 +196,25 @@ func (in *ExtraFields) DeepCopy() *ExtraFields {
// +k8s:deepcopy-gen=true
type ColocationStrategy struct {
Enable *bool `json:"enable,omitempty"`
MetricAggregateDurationSeconds *int64 `json:"metricAggregateDurationSeconds,omitempty"`
MetricReportIntervalSeconds *int64 `json:"metricReportIntervalSeconds,omitempty"`
MetricAggregateDurationSeconds *int64 `json:"metricAggregateDurationSeconds,omitempty" validate:"omitempty,min=1"`
MetricReportIntervalSeconds *int64 `json:"metricReportIntervalSeconds,omitempty" validate:"omitempty,min=1"`
MetricAggregatePolicy *slov1alpha1.AggregatePolicy `json:"metricAggregatePolicy,omitempty"`
CPUReclaimThresholdPercent *int64 `json:"cpuReclaimThresholdPercent,omitempty"`
MemoryReclaimThresholdPercent *int64 `json:"memoryReclaimThresholdPercent,omitempty"`
MemoryCalculatePolicy *CalculatePolicy `json:"memoryCalculatePolicy,omitempty"`
DegradeTimeMinutes *int64 `json:"degradeTimeMinutes,omitempty"`
UpdateTimeThresholdSeconds *int64 `json:"updateTimeThresholdSeconds,omitempty"`
ResourceDiffThreshold *float64 `json:"resourceDiffThreshold,omitempty"`
ColocationStrategyExtender `json:",inline"` // for third-party extension

CPUReclaimThresholdPercent *int64 `json:"cpuReclaimThresholdPercent,omitempty" validate:"omitempty,min=0,max=100"`
MemoryReclaimThresholdPercent *int64 `json:"memoryReclaimThresholdPercent,omitempty" validate:"omitempty,min=0,max=100"`
MemoryCalculatePolicy *CalculatePolicy `json:"memoryCalculatePolicy,omitempty"`
DegradeTimeMinutes *int64 `json:"degradeTimeMinutes,omitempty" validate:"omitempty,min=1"`
UpdateTimeThresholdSeconds *int64 `json:"updateTimeThresholdSeconds,omitempty" validate:"omitempty,min=1"`
ResourceDiffThreshold *float64 `json:"resourceDiffThreshold,omitempty" validate:"omitempty,gt=0,max=1"`

// MidCPUThresholdPercent defines the maximum percentage of the Mid-tier cpu resource dividing the node allocatable.
// MidCPUAllocatable <= NodeCPUAllocatable * MidCPUThresholdPercent / 100.
MidCPUThresholdPercent *int64 `json:"midCPUThresholdPercent,omitempty" validate:"omitempty,min=0,max=100"`
// MidMemoryThresholdPercent defines the maximum percentage of the Mid-tier memory resource dividing the node allocatable.
// MidMemoryAllocatable <= NodeMemoryAllocatable * MidMemoryThresholdPercent / 100.
MidMemoryThresholdPercent *int64 `json:"midMemoryThresholdPercent,omitempty" validate:"omitempty,min=0,max=100"`

ColocationStrategyExtender `json:",inline"` // for third-party extension
}

/*
Expand Down Expand Up @@ -363,12 +372,49 @@ data:
"priority": 0,
"oomKillGroup": 0
},
"blkioQOS": {
"blocks": [
{
"ioCfg": {
"ioWeightPercent": 60
},
"name": "ackdistro-pool",
"type": "volumegroup"
},
{
"ioCfg": {
"readBPS": 102400000,
"readIOPS": 20480,
"writeBPS": 204800004,
"writeIOPS": 10240
},
"name": "/dev/sdb",
"type": "device"
},
],
"enable": true
},
"resctrlQOS": {
"enable": false,
"catRangeStartPercent": 0,
"catRangeEndPercent": 30,
"mbaPercent": 100
}
},
"cgroupRoot": {
"blkioQOS": {
"blocks": [
{
"ioCfg": {
"readLatency": 3000,
"writeLatency": 3000
},
"name": "ackdistro-pool",
"type": "volumegroup"
}
],
"enable": true
}
}
},
"nodeStrategies": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions extension/cluster_colocation_profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2022 The Koordinator Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package extension

import (
configv1alpha1 "github.com/koordinator-sh/apis/config/v1alpha1"
)

const (
AnnotationSkipUpdateResource = "config.koordinator.sh/skip-update-resources"
)

func ShouldSkipUpdateResource(profile *configv1alpha1.ClusterColocationProfile) bool {
if profile == nil || profile.Annotations == nil {
return false
}
_, ok := profile.Annotations[AnnotationSkipUpdateResource]
return ok
}
15 changes: 15 additions & 0 deletions extension/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ const (

LabelPodQoS = DomainPrefix + "qosClass"
LabelPodPriority = DomainPrefix + "priority"
// LabelPodPriorityClass is used to revise those Pods that are already running and have Priority set, so that
// Koordinator can be smoothly deployed to the running cluster. If you don't have a running Pod with
// PriorityClass set, don't set this field specifically.
LabelPodPriorityClass = DomainPrefix + "priority-class"

LabelManagedBy = "app.kubernetes.io/managed-by"
)

type AggregationType string

const (
// max is not welcomed since it may import outliers
AVG AggregationType = "avg"
P99 AggregationType = "p99"
P95 AggregationType = "p95"
P90 AggregationType = "p90"
P50 AggregationType = "p50"
)
92 changes: 92 additions & 0 deletions extension/coscheduling.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Copyright 2022 The Koordinator Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package extension

import (
"strconv"

corev1 "k8s.io/api/core/v1"
)

const (
AnnotationGangPrefix = "gang.scheduling.koordinator.sh"
// AnnotationGangName specifies the name of the gang
AnnotationGangName = AnnotationGangPrefix + "/name"

// AnnotationGangMinNum specifies the minimum number of the gang that can be executed
AnnotationGangMinNum = AnnotationGangPrefix + "/min-available"

// AnnotationGangWaitTime specifies gang's max wait time in Permit Stage
AnnotationGangWaitTime = AnnotationGangPrefix + "/waiting-time"

// AnnotationGangTotalNum specifies the total children number of the gang
// If not specified,it will be set with the AnnotationGangMinNum
AnnotationGangTotalNum = AnnotationGangPrefix + "/total-number"

// AnnotationGangMode defines the Gang Scheduling operation when failed scheduling
// Support GangModeStrict and GangModeNonStrict, default is GangModeStrict
AnnotationGangMode = AnnotationGangPrefix + "/mode"

// AnnotationGangGroups defines which gangs are bundled as a group
// The gang will go to bind only all gangs in one group meet the conditions
AnnotationGangGroups = AnnotationGangPrefix + "/groups"

// AnnotationGangTimeout means that the entire gang cannot be scheduled due to timeout
// The annotation is added by the scheduler when the gang times out
AnnotationGangTimeout = AnnotationGangPrefix + "/timeout"

GangModeStrict = "Strict"
GangModeNonStrict = "NonStrict"

// AnnotationGangMatchPolicy defines the Gang Scheduling operation of taking which status pod into account
// Support GangMatchPolicyOnlyWaiting, GangMatchPolicyWaitingAndRunning, GangMatchPolicyOnceSatisfied, default is GangMatchPolicyOnceSatisfied
AnnotationGangMatchPolicy = AnnotationGangPrefix + "/match-policy"
GangMatchPolicyOnlyWaiting = "only-waiting"
GangMatchPolicyWaitingAndRunning = "waiting-and-running"
GangMatchPolicyOnceSatisfied = "once-satisfied"

// AnnotationAliasGangMatchPolicy defines same match policy but different prefix.
// Duplicate definitions here are only for compatibility considerations
AnnotationAliasGangMatchPolicy = "pod-group.scheduling.sigs.k8s.io/match-policy"
)

const (
// Deprecated: kubernetes-sigs/scheduler-plugins/lightweight-coscheduling
LabelLightweightCoschedulingPodGroupName = "pod-group.scheduling.sigs.k8s.io/name"
// Deprecated: kubernetes-sigs/scheduler-plugins/lightweight-coscheduling
LabelLightweightCoschedulingPodGroupMinAvailable = "pod-group.scheduling.sigs.k8s.io/min-available"
)

func GetMinNum(pod *corev1.Pod) (int, error) {
minRequiredNum, err := strconv.ParseInt(pod.Annotations[AnnotationGangMinNum], 10, 32)
if err != nil {
return 0, err
}
return int(minRequiredNum), nil
}

func GetGangName(pod *corev1.Pod) string {
return pod.Annotations[AnnotationGangName]
}

func GetGangMatchPolicy(pod *corev1.Pod) string {
policy := pod.Annotations[AnnotationGangMatchPolicy]
if policy != "" {
return policy
}
return pod.Annotations[AnnotationAliasGangMatchPolicy]
}
20 changes: 6 additions & 14 deletions extension/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,16 @@ const (
DeprecatedGPUModel string = ResourceDomainPrefix + "gpu-model"
)

var deprecatedDeviceResourceNameMapper = map[corev1.ResourceName]corev1.ResourceName{
var DeprecatedBatchResourcesMapper = map[corev1.ResourceName]corev1.ResourceName{
KoordBatchCPU: BatchCPU,
KoordBatchMemory: BatchMemory,
}

var DeprecatedDeviceResourcesMapper = map[corev1.ResourceName]corev1.ResourceName{
DeprecatedKoordRDMA: ResourceRDMA,
DeprecatedKoordFPGA: ResourceFPGA,
DeprecatedKoordGPU: ResourceGPU,
DeprecatedGPUCore: ResourceGPUCore,
DeprecatedGPUMemory: ResourceGPUMemory,
DeprecatedGPUMemoryRatio: ResourceGPUMemoryRatio,
}

func TransformDeprecatedDeviceResources(resList corev1.ResourceList) corev1.ResourceList {
r := make(corev1.ResourceList, len(resList))
for k, v := range resList {
newResName := deprecatedDeviceResourceNameMapper[k]
if newResName != "" {
r[newResName] = v
} else {
r[k] = v
}
}
return r
}
Loading

0 comments on commit e0f3f00

Please sign in to comment.