Skip to content

Commit ac6cb6a

Browse files
authored
CNS API contracts for NUMA-Aware Pods (#3825)
* CNS API contracts for NUMA-Aware Pods * Addressing feedback * only checking in the bare minimum to give structure to the APIs * hardware addr * remove unnecessary request body * Reference MTPNC Infiniband status * Update swagger and comment in api.go * changing ibmacs to request body * ibmacaddresses
1 parent 852163d commit ac6cb6a

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

cns/api.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import (
77
"context"
88
"encoding/json"
99
"fmt"
10+
"net"
1011
"time"
1112

1213
"github.com/Azure/azure-container-networking/cns/common"
1314
"github.com/Azure/azure-container-networking/cns/types"
15+
"github.com/Azure/azure-container-networking/crd/multitenancy/api/v1alpha1"
1416
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
1517
"github.com/pkg/errors"
1618
)
@@ -32,6 +34,7 @@ const (
3234
V1Prefix = "/v0.1"
3335
V2Prefix = "/v0.2"
3436
EndpointPath = "/network/endpoints/"
37+
IBDevicesPath = "/ibdevices"
3538
// Service Fabric SWIFTV2 mode
3639
StandaloneSWIFTV2 SWIFTV2Mode = "StandaloneSWIFTV2"
3740
// K8s SWIFTV2 mode
@@ -382,3 +385,26 @@ type GetVMUniqueIDResponse struct {
382385
Response Response `json:"response"`
383386
VMUniqueID string `json:"vmuniqueid"`
384387
}
388+
389+
// AssignIBDevicesToPodRequest represents the request for assigning InfiniBand devices to a pod
390+
type AssignIBDevicesToPodRequest struct {
391+
IBMACAddresses []net.HardwareAddr `json:"ibmacaddresses"` // List of IB device MAC addresses to assign
392+
PodNamespace string `json:"podNamespace"` // Namespace of the target pod
393+
PodName string `json:"podName"` // Name of the target pod
394+
}
395+
396+
// AssignIBDevicesToPodRequest
397+
398+
// AssignIBDevicesToPodResponse represents the response for assigning InfiniBand devices to a pod
399+
type AssignIBDevicesToPodResponse struct {
400+
Message string `json:"message"` // Additional message or error description
401+
}
402+
403+
// GetIBDeviceStatusResponse represents the response containing InfiniBand device programming status
404+
type GetIBDeviceStatusResponse struct {
405+
IBMACAddress net.HardwareAddr `json:"ibmacaddress"` // IB device MAC address
406+
PodNamespace string `json:"podNamespace"` // Namespace of pod to which the device is assigned, if any
407+
PodName string `json:"podName"` // Name of pod to which the device is assigned, if any
408+
Status v1alpha1.InfinibandStatus `json:"status"` // Device status (e.g., "Unprogrammed", "Programming", "Programmed" etc.)"
409+
Message string `json:"message"` // Additional message or error description
410+
}

cns/swagger.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,67 @@ paths:
120120
schema:
121121
$ref: "#/components/schemas/UnpublishNetworkContainerResponse"
122122

123+
/ibdevices:
124+
post:
125+
summary: Assign IB devices to a pod
126+
description: >
127+
Assigns one or more Infiniband devices by MAC address to a given pod.
128+
requestBody:
129+
required: true
130+
content:
131+
application/json:
132+
schema:
133+
$ref: "#/components/schemas/AssignIBDevicesToPodRequest"
134+
responses:
135+
'200':
136+
description: >-
137+
The request passed initial validation and CNS was able to propagate its state.
138+
content:
139+
application/json:
140+
schema:
141+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
142+
'404':
143+
description: >-
144+
The pod specified by PodID was not found.
145+
content:
146+
application/json:
147+
schema:
148+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
149+
'400':
150+
description: >-
151+
One of the IB devices specified is not available.
152+
content:
153+
application/json:
154+
schema:
155+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
156+
get:
157+
summary: Get status of an IB device
158+
description: >-
159+
Retrieves the current programming status of the specified IB device.
160+
parameters:
161+
- name: ibmac
162+
in: query
163+
required: true
164+
description: The MAC address of the IB device.
165+
schema:
166+
type: string
167+
example: "60:45:bd:a4:b5:7a"
168+
responses:
169+
'200':
170+
description: >-
171+
The request was successful and the status of the IB device is returned.
172+
content:
173+
application/json:
174+
schema:
175+
$ref: "#/components/schemas/GetIBDeviceStatusResponse"
176+
'404':
177+
description: >-
178+
The IB device specified by MAC address was not found.
179+
content:
180+
application/json:
181+
schema:
182+
$ref: "#/components/schemas/GetIBDeviceStatusResponse"
183+
123184
components:
124185
schemas:
125186
UnpublishNetworkContainerResponse:
@@ -351,3 +412,65 @@ components:
351412
Message:
352413
type: string
353414
description: The error message
415+
416+
AssignIBDevicesToPodRequest:
417+
type: object
418+
required:
419+
- ibmacaddresses
420+
- podNamespace
421+
- podName
422+
properties:
423+
ibmacaddresses:
424+
type: array
425+
items:
426+
type: string
427+
description: List of IB device MAC addresses to assign such as "60:45:bd:a4:b5:7a"
428+
podNamespace:
429+
type: string
430+
description: Namespace of the target pod
431+
podName:
432+
type: string
433+
description: Name of the target pod
434+
435+
AssignIBDevicesToPodResponse:
436+
type: object
437+
required:
438+
- Message
439+
properties:
440+
Message:
441+
type: string
442+
description: Human-readable message or error description
443+
444+
GetIBDeviceStatusResponse:
445+
type: object
446+
required:
447+
- IBMACAddress
448+
- PodNamespace
449+
- PodName
450+
- Status
451+
- Message
452+
properties:
453+
IBMACAddress:
454+
type: string
455+
description: MAC address of the IB device
456+
PodNamespace:
457+
type: string
458+
description: namespace of the pod to which the device is assigned, if any
459+
PodName:
460+
type: string
461+
description: name of the pod to which the device is assigned, if any
462+
Status:
463+
$ref: "#/components/schemas/Status"
464+
Message:
465+
type: string
466+
description: Human-readable message or error description
467+
468+
Status:
469+
type: string
470+
description: Status of IB device
471+
enum:
472+
- Unprogrammed
473+
- Programming
474+
- Programmed
475+
- Unprogramming
476+
- Failed

0 commit comments

Comments
 (0)