mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
ResourceClaim.Status.Devices.Data as pointer
Signed-off-by: Lionel Jouin <lionel.jouin@est.tech>
This commit is contained in:
parent
b7d6e78726
commit
11d68ecc4e
@ -62,7 +62,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
|||||||
//
|
//
|
||||||
// This is necessary because randomly generated content
|
// This is necessary because randomly generated content
|
||||||
// might be valid JSON which changes during re-encoding.
|
// might be valid JSON which changes during re-encoding.
|
||||||
r.Data = runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)}
|
r.Data = &runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ type AllocatedDeviceStatus struct {
|
|||||||
// The length of the raw data must be smaller or equal to 10 Ki.
|
// The length of the raw data must be smaller or equal to 10 Ki.
|
||||||
//
|
//
|
||||||
// +optional
|
// +optional
|
||||||
Data runtime.RawExtension
|
Data *runtime.RawExtension
|
||||||
|
|
||||||
// NetworkData contains network-related information specific to the device.
|
// NetworkData contains network-related information specific to the device.
|
||||||
//
|
//
|
||||||
|
@ -752,8 +752,8 @@ func validateDeviceStatus(device resource.AllocatedDeviceStatus, fldPath *field.
|
|||||||
allErrs = append(allErrs, field.TooMany(fldPath.Child("conditions"), len(device.Conditions), resource.AllocatedDeviceStatusMaxConditions))
|
allErrs = append(allErrs, field.TooMany(fldPath.Child("conditions"), len(device.Conditions), resource.AllocatedDeviceStatusMaxConditions))
|
||||||
}
|
}
|
||||||
allErrs = append(allErrs, metav1validation.ValidateConditions(device.Conditions, fldPath.Child("conditions"))...)
|
allErrs = append(allErrs, metav1validation.ValidateConditions(device.Conditions, fldPath.Child("conditions"))...)
|
||||||
if len(device.Data.Raw) > 0 { // Data is an optional field.
|
if device.Data != nil && len(device.Data.Raw) > 0 { // Data is an optional field.
|
||||||
allErrs = append(allErrs, validateRawExtension(device.Data, fldPath.Child("data"), false, resource.AllocatedDeviceStatusDataMaxLength)...)
|
allErrs = append(allErrs, validateRawExtension(*device.Data, fldPath.Child("data"), false, resource.AllocatedDeviceStatusDataMaxLength)...)
|
||||||
}
|
}
|
||||||
allErrs = append(allErrs, validateNetworkDeviceData(device.NetworkData, fldPath.Child("networkData"))...)
|
allErrs = append(allErrs, validateNetworkDeviceData(device.NetworkData, fldPath.Child("networkData"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
|
@ -1003,7 +1003,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
|
|||||||
{Type: "test-6", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-6", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
{Type: "test-7", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-7", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
},
|
},
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||||
},
|
},
|
||||||
NetworkData: &resource.NetworkDeviceData{
|
NetworkData: &resource.NetworkDeviceData{
|
||||||
@ -1090,7 +1090,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
|
|||||||
Driver: goodName,
|
Driver: goodName,
|
||||||
Pool: goodName,
|
Pool: goodName,
|
||||||
Device: goodName,
|
Device: goodName,
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`foo`),
|
Raw: []byte(`foo`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1112,7 +1112,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
|
|||||||
Driver: goodName,
|
Driver: goodName,
|
||||||
Pool: goodName,
|
Pool: goodName,
|
||||||
Device: goodName,
|
Device: goodName,
|
||||||
Data: runtime.RawExtension{Raw: []byte(`{"str": "` + strings.Repeat("x", resource.AllocatedDeviceStatusDataMaxLength-9-2+1 /* too large by one */) + `"}`)},
|
Data: &runtime.RawExtension{Raw: []byte(`{"str": "` + strings.Repeat("x", resource.AllocatedDeviceStatusDataMaxLength-9-2+1 /* too large by one */) + `"}`)},
|
||||||
Conditions: []metav1.Condition{
|
Conditions: []metav1.Condition{
|
||||||
{Type: "test-0", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-0", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
{Type: "test-1", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-1", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
@ -1219,7 +1219,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
|
|||||||
Driver: goodName,
|
Driver: goodName,
|
||||||
Pool: goodName,
|
Pool: goodName,
|
||||||
Device: goodName,
|
Device: goodName,
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`foo`),
|
Raw: []byte(`foo`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1241,7 +1241,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
|
|||||||
Driver: goodName,
|
Driver: goodName,
|
||||||
Pool: goodName,
|
Pool: goodName,
|
||||||
Device: goodName,
|
Device: goodName,
|
||||||
Data: runtime.RawExtension{Raw: []byte(`{"str": "` + strings.Repeat("x", resource.AllocatedDeviceStatusDataMaxLength-9-2+1 /* too large by one */) + `"}`)},
|
Data: &runtime.RawExtension{Raw: []byte(`{"str": "` + strings.Repeat("x", resource.AllocatedDeviceStatusDataMaxLength-9-2+1 /* too large by one */) + `"}`)},
|
||||||
Conditions: []metav1.Condition{
|
Conditions: []metav1.Condition{
|
||||||
{Type: "test-0", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-0", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
{Type: "test-1", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
{Type: "test-1", Status: metav1.ConditionTrue, Reason: "test_reason", LastTransitionTime: metav1.Now(), ObservedGeneration: 0},
|
||||||
|
@ -1051,7 +1051,7 @@ type AllocatedDeviceStatus struct {
|
|||||||
// The length of the raw data must be smaller or equal to 10 Ki.
|
// The length of the raw data must be smaller or equal to 10 Ki.
|
||||||
//
|
//
|
||||||
// +optional
|
// +optional
|
||||||
Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
|
Data *runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
|
||||||
|
|
||||||
// NetworkData contains network-related information specific to the device.
|
// NetworkData contains network-related information specific to the device.
|
||||||
//
|
//
|
||||||
|
@ -1054,7 +1054,7 @@ type AllocatedDeviceStatus struct {
|
|||||||
// The length of the raw data must be smaller or equal to 10 Ki.
|
// The length of the raw data must be smaller or equal to 10 Ki.
|
||||||
//
|
//
|
||||||
// +optional
|
// +optional
|
||||||
Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
|
Data *runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
|
||||||
|
|
||||||
// NetworkData contains network-related information specific to the device.
|
// NetworkData contains network-related information specific to the device.
|
||||||
//
|
//
|
||||||
|
@ -438,7 +438,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
|
|||||||
Pool: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Pool,
|
Pool: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Pool,
|
||||||
Device: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Device,
|
Device: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Device,
|
||||||
Conditions: []metav1.Condition{{Type: "a", Status: "True", Message: "c", Reason: "d", LastTransitionTime: metav1.NewTime(time.Now().Truncate(time.Second))}},
|
Conditions: []metav1.Condition{{Type: "a", Status: "True", Message: "c", Reason: "d", LastTransitionTime: metav1.NewTime(time.Now().Truncate(time.Second))}},
|
||||||
Data: runtime.RawExtension{Raw: []byte(`{"foo":"bar"}`)},
|
Data: &runtime.RawExtension{Raw: []byte(`{"foo":"bar"}`)},
|
||||||
NetworkData: &resourceapi.NetworkDeviceData{
|
NetworkData: &resourceapi.NetworkDeviceData{
|
||||||
InterfaceName: "inf1",
|
InterfaceName: "inf1",
|
||||||
IPs: []string{"10.9.8.0/24", "2001:db8::/64"},
|
IPs: []string{"10.9.8.0/24", "2001:db8::/64"},
|
||||||
@ -457,7 +457,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
|
|||||||
Pool: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Pool,
|
Pool: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Pool,
|
||||||
Device: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Device,
|
Device: allocatedResourceClaim.Status.Allocation.Devices.Results[0].Device,
|
||||||
Conditions: []metav1.Condition{{Type: "e", Status: "True", Message: "g", Reason: "h", LastTransitionTime: metav1.NewTime(time.Now().Truncate(time.Second))}},
|
Conditions: []metav1.Condition{{Type: "e", Status: "True", Message: "g", Reason: "h", LastTransitionTime: metav1.NewTime(time.Now().Truncate(time.Second))}},
|
||||||
Data: runtime.RawExtension{Raw: []byte(`{"bar":"foo"}`)},
|
Data: &runtime.RawExtension{Raw: []byte(`{"bar":"foo"}`)},
|
||||||
NetworkData: &resourceapi.NetworkDeviceData{
|
NetworkData: &resourceapi.NetworkDeviceData{
|
||||||
InterfaceName: "inf2",
|
InterfaceName: "inf2",
|
||||||
IPs: []string{"10.9.8.1/24", "2001:db8::1/64"},
|
IPs: []string{"10.9.8.1/24", "2001:db8::1/64"},
|
||||||
|
@ -81,7 +81,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
|||||||
Driver: "foo",
|
Driver: "foo",
|
||||||
Pool: "foo",
|
Pool: "foo",
|
||||||
Device: "foo",
|
Device: "foo",
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||||
},
|
},
|
||||||
NetworkData: &v1beta1.NetworkDeviceData{
|
NetworkData: &v1beta1.NetworkDeviceData{
|
||||||
@ -153,7 +153,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
|||||||
Driver: "bar",
|
Driver: "bar",
|
||||||
Pool: "bar",
|
Pool: "bar",
|
||||||
Device: "bar",
|
Device: "bar",
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||||
},
|
},
|
||||||
NetworkData: &v1beta1.NetworkDeviceData{
|
NetworkData: &v1beta1.NetworkDeviceData{
|
||||||
@ -189,7 +189,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
|||||||
Driver: "bar",
|
Driver: "bar",
|
||||||
Pool: "bar",
|
Pool: "bar",
|
||||||
Device: "bar",
|
Device: "bar",
|
||||||
Data: runtime.RawExtension{
|
Data: &runtime.RawExtension{
|
||||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||||
},
|
},
|
||||||
NetworkData: &v1beta1.NetworkDeviceData{
|
NetworkData: &v1beta1.NetworkDeviceData{
|
||||||
|
Loading…
Reference in New Issue
Block a user