mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
[KEP-4817] Update to v1beta1
Signed-off-by: Lionel Jouin <lionel.jouin@est.tech>
This commit is contained in:
parent
4b76ba1a87
commit
7e0035ec86
@ -709,6 +709,18 @@ type ResourceClaimStatus struct {
|
||||
// it got removed. May be reused once decoding v1alpha3 is no longer
|
||||
// supported.
|
||||
// DeallocationRequested bool `json:"deallocationRequested,omitempty" protobuf:"bytes,3,opt,name=deallocationRequested"`
|
||||
|
||||
// Devices contains the status of each device allocated for this
|
||||
// claim, as reported by the driver. This can include driver-specific
|
||||
// information. Entries are owned by their respective drivers.
|
||||
//
|
||||
// +optional
|
||||
// +listType=map
|
||||
// +listMapKey=driver
|
||||
// +listMapKey=device
|
||||
// +listMapKey=pool
|
||||
// +featureGate=DRAResourceClaimDeviceStatus
|
||||
Devices []AllocatedDeviceStatus `json:"devices,omitempty" protobuf:"bytes,4,opt,name=devices"`
|
||||
}
|
||||
|
||||
// ReservedForMaxSize is the maximum number of entries in
|
||||
@ -989,3 +1001,77 @@ type ResourceClaimTemplateList struct {
|
||||
// Items is the list of resource claim templates.
|
||||
Items []ResourceClaimTemplate `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
// AllocatedDeviceStatus contains the status of an allocated device, if the
|
||||
// driver chooses to report it. This may include driver-specific information.
|
||||
type AllocatedDeviceStatus struct {
|
||||
// Driver specifies the name of the DRA driver whose kubelet
|
||||
// plugin should be invoked to process the allocation once the claim is
|
||||
// needed on a node.
|
||||
//
|
||||
// Must be a DNS subdomain and should end with a DNS domain owned by the
|
||||
// vendor of the driver.
|
||||
//
|
||||
// +required
|
||||
Driver string `json:"driver" protobuf:"bytes,1,rep,name=driver"`
|
||||
|
||||
// This name together with the driver name and the device name field
|
||||
// identify which device was allocated (`<driver name>/<pool name>/<device name>`).
|
||||
//
|
||||
// Must not be longer than 253 characters and may contain one or more
|
||||
// DNS sub-domains separated by slashes.
|
||||
//
|
||||
// +required
|
||||
Pool string `json:"pool" protobuf:"bytes,2,rep,name=pool"`
|
||||
|
||||
// Device references one device instance via its name in the driver's
|
||||
// resource pool. It must be a DNS label.
|
||||
//
|
||||
// +required
|
||||
Device string `json:"device" protobuf:"bytes,3,rep,name=device"`
|
||||
|
||||
// Conditions contains the latest observation of the device's state.
|
||||
// If the device has been configured according to the class and claim
|
||||
// config references, the `Ready` condition should be True.
|
||||
//
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Conditions []metav1.Condition `json:"conditions" protobuf:"bytes,4,opt,name=conditions"`
|
||||
|
||||
// Data contains arbitrary driver-specific data.
|
||||
//
|
||||
// +optional
|
||||
Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
|
||||
|
||||
// NetworkData contains network-related information specific to the device.
|
||||
//
|
||||
// +optional
|
||||
NetworkData *NetworkDeviceData `json:"networkData,omitempty" protobuf:"bytes,6,opt,name=networkData"`
|
||||
}
|
||||
|
||||
// NetworkDeviceData provides network-related details for the allocated device.
|
||||
// This information may be filled by drivers or other components to configure
|
||||
// or identify the device within a network context.
|
||||
type NetworkDeviceData struct {
|
||||
// InterfaceName specifies the name of the network interface associated with
|
||||
// the allocated device. This might be the name of a physical or virtual
|
||||
// network interface.
|
||||
//
|
||||
// +optional
|
||||
InterfaceName string `json:"interfaceName,omitempty" protobuf:"bytes,1,opt,name=interfaceName"`
|
||||
|
||||
// IPs lists the network addresses assigned to the device's network interface.
|
||||
// This can include both IPv4 and IPv6 addresses.
|
||||
// The IPs are in the CIDR notation, which includes both the address and the
|
||||
// associated subnet mask.
|
||||
// e.g.: "192.0.2.5/24" for IPv4 and "2001:db8::5/64" for IPv6.
|
||||
//
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
IPs []string `json:"ips,omitempty" protobuf:"bytes,2,opt,name=ips"`
|
||||
|
||||
// HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.
|
||||
//
|
||||
// +optional
|
||||
HardwareAddress string `json:"hardwareAddress,omitempty" protobuf:"bytes,3,opt,name=hardwareAddress"`
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
|
||||
|
||||
gomega.Eventually(ctx, func(ctx context.Context) (*resourceapi.ResourceClaim, error) {
|
||||
var err error
|
||||
allocatedResourceClaim, err = b.f.ClientSet.ResourceV1alpha3().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
|
||||
allocatedResourceClaim, err = b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
|
||||
return allocatedResourceClaim, err
|
||||
}).WithTimeout(f.Timeouts.PodDelete).ShouldNot(gomega.HaveField("Status.Allocation", (*resourceapi.AllocationResult)(nil)))
|
||||
|
||||
@ -469,7 +469,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
|
||||
gomega.Expect(updatedResourceClaim2).ToNot(gomega.BeNil())
|
||||
gomega.Expect(updatedResourceClaim2.Status.Devices).To(gomega.Equal(updatedResourceClaim.Status.Devices))
|
||||
|
||||
getResourceClaim, err := b.f.ClientSet.ResourceV1alpha3().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
|
||||
getResourceClaim, err := b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(getResourceClaim).ToNot(gomega.BeNil())
|
||||
gomega.Expect(getResourceClaim.Status.Devices).To(gomega.Equal(updatedResourceClaim.Status.Devices))
|
||||
|
@ -562,5 +562,5 @@ func (ex *ExamplePlugin) CountCalls(methodSuffix string) int {
|
||||
}
|
||||
|
||||
func (ex *ExamplePlugin) UpdateStatus(ctx context.Context, resourceClaim *resourceapi.ResourceClaim) (*resourceapi.ResourceClaim, error) {
|
||||
return ex.kubeClient.ResourceV1alpha3().ResourceClaims(resourceClaim.Namespace).UpdateStatus(ctx, resourceClaim, metav1.UpdateOptions{})
|
||||
return ex.kubeClient.ResourceV1beta1().ResourceClaims(resourceClaim.Namespace).UpdateStatus(ctx, resourceClaim, metav1.UpdateOptions{})
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/resource/v1alpha3"
|
||||
"k8s.io/api/resource/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
@ -53,30 +53,30 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
ns := framework.CreateNamespaceOrDie(client1, "test-enable-dra-resourceclaim-device-status", t)
|
||||
|
||||
rcDisabledName := "test-enable-dra-resourceclaim-device-status-rc-disabled"
|
||||
rcDisabled := &v1alpha3.ResourceClaim{
|
||||
rcDisabled := &v1beta1.ResourceClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: rcDisabledName,
|
||||
},
|
||||
Spec: v1alpha3.ResourceClaimSpec{
|
||||
Devices: v1alpha3.DeviceClaim{
|
||||
Requests: []v1alpha3.DeviceRequest{
|
||||
Spec: v1beta1.ResourceClaimSpec{
|
||||
Devices: v1beta1.DeviceClaim{
|
||||
Requests: []v1beta1.DeviceRequest{
|
||||
{
|
||||
Name: "foo",
|
||||
DeviceClassName: "foo",
|
||||
Count: 1,
|
||||
AllocationMode: v1alpha3.DeviceAllocationModeExactCount,
|
||||
AllocationMode: v1beta1.DeviceAllocationModeExactCount,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := client1.ResourceV1alpha3().ResourceClaims(ns.Name).Create(context.TODO(), rcDisabled, metav1.CreateOptions{}); err != nil {
|
||||
if _, err := client1.ResourceV1beta1().ResourceClaims(ns.Name).Create(context.TODO(), rcDisabled, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
rcDisabled.Status = v1alpha3.ResourceClaimStatus{
|
||||
Devices: []v1alpha3.AllocatedDeviceStatus{
|
||||
rcDisabled.Status = v1beta1.ResourceClaimStatus{
|
||||
Devices: []v1beta1.AllocatedDeviceStatus{
|
||||
{
|
||||
Driver: "foo",
|
||||
Pool: "foo",
|
||||
@ -84,7 +84,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
Data: runtime.RawExtension{
|
||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||
},
|
||||
NetworkData: &v1alpha3.NetworkDeviceData{
|
||||
NetworkData: &v1beta1.NetworkDeviceData{
|
||||
InterfaceName: "net-1",
|
||||
IPs: []string{
|
||||
"10.9.8.0/24",
|
||||
@ -95,11 +95,11 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := client1.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcDisabled, metav1.UpdateOptions{}); err != nil {
|
||||
if _, err := client1.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcDisabled, metav1.UpdateOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
rcDisabled, err = client1.ResourceV1alpha3().ResourceClaims(ns.Name).Get(context.TODO(), rcDisabledName, metav1.GetOptions{})
|
||||
rcDisabled, err = client1.ResourceV1beta1().ResourceClaims(ns.Name).Get(context.TODO(), rcDisabledName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -123,32 +123,32 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
rcEnabledName := "test-enable-dra-resourceclaim-device-status-rc-enabled"
|
||||
rcEnabled := &v1alpha3.ResourceClaim{
|
||||
rcEnabled := &v1beta1.ResourceClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: rcEnabledName,
|
||||
},
|
||||
Spec: v1alpha3.ResourceClaimSpec{
|
||||
Devices: v1alpha3.DeviceClaim{
|
||||
Requests: []v1alpha3.DeviceRequest{
|
||||
Spec: v1beta1.ResourceClaimSpec{
|
||||
Devices: v1beta1.DeviceClaim{
|
||||
Requests: []v1beta1.DeviceRequest{
|
||||
{
|
||||
Name: "bar",
|
||||
DeviceClassName: "bar",
|
||||
Count: 1,
|
||||
AllocationMode: v1alpha3.DeviceAllocationModeExactCount,
|
||||
AllocationMode: v1beta1.DeviceAllocationModeExactCount,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).Create(context.TODO(), rcEnabled, metav1.CreateOptions{}); err != nil {
|
||||
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).Create(context.TODO(), rcEnabled, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Tests the validation is enabled.
|
||||
// validation will refuse this update as the device is not allocated.
|
||||
rcEnabled.Status = v1alpha3.ResourceClaimStatus{
|
||||
Devices: []v1alpha3.AllocatedDeviceStatus{
|
||||
rcEnabled.Status = v1beta1.ResourceClaimStatus{
|
||||
Devices: []v1beta1.AllocatedDeviceStatus{
|
||||
{
|
||||
Driver: "bar",
|
||||
Pool: "bar",
|
||||
@ -156,7 +156,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
Data: runtime.RawExtension{
|
||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||
},
|
||||
NetworkData: &v1alpha3.NetworkDeviceData{
|
||||
NetworkData: &v1beta1.NetworkDeviceData{
|
||||
InterfaceName: "net-1",
|
||||
IPs: []string{
|
||||
"10.9.8.0/24",
|
||||
@ -167,14 +167,14 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err == nil {
|
||||
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err == nil {
|
||||
t.Fatalf("Expected error (must be an allocated device in the claim)")
|
||||
}
|
||||
|
||||
rcEnabled.Status = v1alpha3.ResourceClaimStatus{
|
||||
Allocation: &v1alpha3.AllocationResult{
|
||||
Devices: v1alpha3.DeviceAllocationResult{
|
||||
Results: []v1alpha3.DeviceRequestAllocationResult{
|
||||
rcEnabled.Status = v1beta1.ResourceClaimStatus{
|
||||
Allocation: &v1beta1.AllocationResult{
|
||||
Devices: v1beta1.DeviceAllocationResult{
|
||||
Results: []v1beta1.DeviceRequestAllocationResult{
|
||||
{
|
||||
Request: "bar",
|
||||
Driver: "bar",
|
||||
@ -184,7 +184,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Devices: []v1alpha3.AllocatedDeviceStatus{
|
||||
Devices: []v1beta1.AllocatedDeviceStatus{
|
||||
{
|
||||
Driver: "bar",
|
||||
Pool: "bar",
|
||||
@ -192,7 +192,7 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
Data: runtime.RawExtension{
|
||||
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
|
||||
},
|
||||
NetworkData: &v1alpha3.NetworkDeviceData{
|
||||
NetworkData: &v1beta1.NetworkDeviceData{
|
||||
InterfaceName: "net-1",
|
||||
IPs: []string{
|
||||
"10.9.8.0/24",
|
||||
@ -203,12 +203,12 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err != nil {
|
||||
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Tests the field is enabled.
|
||||
rcEnabled, err = client2.ResourceV1alpha3().ResourceClaims(ns.Name).Get(context.TODO(), rcEnabledName, metav1.GetOptions{})
|
||||
rcEnabled, err = client2.ResourceV1beta1().ResourceClaims(ns.Name).Get(context.TODO(), rcEnabledName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user