From 35b0d9dfa99d5382a477bd98ad0cb2df4aa1a647 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 | 6 +++++- .../work.karmada.io_clusterresourcebindings.yaml | 10 ++++++++++ .../bases/work/work.karmada.io_resourcebindings.yaml | 10 ++++++++++ pkg/apis/work/v1alpha2/binding_types.go | 12 +++++++++++- pkg/apis/work/v1alpha2/zz_generated.deepcopy.go | 5 +++++ pkg/generated/openapi/zz_generated.openapi.go | 9 ++++++++- 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ea95dcf82dc5..eaa111806f85 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -20435,7 +20435,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 +20445,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..515d3fe52b2d 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 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..9d6b1884d087 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 diff --git a/pkg/apis/work/v1alpha2/binding_types.go b/pkg/apis/work/v1alpha2/binding_types.go index b8cc06191f91..4f75a5d68682 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. 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..8eac67ea5805 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -7461,7 +7461,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 +7477,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: "", + }, + }, }, }, },