Skip to content

Commit 7e0035e

Browse files
committed
[KEP-4817] Update to v1beta1
Signed-off-by: Lionel Jouin <[email protected]>
1 parent 4b76ba1 commit 7e0035e

File tree

4 files changed

+119
-33
lines changed

4 files changed

+119
-33
lines changed

staging/src/k8s.io/api/resource/v1beta1/types.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,18 @@ type ResourceClaimStatus struct {
709709
// it got removed. May be reused once decoding v1alpha3 is no longer
710710
// supported.
711711
// DeallocationRequested bool `json:"deallocationRequested,omitempty" protobuf:"bytes,3,opt,name=deallocationRequested"`
712+
713+
// Devices contains the status of each device allocated for this
714+
// claim, as reported by the driver. This can include driver-specific
715+
// information. Entries are owned by their respective drivers.
716+
//
717+
// +optional
718+
// +listType=map
719+
// +listMapKey=driver
720+
// +listMapKey=device
721+
// +listMapKey=pool
722+
// +featureGate=DRAResourceClaimDeviceStatus
723+
Devices []AllocatedDeviceStatus `json:"devices,omitempty" protobuf:"bytes,4,opt,name=devices"`
712724
}
713725

714726
// ReservedForMaxSize is the maximum number of entries in
@@ -989,3 +1001,77 @@ type ResourceClaimTemplateList struct {
9891001
// Items is the list of resource claim templates.
9901002
Items []ResourceClaimTemplate `json:"items" protobuf:"bytes,2,rep,name=items"`
9911003
}
1004+
1005+
// AllocatedDeviceStatus contains the status of an allocated device, if the
1006+
// driver chooses to report it. This may include driver-specific information.
1007+
type AllocatedDeviceStatus struct {
1008+
// Driver specifies the name of the DRA driver whose kubelet
1009+
// plugin should be invoked to process the allocation once the claim is
1010+
// needed on a node.
1011+
//
1012+
// Must be a DNS subdomain and should end with a DNS domain owned by the
1013+
// vendor of the driver.
1014+
//
1015+
// +required
1016+
Driver string `json:"driver" protobuf:"bytes,1,rep,name=driver"`
1017+
1018+
// This name together with the driver name and the device name field
1019+
// identify which device was allocated (`<driver name>/<pool name>/<device name>`).
1020+
//
1021+
// Must not be longer than 253 characters and may contain one or more
1022+
// DNS sub-domains separated by slashes.
1023+
//
1024+
// +required
1025+
Pool string `json:"pool" protobuf:"bytes,2,rep,name=pool"`
1026+
1027+
// Device references one device instance via its name in the driver's
1028+
// resource pool. It must be a DNS label.
1029+
//
1030+
// +required
1031+
Device string `json:"device" protobuf:"bytes,3,rep,name=device"`
1032+
1033+
// Conditions contains the latest observation of the device's state.
1034+
// If the device has been configured according to the class and claim
1035+
// config references, the `Ready` condition should be True.
1036+
//
1037+
// +optional
1038+
// +listType=atomic
1039+
Conditions []metav1.Condition `json:"conditions" protobuf:"bytes,4,opt,name=conditions"`
1040+
1041+
// Data contains arbitrary driver-specific data.
1042+
//
1043+
// +optional
1044+
Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,5,opt,name=data"`
1045+
1046+
// NetworkData contains network-related information specific to the device.
1047+
//
1048+
// +optional
1049+
NetworkData *NetworkDeviceData `json:"networkData,omitempty" protobuf:"bytes,6,opt,name=networkData"`
1050+
}
1051+
1052+
// NetworkDeviceData provides network-related details for the allocated device.
1053+
// This information may be filled by drivers or other components to configure
1054+
// or identify the device within a network context.
1055+
type NetworkDeviceData struct {
1056+
// InterfaceName specifies the name of the network interface associated with
1057+
// the allocated device. This might be the name of a physical or virtual
1058+
// network interface.
1059+
//
1060+
// +optional
1061+
InterfaceName string `json:"interfaceName,omitempty" protobuf:"bytes,1,opt,name=interfaceName"`
1062+
1063+
// IPs lists the network addresses assigned to the device's network interface.
1064+
// This can include both IPv4 and IPv6 addresses.
1065+
// The IPs are in the CIDR notation, which includes both the address and the
1066+
// associated subnet mask.
1067+
// e.g.: "192.0.2.5/24" for IPv4 and "2001:db8::5/64" for IPv6.
1068+
//
1069+
// +optional
1070+
// +listType=atomic
1071+
IPs []string `json:"ips,omitempty" protobuf:"bytes,2,opt,name=ips"`
1072+
1073+
// HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.
1074+
//
1075+
// +optional
1076+
HardwareAddress string `json:"hardwareAddress,omitempty" protobuf:"bytes,3,opt,name=hardwareAddress"`
1077+
}

test/e2e/dra/dra.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
415415

