Skip to content

Commit 925ffe9

Browse files
committed
Rename ComponentRequirements field in ResourceBinding for get rid of redundant namespace
Signed-off-by: RainbowMango <[email protected]>
1 parent e7ecc93 commit 925ffe9

File tree

17 files changed

+168
-67
lines changed

17 files changed

+168
-67
lines changed

api/openapi-spec/swagger.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21212,8 +21212,8 @@
2121221212
}
2121321213
]
2121421214
},
21215-
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ComponentRequirements": {
21216-
"description": "ComponentRequirements represents the requirements for a specific component.",
21215+
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.Component": {
21216+
"description": "Component represents the requirements for a specific component.",
2121721217
"type": "object",
2121821218
"required": [
2121921219
"replicas"
@@ -21225,7 +21225,7 @@
2122521225
},
2122621226
"replicaRequirements": {
2122721227
"description": "ReplicaRequirements represents the requirements required by each replica for this component.",
21228-
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ReplicaRequirements"
21228+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ComponentReplicaRequirements"
2122921229
},
2123021230
"replicas": {
2123121231
"description": "Replicas represents the replica number of the resource's component.",
@@ -21235,6 +21235,27 @@
2123521235
}
2123621236
}
2123721237
},
21238+
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ComponentReplicaRequirements": {
21239+
"description": "ComponentReplicaRequirements represents the requirements required by each replica.",
21240+
"type": "object",
21241+
"properties": {
21242+
"nodeClaim": {
21243+
"description": "NodeClaim represents the node claim HardNodeAffinity, NodeSelector and Tolerations required by each replica.",
21244+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.NodeClaim"
21245+
},
21246+
"priorityClassName": {
21247+
"description": "PriorityClassName represents the resources priorityClassName",
21248+
"type": "string"
21249+
},
21250+
"resourceRequest": {
21251+
"description": "ResourceRequest represents the resources required by each replica.",
21252+
"type": "object",
21253+
"additionalProperties": {
21254+
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
21255+
}
21256+
}
21257+
}
21258+
},
2123821259
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.GracefulEvictionTask": {
2123921260
"description": "GracefulEvictionTask represents a graceful eviction task.",
2124021261
"type": "object",
@@ -21486,7 +21507,7 @@
2148621507
"type": "array",
2148721508
"items": {
2148821509
"default": {},
21489-
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ComponentRequirements"
21510+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.Component"
2149021511
}
2149121512
},
2149221513
"conflictResolution": {

charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ spec:
272272
Note: This field is intended to replace the legacy ReplicaRequirements and Replicas fields above.
273273
It is only populated when the MultiplePodTemplatesScheduling feature gate is enabled.
274274
items:
275-
description: ComponentRequirements represents the requirements for
276-
a specific component.
275+
description: Component represents the requirements for a specific
276+
component.
277277
properties:
278278
name:
279279
description: |-
@@ -286,9 +286,6 @@ spec:
286286
description: ReplicaRequirements represents the requirements
287287
required by each replica for this component.
288288
properties:
289-
namespace:
290-
description: Namespace represents the resources namespaces
291-
type: string
292289
nodeClaim:
293290
description: NodeClaim represents the node claim HardNodeAffinity,
294291
NodeSelector and Tolerations required by each replica.

charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ spec:
272272
Note: This field is intended to replace the legacy ReplicaRequirements and Replicas fields above.
273273
It is only populated when the MultiplePodTemplatesScheduling feature gate is enabled.
274274
items:
275-
description: ComponentRequirements represents the requirements for
276-
a specific component.
275+
description: Component represents the requirements for a specific
276+
component.
277277
properties:
278278
name:
279279
description: |-
@@ -286,9 +286,6 @@ spec:
286286
description: ReplicaRequirements represents the requirements
287287
required by each replica for this component.
288288
properties:
289-
namespace:
290-
description: Namespace represents the resources namespaces
291-
type: string
292289
nodeClaim:
293290
description: NodeClaim represents the node claim HardNodeAffinity,
294291
NodeSelector and Tolerations required by each replica.

pkg/apis/work/v1alpha2/binding_types.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type ResourceBindingSpec struct {
9595
// Note: This field is intended to replace the legacy ReplicaRequirements and Replicas fields above.
9696
// It is only populated when the MultiplePodTemplatesScheduling feature gate is enabled.
9797
// +optional
98-
Components []ComponentRequirements `json:"components,omitempty"`
98+
Components []Component `json:"components,omitempty"`
9999

100100
// Clusters represents target member clusters where the resource to be deployed.
101101
// +optional
@@ -223,8 +223,8 @@ type ReplicaRequirements struct {
223223
PriorityClassName string `json:"priorityClassName,omitempty"`
224224
}
225225

226-
// ComponentRequirements represents the requirements for a specific component.
227-
type ComponentRequirements struct {
226+
// Component represents the requirements for a specific component.
227+
type Component struct {
228228
// Name of this component.
229229
// It is required when the resource contains multiple components to ensure proper identification,
230230
// and must also be unique within the same resource.
@@ -238,7 +238,22 @@ type ComponentRequirements struct {
238238

239239
// ReplicaRequirements represents the requirements required by each replica for this component.
240240
// +optional
241-
ReplicaRequirements *ReplicaRequirements `json:"replicaRequirements,omitempty"`
241+
ReplicaRequirements *ComponentReplicaRequirements `json:"replicaRequirements,omitempty"`
242+
}
243+
244+
// ComponentReplicaRequirements represents the requirements required by each replica.
245+
type ComponentReplicaRequirements struct {
246+
// NodeClaim represents the node claim HardNodeAffinity, NodeSelector and Tolerations required by each replica.
247+
// +optional
248+
NodeClaim *NodeClaim `json:"nodeClaim,omitempty"`
249+
250+
// ResourceRequest represents the resources required by each replica.
251+
// +optional
252+
ResourceRequest corev1.ResourceList `json:"resourceRequest,omitempty"`
253+
254+
// PriorityClassName represents the resources priorityClassName
255+
// +optional
256+
PriorityClassName string `json:"priorityClassName,omitempty"`
242257
}
243258

244259
// NodeClaim represents the node claim HardNodeAffinity, NodeSelector and Tolerations required by each replica.

pkg/apis/work/v1alpha2/zz_generated.deepcopy.go

Lines changed: 34 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controllers/federatedresourcequota/federated_resource_quota_enforcement_controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestCalculateUsedWithResourceBinding(t *testing.T) {
151151
{Name: "cluster2", Replicas: 7},
152152
{Name: "cluster3", Replicas: 7},
153153
},
154-
[]workv1alpha2.ComponentRequirements{
154+
[]workv1alpha2.Component{
155155
makeComponentWithReplicas(2, "100m", "128Mi"),
156156
makeComponentWithReplicas(0, "50m", "64Mi"),
157157
makeComponentWithReplicas(3, "25m", ""),
@@ -200,7 +200,7 @@ func makeBinding(cpu string, memory string, clusters []workv1alpha2.TargetCluste
200200
}
201201
}
202202

203-
func makeBindingWithComponents(clusters []workv1alpha2.TargetCluster, components []workv1alpha2.ComponentRequirements) workv1alpha2.ResourceBinding {
203+
func makeBindingWithComponents(clusters []workv1alpha2.TargetCluster, components []workv1alpha2.Component) workv1alpha2.ResourceBinding {
204204
return workv1alpha2.ResourceBinding{
205205
Spec: workv1alpha2.ResourceBindingSpec{
206206
Clusters: clusters,
@@ -209,10 +209,10 @@ func makeBindingWithComponents(clusters []workv1alpha2.TargetCluster, components
209209
}
210210
}
211211

212-
func makeComponentWithReplicas(replicas int32, cpu, memory string) workv1alpha2.ComponentRequirements {
213-
return workv1alpha2.ComponentRequirements{
212+
func makeComponentWithReplicas(replicas int32, cpu, memory string) workv1alpha2.Component {
213+
return workv1alpha2.Component{
214214
Replicas: replicas,
215-
ReplicaRequirements: &workv1alpha2.ReplicaRequirements{
215+
ReplicaRequirements: &workv1alpha2.ComponentReplicaRequirements{
216216
ResourceRequest: makeResourceRequest(cpu, memory),
217217
},
218218
}

pkg/detector/detector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ func (m *mockRESTMapper) ResourceSingularizer(resource string) (string, error) {
10441044
// mockResourceInterpreter is a mock implementation of the ResourceInterpreter interface
10451045
type mockResourceInterpreter struct{}
10461046

1047-
func (m *mockResourceInterpreter) GetComponents(_ *unstructured.Unstructured) ([]workv1alpha2.ComponentRequirements, error) {
1047+
func (m *mockResourceInterpreter) GetComponents(_ *unstructured.Unstructured) ([]workv1alpha2.Component, error) {
10481048
return nil, nil
10491049
}
10501050

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 50 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resourceinterpreter/customized/declarative/configurable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (c *ConfigurableInterpreter) GetReplicas(object *unstructured.Unstructured)
102102
}
103103

104104
// GetComponents returns the desired components of the object.
105-
func (c *ConfigurableInterpreter) GetComponents(object *unstructured.Unstructured) (components []workv1alpha2.ComponentRequirements, enabled bool, err error) {
105+
func (c *ConfigurableInterpreter) GetComponents(object *unstructured.Unstructured) (components []workv1alpha2.Component, enabled bool, err error) {
106106
klog.V(4).Infof("Get components for object: %v %s/%s with configurable interpreter.", object.GroupVersionKind(), object.GetNamespace(), object.GetName())
107107

108108
accessor, enabled := c.getCustomAccessor(object.GroupVersionKind())

pkg/resourceinterpreter/customized/declarative/luavm/lua.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ func (vm *VM) GetReplicas(obj *unstructured.Unstructured, script string) (replic
155155
}
156156

157157
// GetComponents returns the desired components of the object by executing a Lua script.
158-
func (vm *VM) GetComponents(obj *unstructured.Unstructured, script string) ([]workv1alpha2.ComponentRequirements, error) {
158+
func (vm *VM) GetComponents(obj *unstructured.Unstructured, script string) ([]workv1alpha2.Component, error) {
159159
results, err := vm.RunScript(script, "GetComponents", 1, obj)
160160
if err != nil {
161161
return nil, fmt.Errorf("failed to run 'GetComponents' script: %w", err)
162162
}
163163

164164
componentsResult := results[0]
165-
var components []workv1alpha2.ComponentRequirements
165+
var components []workv1alpha2.Component
166166

167167
switch componentsResult.Type() {
168168
case lua.LTTable:

0 commit comments

Comments
 (0)