Skip to content

Commit

Permalink
Merge pull request #69 from luomingmeng/dev/spd-support-extended-indi…
Browse files Browse the repository at this point in the history
…cator

spd support extended indicator
  • Loading branch information
waynepeking348 authored Mar 15, 2024
2 parents 328ba1d + a519e64 commit 45cdd48
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ spec:
business and system scopes. Examples include policies for custom
memory reclamation and I/O limitations specific to a service.
properties:
baselinePercent:
description: BaselinePercent marks off a bunch of instances,
and skip applying extended indicator for them; those instances
are defined as baselines, and can be compared with other (experimental/production)
instances to demonstrate the benefits. If BaselinePercent
is not set, we should take all instances as production instances.
format: int32
maximum: 100
minimum: 0
type: integer
indicators:
description: Indicators defines extend workload characteristics,
Indicators can have arbitrary structure. Each kind of Indicator
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/workload/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ServiceProfileDescriptor{},
&ServiceProfileDescriptorList{},

&TestExtendedIndicators{},
)

metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
Expand Down
28 changes: 27 additions & 1 deletion pkg/apis/workload/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,28 @@ type ServiceExtendedIndicatorSpec struct {
// Name defines the name of extended module
Name string `json:"name"`

// BaselinePercent marks off a bunch of instances, and skip applying extended indicator
// for them; those instances are defined as baselines, and can be compared
// with other (experimental/production) instances to demonstrate the benefits.
// If BaselinePercent is not set, we should take all instances as production instances.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
// +optional
BaselinePercent *int32 `json:"baselinePercent,omitempty"`

// Indicators defines extend workload characteristics, Indicators can have arbitrary structure.
// Each kind of Indicator must be named using Name, followed by the suffix 'Indicators'.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
Indicators runtime.RawExtension `json:"indicators,omitempty"`
}

const (
ExtendedIndicatorSuffix = "Indicators"
)

func (c *ServiceExtendedIndicatorSpec) decodeNestedObjects(d runtime.Decoder) error {
gvk := SchemeGroupVersion.WithKind(c.Name + "Indicators")
gvk := SchemeGroupVersion.WithKind(c.Name + ExtendedIndicatorSuffix)
// dry-run to detect and skip out-of-tree extended indicators.
if _, _, err := d.Decode(nil, &gvk, nil); runtime.IsNotRegisteredError(err) {
return nil
Expand Down Expand Up @@ -289,3 +302,16 @@ type ServiceProfileDescriptorList struct {
// items is the list of SPDs
Items []ServiceProfileDescriptor `json:"items"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// TestExtendedIndicators just for extended indicator test
type TestExtendedIndicators struct {
metav1.TypeMeta `json:",inline"`

Indicators *TestIndicators `json:"indicators"`
}

type TestIndicators struct {
TestIndicator string `json:"testIndicator"`
}
51 changes: 51 additions & 0 deletions pkg/apis/workload/v1alpha1/zz_generated.deepcopy.go

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

11 changes: 6 additions & 5 deletions pkg/consts/spd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ const (

// const variables for spd.
const (
// SPDAnnotationBaselineSentinelKey is updated by the SPD controller. It represents
// the sentinel pod among all pods managed by this SPD. Agents or controllers
// can use this key to determine if a pod falls within the baseline by comparing it
// with the pod's createTime and podName.
SPDAnnotationBaselineSentinelKey = "spd.katalyst.kubewharf.io/baselineSentinel"
// SPDAnnotationBaselineSentinelKey and SPDAnnotationExtendedBaselineSentinelKey is
// updated by the SPD controller. It represents the sentinel pod among all pods managed
// by this SPD. Agents or controllers can use this key to determine if a pod falls within
// the baseline by comparing it with the pod's createTime and podName.
SPDAnnotationBaselineSentinelKey = "spd.katalyst.kubewharf.io/baselineSentinel"
SPDAnnotationExtendedBaselineSentinelKey = "spd.katalyst.kubewharf.io/extendedBaselineSentinel"

SPDBaselinePercentMax = 100
SPDBaselinePercentMin = 0
Expand Down

0 comments on commit 45cdd48

Please sign in to comment.