Skip to content

Commit

Permalink
api: add device info into NodeMetric CRD (#378)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Liu <jasonliu747@gmail.com>
  • Loading branch information
jasonliu747 committed Jul 20, 2022
1 parent 0523d60 commit dab5a92
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 52 deletions.
6 changes: 6 additions & 0 deletions apis/extension/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const (
BatchCPU corev1.ResourceName = DomainPrefix + "batch-cpu"
BatchMemory corev1.ResourceName = DomainPrefix + "batch-memory"

GPUCore corev1.ResourceName = DomainPrefix + "gpu-core"
GPUMemory corev1.ResourceName = DomainPrefix + "gpu-memory"
GPUMemoryRatio corev1.ResourceName = DomainPrefix + "gpu-memory-ratio"
)

const (
// AnnotationResourceSpec represents resource allocation API defined by Koordinator.
// The user specifies the desired CPU orchestration policy by setting the annotation.
AnnotationResourceSpec = SchedulingDomainPrefix + "/resource-spec"
Expand Down
8 changes: 4 additions & 4 deletions apis/scheduling/v1alpha1/device_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1

import (
"k8s.io/apimachinery/pkg/api/resource"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -39,11 +39,11 @@ type DeviceInfo struct {
// Minor represents the Minor number of Device, starting from 0
Minor int32 `json:"minor,omitempty"`
// Type represents the type of device
Type DeviceType `json:"deviceType,omitempty"`
Type DeviceType `json:"type,omitempty"`
// Health indicates whether the device is normal
Health bool `json:"health,omitempty"`
// Resources represents the total capacity of various resources of the device
Resources map[string]resource.Quantity `json:"resource,omitempty"`
// Resources is a set of (resource name, quantity) pairs
Resources corev1.ResourceList `json:"resources,omitempty"`
}

type DeviceStatus struct {
Expand Down
33 changes: 16 additions & 17 deletions apis/scheduling/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 0 additions & 5 deletions apis/slo/v1alpha1/nodemetric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -34,10 +33,6 @@ type PodMetricInfo struct {
PodUsage ResourceMap `json:"podUsage,omitempty"`
}

type ResourceMap struct {
corev1.ResourceList `json:"resources,omitempty"`
}

// NodeMetricSpec defines the desired state of NodeMetric
type NodeMetricSpec struct {
// CollectPolicy defines the Metric collection policy
Expand Down
28 changes: 28 additions & 0 deletions apis/slo/v1alpha1/resources.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
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 v1alpha1

import (
corev1 "k8s.io/api/core/v1"

schedulingv1alpha1 "github.com/koordinator-sh/koordinator/apis/scheduling/v1alpha1"
)

type ResourceMap struct {
corev1.ResourceList `json:",inline"`
Devices []schedulingv1alpha1.DeviceInfo `json:"devices,omitempty"`
}
8 changes: 8 additions & 0 deletions apis/slo/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 6 additions & 6 deletions config/crd/bases/scheduling.koordinator.sh_devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ spec:
devices:
items:
properties:
deviceType:
description: Type represents the type of device
type: string
health:
description: Health indicates whether the device is normal
type: boolean
Expand All @@ -50,16 +47,19 @@ spec:
from 0
format: int32
type: integer
resource:
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources represents the total capacity of various
resources of the device
description: Resources is a set of (resource name, quantity)
pairs
type: object
type:
description: Type represents the type of device
type: string
type: object
type: array
required:
Expand Down
92 changes: 72 additions & 20 deletions config/crd/bases/slo.koordinator.sh_nodemetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,43 @@ spec:
description: NodeMetric contains the metrics for this node.
properties:
nodeUsage:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
properties:
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
type: object
devices:
items:
properties:
health:
description: Health indicates whether the device is
normal
type: boolean
id:
description: UUID represents the UUID of device
type: string
minor:
description: Minor represents the Minor number of Device,
starting from 0
format: int32
type: integer
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources is a set of (resource name, quantity)
pairs
type: object
type:
description: Type represents the type of device
type: string
type: object
type: array
type: object
type: object
podsMetric:
Expand All @@ -80,17 +106,43 @@ spec:
namespace:
type: string
podUsage:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
properties:
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity)
pairs.
type: object
devices:
items:
properties:
health:
description: Health indicates whether the device is
normal
type: boolean
id:
description: UUID represents the UUID of device
type: string
minor:
description: Minor represents the Minor number of
Device, starting from 0
format: int32
type: integer
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources is a set of (resource name,
quantity) pairs
type: object
type:
description: Type represents the type of device
type: string
type: object
type: array
type: object
type: object
type: array
Expand Down

0 comments on commit dab5a92

Please sign in to comment.