Skip to content

Commit 37cf8f4

Browse files
committed
CNS API contracts for NUMA-Aware Pods
1 parent ef97f2a commit 37cf8f4

File tree

4 files changed

+226
-0
lines changed

4 files changed

+226
-0
lines changed

cns/api.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/Azure/azure-container-networking/cns/common"
1313
"github.com/Azure/azure-container-networking/cns/types"
14+
"github.com/Azure/azure-container-networking/cns/types/infiniband"
1415
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
1516
"github.com/pkg/errors"
1617
)
@@ -32,6 +33,9 @@ const (
3233
V1Prefix = "/v0.1"
3334
V2Prefix = "/v0.2"
3435
EndpointPath = "/network/endpoints/"
36+
// IBDevice API paths
37+
IBDevicesPodPath = "/ibdevices/pod/" // PUT /ibdevices/pod/{podname-podnamespace}
38+
IBDevicesPath = "/ibdevices/" // GET /ibdevices/{mac-address-of-device}
3539
// Service Fabric SWIFTV2 mode
3640
StandaloneSWIFTV2 SWIFTV2Mode = "StandaloneSWIFTV2"
3741
// K8s SWIFTV2 mode
@@ -382,3 +386,33 @@ type GetVMUniqueIDResponse struct {
382386
Response Response `json:"response"`
383387
VMUniqueID string `json:"vmuniqueid"`
384388
}
389+
390+
// IBDevice API Contracts
391+
392+
// AssignIBDevicesToPodRequest represents the request to assign InfiniBand devices to a pod
393+
// PUT /ibdevices/pod/{podname-podnamespace}
394+
type AssignIBDevicesToPodRequest struct {
395+
PodID string `json:"podID"` // podname-podnamespace format
396+
MACAddresses []string `json:"macAddresses"` // Array of MAC addresses like ["60:45:bd:a4:b5:7a", "7c:1e:52:07:11:36"]
397+
}
398+
399+
// AssignIBDevicesToPodResponse represents the response for assigning InfiniBand devices to a pod
400+
type AssignIBDevicesToPodResponse struct {
401+
ErrorCode infiniband.ErrorCode `json:"errorCode"` // Error code if applicable
402+
Message string `json:"message"` // Additional message or error description
403+
}
404+
405+
// GetIBDeviceStatusRequest represents the request to get the InfiniBand device programming status
406+
// GET /ibdevices/{mac-address-of-device} - no request body needed for GET
407+
type GetIBDeviceStatusRequest struct {
408+
MACAddress string `json:"macAddress"` // MAC address of the device (from URL path)
409+
}
410+
411+
// GetIBDeviceStatusResponse represents the response containing InfiniBand device programming status
412+
type GetIBDeviceStatusResponse struct {
413+
MACAddress string `json:"macAddress"` // MAC address of the device
414+
PodID string `json:"podID"` // Pod that the device is assigned to
415+
Status infiniband.Status `json:"status"` // Device status (e.g., "pendingProgramming", "error", "programmed", "pendingDeletion", "available")
416+
ErrorCode infiniband.ErrorCode `json:"errorCode"` // Error code if applicable
417+
Message string `json:"message"` // Additional message or error description
418+
}

cns/swagger.yaml

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

123+
/ibdevices/pod/{podname-podnamespace}:
124+
put:
125+
summary: Assigns IB devices to a pod
126+
description: >-
127+
Assigns the specified IB devices to the pod identified by PodID. The
128+
MAC addresses of the devices are provided in the request body.
129+
parameters:
130+
- name: podname-podnamespace
131+
in: path
132+
required: true
133+
description: The name and namespace of the pod
134+
schema:
135+
type: string
136+
requestBody:
137+
required: true
138+
content:
139+
application/json:
140+
schema:
141+
$ref: "#/components/schemas/AssignIBDevicesToPodRequest"
142+
responses:
143+
'200':
144+
description: >-
145+
The request passed initial validation and CNS was able to propagate its state.
146+
content:
147+
application/json:
148+
schema:
149+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
150+
'404':
151+
description: >-
152+
The pod specified by PodID was not found
153+
content:
154+
application/json:
155+
schema:
156+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
157+
'400':
158+
description: >-
159+
One of the IB devices specified is not available
160+
content:
161+
application/json:
162+
schema:
163+
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
164+
165+
/ibdevices/{macaddress}:
166+
get:
167+
summary: Get status about an IB device
168+
description: >-
169+
Retrieves the current status of the specified IB device.
170+
parameters:
171+
- name: macaddress
172+
in: path
173+
required: true
174+
description: The MAC address of the IB device (with colons ":")
175+
schema:
176+
type: string
177+
requestBody:
178+
required: false
179+
responses:
180+
'200':
181+
description: >-
182+
The request was successful and the status of the IB device is returned.
183+
content:
184+
application/json:
185+
schema:
186+
$ref: "#/components/schemas/GetIBDeviceStatusResponse"
187+
'404':
188+
description: >-
189+
The IB device specified by MAC address was not found.
190+
content:
191+
application/json:
192+
schema:
193+
$ref: "#/components/schemas/GetIBDeviceStatusResponse"
194+
123195
components:
124196
schemas:
125197
UnpublishNetworkContainerResponse:
@@ -351,3 +423,99 @@ components:
351423
Message:
352424
type: string
353425
description: The error message
426+
427+
ErrorCode:
428+
type: integer
429+
description: Pre-defined error code of what went wrong, if anything (see cns/types/infiniband/errorcodes.go)
430+
oneOf:
431+
- title: Success
432+
const: 0
433+
description: Successful operation
434+
- title: PodNotFound
435+
const: 1
436+
description: Pod not found
437+
- title: DeviceUnavailable
438+
const: 2
439+
description: Device is unavailable
440+
- title: DeviceNotFound
441+
const: 3
442+
description: Device not found
443+
- title: AnnotationNotFound
444+
const: 4
445+
description: Annotation not found on pod
446+
- title: PodAlreadyAllocated
447+
const: 5
448+
description: Pod was already assigned IB devices (and new ones don't match)
449+
- title: InternalProgrammingError
450+
const: 6
451+
description: Something went wrong programming the devices
452+
453+
Status:
454+
type: integer
455+
description: Status of IB device (see cns/types/infiniband/status.go)
456+
oneOf:
457+
- title: ProgrammingPending
458+
const: 0
459+
description: Programming of device is pending
460+
- title: ProgrammingFailed
461+
const: 1
462+
description: Programming of device failed
463+
- title: ProgrammingComplete
464+
const: 2
465+
description: Programming of device is complete
466+
- title: ReleasePending
467+
const: 3
468+
description: Release of device is pending
469+
- title: Available
470+
const: 4
471+
description: Device is available for use
472+
473+
AssignIBDevicesToPodRequest:
474+
type: object
475+
required:
476+
- PodID
477+
- MACAddresses
478+
properties:
479+
PodID:
480+
type: string
481+
description: podname-podnamespace of which pod to attach these devices through
482+
MACAddresses:
483+
type: array
484+
description: MAC addresses of IB devices such as "60:45:bd:a4:b5:7a"
485+
items:
486+
type: string
487+
488+
AssignIBDevicesToPodResponse:
489+
type: object
490+
required:
491+
- ErrorCode
492+
- Message
493+
properties:
494+
ErrorCode:
495+
$ref: "#/components/schemas/ErrorCode"
496+
Message:
497+
type: string
498+
description: Human-readable message or error description
499+
500+
GetIBDeviceStatusResponse:
501+
type: object
502+
required:
503+
- MACAddress
504+
- PodID
505+
- Status
506+
- ErrorCode
507+
- Message
508+
properties:
509+
MACAddress:
510+
type: string
511+
description: MAC address of the IB device
512+
PodID:
513+
type: string
514+
description: podname-podnamespace of the pod to which the device is assigned, if any
515+
Status:
516+
$ref: "#/components/schemas/Status"
517+
ErrorCode:
518+
$ref: "#/components/schemas/ErrorCode"
519+
Message:
520+
type: string
521+
description: Human-readable message or error description

cns/types/infiniband/errorcodes.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package infiniband
2+
3+
type ErrorCode int
4+
5+
const (
6+
Success ErrorCode = 0
7+
PodNotFound ErrorCode = 1
8+
DeviceUnavailable ErrorCode = 2
9+
DeviceNotFound ErrorCode = 3
10+
AnnotationNotFound ErrorCode = 4
11+
PodAlreadyAllocated ErrorCode = 5
12+
InternalProgrammingError ErrorCode = 6
13+
)

cns/types/infiniband/status.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package infiniband
2+
3+
type Status int
4+
5+
const (
6+
ProgrammingPending Status = 0
7+
ProgrammingFailed Status = 1
8+
ProgrammingComplete Status = 2
9+
ReleasePending Status = 3
10+
Available Status = 4
11+
)

0 commit comments

Comments
 (0)