From 3c1b729d30a6f7f8506413926ff764a5a4f328d3 Mon Sep 17 00:00:00 2001 From: Monokaix Date: Mon, 9 Dec 2024 14:55:16 +0800 Subject: [PATCH] RB suspension: API change Signed-off-by: Monokaix --- api/openapi-spec/swagger.json | 12 ++++++++++-- ...work.karmada.io_clusterresourcebindings.yaml | 13 +++++++++++++ .../work/work.karmada.io_resourcebindings.yaml | 13 +++++++++++++ pkg/apis/work/v1alpha2/binding_types.go | 14 +++++++++++++- pkg/apis/work/v1alpha2/zz_generated.deepcopy.go | 5 +++++ pkg/generated/openapi/zz_generated.openapi.go | 17 ++++++++++++++++- 6 files changed, 70 insertions(+), 4 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ea95dcf82dc5..2e3387eb9581 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -20417,7 +20417,11 @@ "items": { "default": {}, "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Condition" - } + }, + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" }, "lastScheduledTime": { "description": "LastScheduledTime representing the latest timestamp when scheduler successfully finished a scheduling. It is represented in RFC3339 form (like '2006-01-02T15:04:05Z') and is in UTC.", @@ -20435,7 +20439,7 @@ } }, "com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.Suspension": { - "description": "Suspension defines the policy for suspending of propagation.", + "description": "Suspension defines the policy for suspending dispatching and scheduling.", "type": "object", "properties": { "dispatching": { @@ -20445,6 +20449,10 @@ "dispatchingOnClusters": { "description": "DispatchingOnClusters declares a list of clusters to which the dispatching should be suspended. Note: Can not co-exist with Dispatching which is used to suspend all.", "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SuspendClusters" + }, + "scheduling": { + "description": "Scheduling controls whether scheduling should be suspended, the scheduler will pause scheduling and not process resource binding when the value is true and resume scheduling when it's false or nil. This is designed for third-party systems to temporarily pause the scheduling of applications, which enabling manage resource allocation, prioritize critical workloads, etc. It is expected that third-party systems use an admission webhook to suspend scheduling at the time of ResourceBinding creation. Once a ResourceBinding has been scheduled, it cannot be paused afterward, as it may lead to ineffective suspension.", + "type": "boolean" } } }, diff --git a/charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml b/charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml index 7bfb5ed72887..9a6604ef59ed 100644 --- a/charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml +++ b/charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml @@ -1281,6 +1281,16 @@ spec: type: string type: array type: object + scheduling: + description: |- + Scheduling controls whether scheduling should be suspended, the scheduler will pause scheduling and not + process resource binding when the value is true and resume scheduling when it's false or nil. + This is designed for third-party systems to temporarily pause the scheduling of applications, which enabling + manage resource allocation, prioritize critical workloads, etc. + It is expected that third-party systems use an admission webhook to suspend scheduling at the time of + ResourceBinding creation. Once a ResourceBinding has been scheduled, it cannot be paused afterward, as it may + lead to ineffective suspension. + type: boolean type: object required: - resource @@ -1384,6 +1394,9 @@ spec: - type type: object type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map lastScheduledTime: description: |- LastScheduledTime representing the latest timestamp when scheduler successfully finished a scheduling. diff --git a/charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml b/charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml index f2ad93b827ae..6ba3cd7c4188 100644 --- a/charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml +++ b/charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml @@ -1281,6 +1281,16 @@ spec: type: string type: array type: object + scheduling: + description: |- + Scheduling controls whether scheduling should be suspended, the scheduler will pause scheduling and not + process resource binding when the value is true and resume scheduling when it's false or nil. + This is designed for third-party systems to temporarily pause the scheduling of applications, which enabling + manage resource allocation, prioritize critical workloads, etc. + It is expected that third-party systems use an admission webhook to suspend scheduling at the time of + ResourceBinding creation. Once a ResourceBinding has been scheduled, it cannot be paused afterward, as it may + lead to ineffective suspension. + type: boolean type: object required: - resource @@ -1384,6 +1394,9 @@ spec: - type type: object type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map lastScheduledTime: description: |- LastScheduledTime representing the latest timestamp when scheduler successfully finished a scheduling. diff --git a/pkg/apis/work/v1alpha2/binding_types.go b/pkg/apis/work/v1alpha2/binding_types.go index b8cc06191f91..19c9a2467ce5 100644 --- a/pkg/apis/work/v1alpha2/binding_types.go +++ b/pkg/apis/work/v1alpha2/binding_types.go @@ -322,9 +322,19 @@ type BindingSnapshot struct { Clusters []TargetCluster `json:"clusters,omitempty"` } -// Suspension defines the policy for suspending of propagation. +// Suspension defines the policy for suspending dispatching and scheduling. type Suspension struct { policyv1alpha1.Suspension `json:",inline"` + + // Scheduling controls whether scheduling should be suspended, the scheduler will pause scheduling and not + // process resource binding when the value is true and resume scheduling when it's false or nil. + // This is designed for third-party systems to temporarily pause the scheduling of applications, which enabling + // manage resource allocation, prioritize critical workloads, etc. + // It is expected that third-party systems use an admission webhook to suspend scheduling at the time of + // ResourceBinding creation. Once a ResourceBinding has been scheduled, it cannot be paused afterward, as it may + // lead to ineffective suspension. + // +optional + Scheduling *bool `json:"scheduling,omitempty"` } // ResourceBindingStatus represents the overall status of the strategy as well as the referenced resources. @@ -347,6 +357,8 @@ type ResourceBindingStatus struct { // Conditions contain the different condition statuses. // +optional + // +listType=map + // +listMapKey=type Conditions []metav1.Condition `json:"conditions,omitempty"` // AggregatedStatus represents status list of the resource running in each member cluster. diff --git a/pkg/apis/work/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/work/v1alpha2/zz_generated.deepcopy.go index cd42228e6f7b..44ce04650198 100644 --- a/pkg/apis/work/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/work/v1alpha2/zz_generated.deepcopy.go @@ -421,6 +421,11 @@ func (in *ResourceBindingStatus) DeepCopy() *ResourceBindingStatus { func (in *Suspension) DeepCopyInto(out *Suspension) { *out = *in in.Suspension.DeepCopyInto(&out.Suspension) + if in.Scheduling != nil { + in, out := &in.Scheduling, &out.Scheduling + *out = new(bool) + **out = **in + } return } diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index ce9fadceac0e..8732cbc09f9b 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -7422,6 +7422,14 @@ func schema_pkg_apis_work_v1alpha2_ResourceBindingStatus(ref common.ReferenceCal }, }, "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, SchemaProps: spec.SchemaProps{ Description: "Conditions contain the different condition statuses.", Type: []string{"array"}, @@ -7461,7 +7469,7 @@ func schema_pkg_apis_work_v1alpha2_Suspension(ref common.ReferenceCallback) comm return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "Suspension defines the policy for suspending of propagation.", + Description: "Suspension defines the policy for suspending dispatching and scheduling.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "dispatching": { @@ -7477,6 +7485,13 @@ func schema_pkg_apis_work_v1alpha2_Suspension(ref common.ReferenceCallback) comm Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SuspendClusters"), }, }, + "scheduling": { + SchemaProps: spec.SchemaProps{ + Description: "Scheduling controls whether scheduling should be suspended, the scheduler will pause scheduling and not process resource binding when the value is true and resume scheduling when it's false or nil. This is designed for third-party systems to temporarily pause the scheduling of applications, which enabling manage resource allocation, prioritize critical workloads, etc. It is expected that third-party systems use an admission webhook to suspend scheduling at the time of ResourceBinding creation. Once a ResourceBinding has been scheduled, it cannot be paused afterward, as it may lead to ineffective suspension.", + Type: []string{"boolean"}, + Format: "", + }, + }, }, }, },