Merge pull request #91603 from pancernik/v1beta1-requested-to-cap-ratio-encoding
Configure strict encoding for RequestedToCapacityRatioArgs
This commit is contained in:
@@ -17,9 +17,7 @@ limitations under the License.
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
gojson "encoding/json"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@@ -80,7 +78,7 @@ type PodTopologySpreadArgs struct {
|
||||
// Empty by default.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DefaultConstraints []v1.TopologySpreadConstraint `json:"defaultConstraints"`
|
||||
DefaultConstraints []corev1.TopologySpreadConstraint `json:"defaultConstraints"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@@ -123,39 +121,20 @@ type NodeResourcesMostAllocatedArgs struct {
|
||||
Resources []ResourceSpec `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
// TODO add JSON tags and remove custom unmarshalling in v1beta1.
|
||||
// UtilizationShapePoint and ResourceSpec fields are not annotated with JSON tags in v1alpha2
|
||||
// to maintain backward compatibility with the args shipped with v1.18.
|
||||
// See https://github.com/kubernetes/kubernetes/pull/88585#discussion_r405021905
|
||||
|
||||
// UtilizationShapePoint represents single point of priority function shape.
|
||||
type UtilizationShapePoint struct {
|
||||
// Utilization (x axis). Valid values are 0 to 100. Fully utilized node maps to 100.
|
||||
Utilization int32
|
||||
Utilization int32 `json:"utilization"`
|
||||
// Score assigned to given utilization (y axis). Valid values are 0 to 10.
|
||||
Score int32
|
||||
}
|
||||
|
||||
// UnmarshalJSON provides case insensitive unmarshalling for the type.
|
||||
// TODO remove when copying to v1beta1.
|
||||
func (t *UtilizationShapePoint) UnmarshalJSON(data []byte) error {
|
||||
type internal *UtilizationShapePoint
|
||||
return gojson.Unmarshal(data, internal(t))
|
||||
Score int32 `json:"score"`
|
||||
}
|
||||
|
||||
// ResourceSpec represents single resource and weight for bin packing of priority RequestedToCapacityRatioArguments.
|
||||
type ResourceSpec struct {
|
||||
// Name of the resource to be managed by RequestedToCapacityRatio function.
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
// Weight of the resource.
|
||||
Weight int64
|
||||
}
|
||||
|
||||
// UnmarshalJSON provides case insensitive unmarshalling for the type.
|
||||
// TODO remove when copying to v1beta1.
|
||||
func (t *ResourceSpec) UnmarshalJSON(data []byte) error {
|
||||
type internal *ResourceSpec
|
||||
return gojson.Unmarshal(data, internal(t))
|
||||
Weight int64 `json:"weight,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
Reference in New Issue
Block a user