mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Fix missing field conversions in v1beta1 DRA API
Fix missing fields in the v1beta1 hand-written conversion code: - Device: BindsToNode, BindingConditions, BindingFailureConditions, AllowMultipleAllocations were not copied when converting between v1beta1.BasicDevice (nested) and v1.Device (flat). - DeviceRequest: Capacity was not copied between v1beta1.DeviceRequest and v1.ExactDeviceRequest, and was missing from hasAnyMainRequestFieldsSet. These fields are for alpha features added after v1beta1, so while worth fixing, the impact in practice is limited.
This commit is contained in:
@@ -58,6 +58,7 @@ func Convert_v1beta1_DeviceRequest_To_v1_DeviceRequest(in *resourcev1beta1.Devic
|
||||
tolerations = append(tolerations, toleration)
|
||||
}
|
||||
exactDeviceRequest.Tolerations = tolerations
|
||||
exactDeviceRequest.Capacity = (*resourceapi.CapacityRequirements)(unsafe.Pointer(in.Capacity))
|
||||
out.Exactly = &exactDeviceRequest
|
||||
}
|
||||
return nil
|
||||
@@ -69,7 +70,8 @@ func hasAnyMainRequestFieldsSet(deviceRequest *resourcev1beta1.DeviceRequest) bo
|
||||
deviceRequest.AllocationMode != "" ||
|
||||
deviceRequest.Count != 0 ||
|
||||
deviceRequest.AdminAccess != nil ||
|
||||
deviceRequest.Tolerations != nil
|
||||
deviceRequest.Tolerations != nil ||
|
||||
deviceRequest.Capacity != nil
|
||||
}
|
||||
|
||||
func Convert_v1_DeviceRequest_To_v1beta1_DeviceRequest(in *resourceapi.DeviceRequest, out *resourcev1beta1.DeviceRequest, s conversion.Scope) error {
|
||||
@@ -102,6 +104,7 @@ func Convert_v1_DeviceRequest_To_v1beta1_DeviceRequest(in *resourceapi.DeviceReq
|
||||
tolerations = append(tolerations, toleration)
|
||||
}
|
||||
out.Tolerations = tolerations
|
||||
out.Capacity = (*resourcev1beta1.CapacityRequirements)(unsafe.Pointer(in.Exactly.Capacity))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -181,6 +184,10 @@ func Convert_v1beta1_Device_To_v1_Device(in *resourcev1beta1.Device, out *resour
|
||||
taints = append(taints, taint)
|
||||
}
|
||||
out.Taints = taints
|
||||
out.BindsToNode = basic.BindsToNode
|
||||
out.BindingConditions = basic.BindingConditions
|
||||
out.BindingFailureConditions = basic.BindingFailureConditions
|
||||
out.AllowMultipleAllocations = basic.AllowMultipleAllocations
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -226,6 +233,10 @@ func Convert_v1_Device_To_v1beta1_Device(in *resourceapi.Device, out *resourcev1
|
||||
taints = append(taints, taint)
|
||||
}
|
||||
out.Basic.Taints = taints
|
||||
out.Basic.BindsToNode = in.BindsToNode
|
||||
out.Basic.BindingConditions = in.BindingConditions
|
||||
out.Basic.BindingFailureConditions = in.BindingFailureConditions
|
||||
out.Basic.AllowMultipleAllocations = in.AllowMultipleAllocations
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user