Skip to content

Commit

Permalink
add a new container type for l1vh singularity container request (#2215)
Browse files Browse the repository at this point in the history
* add a new container type for l1vh singularity container request

* feat: adding fields required for backendnetworkinterface NC Request

* fix: add nctype-case to outer switch statement

* feat: new struct to store nicInfo sent by DNC to CNS to support l1vh

* fix: nolint for 2 cases, remove backendnic-id from config

* fix: refactor networkInterfaceInfo

* feat:add NetworkInterfaceInfo details to getallNCResponse in cns, to be used by CNI ADD net-plugin
  • Loading branch information
kmurudi authored Oct 28, 2023
1 parent b65b051 commit dda7fe8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 14 additions & 3 deletions cns/NetworkContainerContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
Basic = "Basic"
JobObject = "JobObject"
COW = "COW" // Container on Windows
BackendNICNC = "BackendNICNC"
)

// Orchestrator Types
Expand All @@ -77,6 +78,8 @@ const (
InfraNIC NICType = "InfraNIC"
// Delegated VM NICs are projected from VM to container network namespace
DelegatedVMNIC NICType = "DelegatedVMNIC"
// BackendNIC NICs are used for infiniband nics on a VM
BackendNIC NICType = "BackendNIC"
)

// ChannelMode :- CNS channel modes
Expand Down Expand Up @@ -106,16 +109,18 @@ type CreateNetworkContainerRequest struct {
AllowNCToHostCommunication bool
EndpointPolicies []NetworkContainerRequestPolicies
NCStatus v1alpha.NCStatus
NetworkInterfaceInfo NetworkInterfaceInfo //nolint // introducing new field for backendnic, to be used later by cni code
}

// CreateNetworkContainerRequest implements fmt.Stringer for logging
func (req *CreateNetworkContainerRequest) String() string {
return fmt.Sprintf("CreateNetworkContainerRequest"+
"{Version: %s, NetworkContainerType: %s, NetworkContainerid: %s, PrimaryInterfaceIdentifier: %s, "+
"LocalIPConfiguration: %+v, IPConfiguration: %+v, SecondaryIPConfigs: %+v, MultitenancyInfo: %+v, "+
"AllowHostToNCCommunication: %t, AllowNCToHostCommunication: %t, NCStatus: %s}",
"AllowHostToNCCommunication: %t, AllowNCToHostCommunication: %t, NCStatus: %s, NetworkInterfaceInfo: %+v}",
req.Version, req.NetworkContainerType, req.NetworkContainerid, req.PrimaryInterfaceIdentifier, req.LocalIPConfiguration,
req.IPConfiguration, req.SecondaryIPConfigs, req.MultiTenancyInfo, req.AllowHostToNCCommunication, req.AllowNCToHostCommunication, string(req.NCStatus))
req.IPConfiguration, req.SecondaryIPConfigs, req.MultiTenancyInfo, req.AllowHostToNCCommunication, req.AllowNCToHostCommunication,
string(req.NCStatus), req.NetworkInterfaceInfo)
}

// NetworkContainerRequestPolicies - specifies policies associated with create network request
Expand Down Expand Up @@ -317,6 +322,11 @@ type MultiTenancyInfo struct {
ID int // This can be vlanid, vxlanid, gre-key etc. (depends on EnacapType).
}

type NetworkInterfaceInfo struct {
NICType NICType
MACAddress string
}

// IPConfiguration contains details about ip config to provision in the VM.
type IPConfiguration struct {
IPSubnet IPSubnet
Expand Down Expand Up @@ -409,13 +419,14 @@ type GetNetworkContainerResponse struct {
Response Response
AllowHostToNCCommunication bool
AllowNCToHostCommunication bool
NetworkInterfaceInfo NetworkInterfaceInfo
}

type PodIpInfo struct {
PodIPConfig IPSubnet
NetworkContainerPrimaryIPConfig IPConfiguration
HostPrimaryIPInfo HostIPInfo
// NICType defines whether NIC is InfraNIC or DelegatedVMNIC
// NICType defines whether NIC is InfraNIC or DelegatedVMNIC or BackendNIC
NICType NICType
InterfaceName string
// MacAddress of interface
Expand Down
5 changes: 3 additions & 2 deletions cns/restserver/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(
fallthrough
case cns.JobObject:
fallthrough
case cns.COW:
case cns.COW, cns.BackendNICNC:
fallthrough
case cns.WebApps:
switch service.state.OrchestratorType {
Expand All @@ -177,7 +177,7 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(
fallthrough
case cns.AzureFirstParty:
fallthrough
case cns.WebApps: // todo: Is WebApps an OrchastratorType or ContainerType?
case cns.WebApps, cns.BackendNICNC: // todo: Is WebApps an OrchastratorType or ContainerType?
podInfo, err := cns.UnmarshalPodInfo(req.OrchestratorContext)
if err != nil {
errBuf := fmt.Sprintf("Unmarshalling %s failed with error %v", req.NetworkContainerType, err)
Expand Down Expand Up @@ -501,6 +501,7 @@ func (service *HTTPRestService) getAllNetworkContainerResponses(
LocalIPConfiguration: savedReq.LocalIPConfiguration,
AllowHostToNCCommunication: savedReq.AllowHostToNCCommunication,
AllowNCToHostCommunication: savedReq.AllowNCToHostCommunication,
NetworkInterfaceInfo: savedReq.NetworkInterfaceInfo,
}

// If the NC version check wasn't skipped, take into account the VFP programming status when returning the response
Expand Down

0 comments on commit dda7fe8

Please sign in to comment.