Skip to content

Commit e6660c8

Browse files
committed
CNS API contracts for NUMA-Aware Pods
1 parent 7d56d36 commit e6660c8

File tree

11 files changed

+1745
-167
lines changed

11 files changed

+1745
-167
lines changed

cns/api.go

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

1212
"github.com/Azure/azure-container-networking/cns/common"
13+
"github.com/Azure/azure-container-networking/cns/infiniband"
1314
"github.com/Azure/azure-container-networking/cns/types"
1415
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
1516
"github.com/pkg/errors"
@@ -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 types.ResponseCode `json:"errorCode"` // Error code if applicable
402+
Msg string `json:"msg"` // 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 types.ResponseCode `json:"errorCode"` // Error code if applicable
417+
Msg string `json:"msg"` // Additional message or error description
418+
}

cns/grpc/cns.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,33 @@ func (s *CNS) GetNodeInfo(_ context.Context, req *pb.NodeInfoRequest) (*pb.NodeI
2626
// todo: Implement the logic
2727
return &pb.NodeInfoResponse{}, nil
2828
}
29+
30+
// AssignIBDevicesToPod assigns InfiniBand devices to a pod via gRPC.
31+
func (s *CNS) AssignIBDevicesToPod(_ context.Context, req *pb.AssignIBDevicesToPodRequest) (*pb.AssignIBDevicesToPodResponse, error) {
32+
s.Logger.Info("AssignIBDevicesToPod called",
33+
zap.String("podID", req.GetPodID()),
34+
zap.Strings("deviceIDs", req.GetDeviceIds()))
35+
36+
// TODO: Implement the actual logic by calling the IBDeviceManager
37+
// For now, return a success response
38+
return &pb.AssignIBDevicesToPodResponse{
39+
ErrorCode: 0,
40+
Message: "InfiniBand devices assigned successfully",
41+
}, nil
42+
}
43+
44+
// GetIBDeviceInfo retrieves information about a specific InfiniBand device via gRPC.
45+
func (s *CNS) GetIBDeviceInfo(_ context.Context, req *pb.GetIBDeviceInfoRequest) (*pb.GetIBDeviceInfoResponse, error) {
46+
s.Logger.Info("GetIBDeviceInfo called",
47+
zap.String("deviceID", req.GetDeviceID()))
48+
49+
// TODO: Implement the actual logic by calling the IBDeviceManager
50+
// For now, return a placeholder response
51+
return &pb.GetIBDeviceInfoResponse{
52+
DeviceID: req.GetDeviceID(),
53+
PodID: "",
54+
Status: "Available",
55+
ErrorCode: 0,
56+
Msg: "Device information retrieved successfully",
57+
}, nil
58+
}

cns/grpc/proto/server.proto

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ service CNS {
1515
// Retrieves detailed information about a specific node.
1616
// Primarily used for health checks.
1717
rpc GetNodeInfo(NodeInfoRequest) returns (NodeInfoResponse);
18+
19+
// Assigns InfiniBand devices to a pod.
20+
rpc AssignIBDevicesToPod(AssignIBDevicesToPodRequest) returns (AssignIBDevicesToPodResponse);
21+
22+
// Retrieves information about a specific InfiniBand device.
23+
rpc GetIBDeviceInfo(GetIBDeviceInfoRequest) returns (GetIBDeviceInfoResponse);
1824
}
1925

2026
// SetOrchestratorInfoRequest is the request message for setting the orchestrator information.
@@ -41,3 +47,29 @@ message NodeInfoResponse {
4147
string status = 5; // The current status of the node (e.g., running, stopped).
4248
string message = 6; // Additional information about the node's health or status.
4349
}
50+
51+
// AssignIBDevicesToPodRequest is the request message for assigning InfiniBand devices to a pod.
52+
message AssignIBDevicesToPodRequest {
53+
string podID = 1; // The pod ID in format podname-podnamespace.
54+
repeated string deviceIds = 2; // List of device MAC addresses.
55+
}
56+
57+
// AssignIBDevicesToPodResponse is the response message for assigning InfiniBand devices to a pod.
58+
message AssignIBDevicesToPodResponse {
59+
int32 errorCode = 1; // Error code (0 for success).
60+
string message = 2; // Response message.
61+
}
62+
63+
// GetIBDeviceInfoRequest is the request message for retrieving InfiniBand device information.
64+
message GetIBDeviceInfoRequest {
65+
string deviceID = 1; // The device ID (MAC address).
66+
}
67+
68+
// GetIBDeviceInfoResponse is the response message containing InfiniBand device information.
69+
message GetIBDeviceInfoResponse {
70+
string deviceID = 1; // The device ID (MAC address).
71+
string podID = 2; // The pod ID that the device is assigned to.
72+
string status = 3; // The status of the device.
73+
int32 errorCode = 4; // Error code if applicable.
74+
string msg = 5; // Additional message or error description.
75+
}

0 commit comments

Comments
 (0)