Skip to content

CNS API contracts for NUMA-Aware Pods #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cns/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"time"

"github.com/Azure/azure-container-networking/cns/common"
"github.com/Azure/azure-container-networking/cns/types"
"github.com/Azure/azure-container-networking/cns/types/infiniband"
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
"github.com/pkg/errors"
)
Expand All @@ -32,6 +34,7 @@ const (
V1Prefix = "/v0.1"
V2Prefix = "/v0.2"
EndpointPath = "/network/endpoints/"
IBDevicesPath = "/ibdevices"
// Service Fabric SWIFTV2 mode
StandaloneSWIFTV2 SWIFTV2Mode = "StandaloneSWIFTV2"
// K8s SWIFTV2 mode
Expand Down Expand Up @@ -382,3 +385,17 @@ type GetVMUniqueIDResponse struct {
Response Response `json:"response"`
VMUniqueID string `json:"vmuniqueid"`
}

// AssignIBDevicesToPodResponse represents the response for assigning InfiniBand devices to a pod
type AssignIBDevicesToPodResponse struct {
Message string `json:"message"` // Additional message or error description
}

// GetIBDeviceStatusResponse represents the response containing InfiniBand device programming status
type GetIBDeviceStatusResponse struct {
MACAddress net.HardwareAddr `json:"macAddress"` // MAC address of the device
PodNamespace string `json:"podNamespace"` // Namespace of pod to which the device is assigned, if any
PodName string `json:"podName"` // Name of pod to which the device is assigned, if any
Status infiniband.Status `json:"status"` // Device status (e.g., "Available", "ProgrammingPending", etc.)"
Message string `json:"message"` // Additional message or error description
}
134 changes: 134 additions & 0 deletions cns/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,87 @@ paths:
schema:
$ref: "#/components/schemas/UnpublishNetworkContainerResponse"

/ibdevices:assign:
post:
summary: Assign IB devices to a pod
description: >
Assigns one or more Infiniband devices by MAC address to a given pod.
parameters:
- name: ibmacs
in: query
required: true
description: Comma-separated list of IB device MAC addresses.
schema:
type: array
items:
type: string
example: ["60:45:bd:a4:b5:7a", "7c:1e:52:07:11:36"]
- name: podnamespace
in: query
required: true
description: The namespace of the target pod.
schema:
type: string
example: "podnamespace"
- name: podname
in: query
required: true
description: The name of the target pod.
schema:
type: string
example: "podname"
responses:
'200':
description: >-
The request passed initial validation and CNS was able to propagate its state.
content:
application/json:
schema:
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
'404':
description: >-
The pod specified by PodID was not found.
content:
application/json:
schema:
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
'400':
description: >-
One of the IB devices specified is not available.
content:
application/json:
schema:
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"

/ibdevices:
get:
summary: Get status of an IB device
description: >-
Retrieves the current programming status of the specified IB device.
parameters:
- name: ibmac
in: query
required: true
description: The MAC address of the IB device.
schema:
type: string
example: "60:45:bd:a4:b5:7a"
responses:
'200':
description: >-
The request was successful and the status of the IB device is returned.
content:
application/json:
schema:
$ref: "#/components/schemas/GetIBDeviceStatusResponse"
'404':
description: >-
The IB device specified by MAC address was not found.
content:
application/json:
schema:
$ref: "#/components/schemas/GetIBDeviceStatusResponse"

components:
schemas:
UnpublishNetworkContainerResponse:
Expand Down Expand Up @@ -351,3 +432,56 @@ components:
Message:
type: string
description: The error message

AssignIBDevicesToPodResponse:
type: object
required:
- Message
properties:
Message:
type: string
description: Human-readable message or error description

GetIBDeviceStatusResponse:
type: object
required:
- MACAddress
- PodNamespace
- PodName
- Status
- Message
properties:
MACAddress:
type: string
description: MAC address of the IB device
PodNamespace:
type: string
description: namespace of the pod to which the device is assigned, if any
PodName:
type: string
description: name of the pod to which the device is assigned, if any
Status:
$ref: "#/components/schemas/Status"
Message:
type: string
description: Human-readable message or error description

Status:
type: integer
description: Status of IB device (see cns/types/infiniband/status.go)
oneOf:
- title: Available
const: 0
description: Device is available for use
- title: ProgrammingPending
const: 1
description: Programming of device is pending
- title: ProgrammingFailed
const: 2
description: Programming of device failed
- title: ProgrammingComplete
const: 3
description: Programming of device is complete
- title: ReleasePending
const: 4
description: Release of device is pending
11 changes: 11 additions & 0 deletions cns/types/infiniband/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package infiniband

type Status int

const (
Available Status = 0
ProgrammingPending Status = 1
ProgrammingFailed Status = 2
ProgrammingComplete Status = 3
ReleasePending Status = 4
)
Loading