Skip to content

Commit 82b11b0

Browse files
committed
CNS API contracts for NUMA-Aware Pods
1 parent f2d2be5 commit 82b11b0

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-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+
// GetIBDeviceInfoRequest represents the request to get InfiniBand device information
406+
// GET /ibdevices/{mac-address-of-device} - no request body needed for GET
407+
type GetIBDeviceInfoRequest struct {
408+
MACAddress string `json:"macAddress"` // MAC address of the device (from URL path)
409+
}
410+
411+
// GetIBDeviceInfoResponse represents the response containing InfiniBand device information
412+
type GetIBDeviceInfoResponse 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/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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package infiniband
2+
3+
type Status int
4+
5+
// IBStatus definitions
6+
const (
7+
ProgrammingPending Status = 0
8+
ProgrammingFailed Status = 1
9+
ProgrammingComplete Status = 2
10+
ReleasePending Status = 3
11+
Available Status = 4
12+
)

0 commit comments

Comments
 (0)