416416
gomega.Eventually(ctx, func(ctx context.Context) (*resourceapi.ResourceClaim, error) {
417417
var err error
418-
allocatedResourceClaim, err = b.f.ClientSet.ResourceV1alpha3().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
418+
allocatedResourceClaim, err = b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
419419
return allocatedResourceClaim, err
420420
}).WithTimeout(f.Timeouts.PodDelete).ShouldNot(gomega.HaveField("Status.Allocation", (*resourceapi.AllocationResult)(nil)))
421421

@@ -469,7 +469,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
469469
gomega.Expect(updatedResourceClaim2).ToNot(gomega.BeNil())
470470
gomega.Expect(updatedResourceClaim2.Status.Devices).To(gomega.Equal(updatedResourceClaim.Status.Devices))
471471

472-
getResourceClaim, err := b.f.ClientSet.ResourceV1alpha3().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
472+
getResourceClaim, err := b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
473473
framework.ExpectNoError(err)
474474
gomega.Expect(getResourceClaim).ToNot(gomega.BeNil())
475475
gomega.Expect(getResourceClaim.Status.Devices).To(gomega.Equal(updatedResourceClaim.Status.Devices))

test/e2e/dra/test-driver/app/kubeletplugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,5 +562,5 @@ func (ex *ExamplePlugin) CountCalls(methodSuffix string) int {
562562
}
563563

564564
func (ex *ExamplePlugin) UpdateStatus(ctx context.Context, resourceClaim *resourceapi.ResourceClaim) (*resourceapi.ResourceClaim, error) {
565-
return ex.kubeClient.ResourceV1alpha3().ResourceClaims(resourceClaim.Namespace).UpdateStatus(ctx, resourceClaim, metav1.UpdateOptions{})
565+
return ex.kubeClient.ResourceV1beta1().ResourceClaims(resourceClaim.Namespace).UpdateStatus(ctx, resourceClaim, metav1.UpdateOptions{})
566566
}

test/integration/resourceclaim/feature_enable_disable_test.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"testing"
2323

24-
"k8s.io/api/resource/v1alpha3"
24+
"k8s.io/api/resource/v1beta1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/runtime"
2727
clientset "k8s.io/client-go/kubernetes"
@@ -53,38 +53,38 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
5353
ns := framework.CreateNamespaceOrDie(client1, "test-enable-dra-resourceclaim-device-status", t)
5454

5555
rcDisabledName := "test-enable-dra-resourceclaim-device-status-rc-disabled"
56-
rcDisabled := &v1alpha3.ResourceClaim{
56+
rcDisabled := &v1beta1.ResourceClaim{
5757
ObjectMeta: metav1.ObjectMeta{
5858
Name: rcDisabledName,
5959
},
60-
Spec: v1alpha3.ResourceClaimSpec{
61-
Devices: v1alpha3.DeviceClaim{
62-
Requests: []v1alpha3.DeviceRequest{
60+
Spec: v1beta1.ResourceClaimSpec{
61+
Devices: v1beta1.DeviceClaim{
62+
Requests: []v1beta1.DeviceRequest{
6363
{
6464
Name: "foo",
6565
DeviceClassName: "foo",
6666
Count: 1,
67-
AllocationMode: v1alpha3.DeviceAllocationModeExactCount,
67+
AllocationMode: v1beta1.DeviceAllocationModeExactCount,
6868
},
6969
},
7070
},
7171
},
7272
}
7373

74-
if _, err := client1.ResourceV1alpha3().ResourceClaims(ns.Name).Create(context.TODO(), rcDisabled, metav1.CreateOptions{}); err != nil {
74+
if _, err := client1.ResourceV1beta1().ResourceClaims(ns.Name).Create(context.TODO(), rcDisabled, metav1.CreateOptions{}); err != nil {
7575
t.Fatal(err)
7676
}
7777

78-
rcDisabled.Status = v1alpha3.ResourceClaimStatus{
79-
Devices: []v1alpha3.AllocatedDeviceStatus{
78+
rcDisabled.Status = v1beta1.ResourceClaimStatus{
79+
Devices: []v1beta1.AllocatedDeviceStatus{
8080
{
8181
Driver: "foo",
8282
Pool: "foo",
8383
Device: "foo",
8484
Data: runtime.RawExtension{
8585
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
8686
},
87-
NetworkData: &v1alpha3.NetworkDeviceData{
87+
NetworkData: &v1beta1.NetworkDeviceData{
8888
InterfaceName: "net-1",
8989
IPs: []string{
9090
"10.9.8.0/24",
@@ -95,11 +95,11 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
9595
},
9696
},
9797
}
98-
if _, err := client1.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcDisabled, metav1.UpdateOptions{}); err != nil {
98+
if _, err := client1.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcDisabled, metav1.UpdateOptions{}); err != nil {
9999
t.Fatal(err)
100100
}
101101

102-
rcDisabled, err = client1.ResourceV1alpha3().ResourceClaims(ns.Name).Get(context.TODO(), rcDisabledName, metav1.GetOptions{})
102+
rcDisabled, err = client1.ResourceV1beta1().ResourceClaims(ns.Name).Get(context.TODO(), rcDisabledName, metav1.GetOptions{})
103103
if err != nil {
104104
t.Fatal(err)
105105
}
@@ -123,40 +123,40 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
123123
}
124124

125125
rcEnabledName := "test-enable-dra-resourceclaim-device-status-rc-enabled"
126-
rcEnabled := &v1alpha3.ResourceClaim{
126+
rcEnabled := &v1beta1.ResourceClaim{
127127
ObjectMeta: metav1.ObjectMeta{
128128
Name: rcEnabledName,
129129
},
130-
Spec: v1alpha3.ResourceClaimSpec{
131-
Devices: v1alpha3.DeviceClaim{
132-
Requests: []v1alpha3.DeviceRequest{
130+
Spec: v1beta1.ResourceClaimSpec{
131+
Devices: v1beta1.DeviceClaim{
132+
Requests: []v1beta1.DeviceRequest{
133133
{
134134
Name: "bar",
135135
DeviceClassName: "bar",
136136
Count: 1,
137-
AllocationMode: v1alpha3.DeviceAllocationModeExactCount,
137+
AllocationMode: v1beta1.DeviceAllocationModeExactCount,
138138
},
139139
},
140140
},
141141
},
142142
}
143143

144-
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).Create(context.TODO(), rcEnabled, metav1.CreateOptions{}); err != nil {
144+
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).Create(context.TODO(), rcEnabled, metav1.CreateOptions{}); err != nil {
145145
t.Fatal(err)
146146
}
147147

148148
// Tests the validation is enabled.
149149
// validation will refuse this update as the device is not allocated.
150-
rcEnabled.Status = v1alpha3.ResourceClaimStatus{
151-
Devices: []v1alpha3.AllocatedDeviceStatus{
150+
rcEnabled.Status = v1beta1.ResourceClaimStatus{
151+
Devices: []v1beta1.AllocatedDeviceStatus{
152152
{
153153
Driver: "bar",
154154
Pool: "bar",
155155
Device: "bar",
156156
Data: runtime.RawExtension{
157157
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
158158
},
159-
NetworkData: &v1alpha3.NetworkDeviceData{
159+
NetworkData: &v1beta1.NetworkDeviceData{
160160
InterfaceName: "net-1",
161161
IPs: []string{
162162
"10.9.8.0/24",
@@ -167,14 +167,14 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
167167
},
168168
},
169169
}
170-
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err == nil {
170+
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err == nil {
171171
t.Fatalf("Expected error (must be an allocated device in the claim)")
172172
}
173173

174-
rcEnabled.Status = v1alpha3.ResourceClaimStatus{
175-
Allocation: &v1alpha3.AllocationResult{
176-
Devices: v1alpha3.DeviceAllocationResult{
177-
Results: []v1alpha3.DeviceRequestAllocationResult{
174+
rcEnabled.Status = v1beta1.ResourceClaimStatus{
175+
Allocation: &v1beta1.AllocationResult{
176+
Devices: v1beta1.DeviceAllocationResult{
177+
Results: []v1beta1.DeviceRequestAllocationResult{
178178
{
179179
Request: "bar",
180180
Driver: "bar",
@@ -184,15 +184,15 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
184184
},
185185
},
186186
},
187-
Devices: []v1alpha3.AllocatedDeviceStatus{
187+
Devices: []v1beta1.AllocatedDeviceStatus{
188188
{
189189
Driver: "bar",
190190
Pool: "bar",
191191
Device: "bar",
192192
Data: runtime.RawExtension{
193193
Raw: []byte(`{"kind": "foo", "apiVersion": "dra.example.com/v1"}`),
194194
},
195-
NetworkData: &v1alpha3.NetworkDeviceData{
195+
NetworkData: &v1beta1.NetworkDeviceData{
196196
InterfaceName: "net-1",
197197
IPs: []string{
198198
"10.9.8.0/24",
@@ -203,12 +203,12 @@ func TestEnableDisableDRAResourceClaimDeviceStatus(t *testing.T) {
203203
},
204204
},
205205
}
206-
if _, err := client2.ResourceV1alpha3().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err != nil {
206+
if _, err := client2.ResourceV1beta1().ResourceClaims(ns.Name).UpdateStatus(context.TODO(), rcEnabled, metav1.UpdateOptions{}); err != nil {
207207
t.Fatal(err)
208208
}
209209

210210
// Tests the field is enabled.
211-
rcEnabled, err = client2.ResourceV1alpha3().ResourceClaims(ns.Name).Get(context.TODO(), rcEnabledName, metav1.GetOptions{})
211+
rcEnabled, err = client2.ResourceV1beta1().ResourceClaims(ns.Name).Get(context.TODO(), rcEnabledName, metav1.GetOptions{})
212212
if err != nil {
213213
t.Fatal(err)
214214
}

0 commit comments

Comments
 (0)