Skip to content

Commit f0cf0da

Browse files
committed
initial TODOs for CNS
1 parent 09f7f72 commit f0cf0da

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

cns/kubecontroller/nodenetworkconfig/reconciler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
124124
ipAssignments += len(req.SecondaryIPConfigs)
125125
}
126126

127+
// TODO: Here we can assign a IPFamilies along with the allocated IPs
127128
// record assigned IPs metric
128129
allocatedIPs.Set(float64(ipAssignments))
129130

cns/middlewares/k8sSwiftV2.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var _ cns.IPConfigsHandlerMiddleware = (*K8sSWIFTv2Middleware)(nil)
3838

3939
// IPConfigsRequestHandlerWrapper is the middleware function for handling SWIFT v2 IP configs requests for AKS-SWIFT. This function wrapped the default SWIFT request
4040
// and release IP configs handlers.
41+
// this will need to change to also work for a delegated NIC with multiple IPs
4142
func (k *K8sSWIFTv2Middleware) IPConfigsRequestHandlerWrapper(defaultHandler, failureHandler cns.IPConfigsHandlerFunc) cns.IPConfigsHandlerFunc {
4243
return func(ctx context.Context, req cns.IPConfigsRequest) (*cns.IPConfigsResponse, error) {
4344
podInfo, respCode, message := k.validateIPConfigsRequest(ctx, &req)
@@ -52,9 +53,11 @@ func (k *K8sSWIFTv2Middleware) IPConfigsRequestHandlerWrapper(defaultHandler, fa
5253
}
5354
ipConfigsResp, err := defaultHandler(ctx, req)
5455
// If the pod is not v2, return the response from the handler
56+
// we need to add the secondary Interface. Our current POC cluster is returning here
5557
if !req.SecondaryInterfacesExist {
5658
return ipConfigsResp, err
5759
}
60+
// TODO: the pod itself won't be "V2" as we aren't using multitenancy pods
5861
// If the pod is v2, get the infra IP configs from the handler first and then add the SWIFTv2 IP config
5962
defer func() {
6063
// Release the default IP config if there is an error
@@ -100,6 +103,8 @@ func (k *K8sSWIFTv2Middleware) IPConfigsRequestHandlerWrapper(defaultHandler, fa
100103
}
101104
}
102105

106+
// TODO: we will not be using multitenant pods. Need to look into what labels we are currently seeing and maybe compare to Vanilla swiftv2
107+
// For our purposes we would skip over this logic or need to replace it with something to check the delegated NIC
103108
// validateIPConfigsRequest validates if pod is multitenant by checking the pod labels, used in SWIFT V2 AKS scenario.
104109
// nolint
105110
func (k *K8sSWIFTv2Middleware) validateIPConfigsRequest(ctx context.Context, req *cns.IPConfigsRequest) (podInfo cns.PodInfo, respCode types.ResponseCode, message string) {

cns/restserver/ipam.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ func (service *HTTPRestService) RequestIPConfigsHandler(w http.ResponseWriter, r
280280
}
281281
var ipConfigsResp *cns.IPConfigsResponse
282282

283+
// TODO: Decide what middleware option we need to singetenancy swift v2
283284
// Check if IPConfigsHandlerMiddleware is set
284285
if service.IPConfigsHandlerMiddleware != nil {
285286
// Wrap the default datapath handlers with the middleware depending on middleware type
@@ -979,8 +980,11 @@ func (service *HTTPRestService) AssignDesiredIPConfigs(podInfo cns.PodInfo, desi
979980
// In the case of dualstack we would expect to have one IPv6 from one NC and one IPv4 from a second NC
980981
func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([]cns.PodIpInfo, error) {
981982
// Gets the number of NCs which will determine the number of IPs given to a pod
983+
// TODO: If we go with the One NC route then this logic would have to be updated
984+
// Instead of using numOfNCs we would have a variable added to the HTTPRestService struct that determines IPFamilies and use the length of that
982985
numOfNCs := len(service.state.ContainerStatus)
983986
// if there are no NCs on the NNC there will be no IPs in the pool so return error
987+
// We could still keep this check
984988
if numOfNCs == 0 {
985989
return nil, ErrNoNCs
986990
}
@@ -994,6 +998,7 @@ func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([
994998
// Searches for available IPs in the pool
995999
for _, ipState := range service.PodIPConfigState {
9961000
// check if an IP from this NC is already set side for assignment.
1001+
// TODO: Instead of using ncAlreadyMarkedForAssignment it would be IPFamilyAlreadyMarkedForAssignment
9971002
if _, ncAlreadyMarkedForAssignment := ipsToAssign[ipState.NCID]; ncAlreadyMarkedForAssignment {
9981003
continue
9991004
}

cns/restserver/ipusage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"github.com/Azure/azure-container-networking/cns/types"
66
)
77

8+
// TODO: add an IPFamily type with values ipv4 and ipv6
9+
//
10+
// This should be similar to DNC's IPFamilies and will only be ipv4 only or ipv4,ipv6
811
type ipState struct {
912
// allocatedIPs are all the IPs given to CNS by DNC.
1013
allocatedIPs int64
@@ -16,6 +19,7 @@ type ipState struct {
1619
programmingIPs int64
1720
// releasingIPs are the IPs in state "PendingReleasr".
1821
releasingIPs int64
22+
// TODO: add and IPFamilies value to be a slice of IPFamily type
1923
}
2024

2125
func (service *HTTPRestService) buildIPState() *ipState {

cns/restserver/restserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type imdsClient interface {
5353
}
5454

5555
// HTTPRestService represents http listener for CNS - Container Networking Service.
56+
// TODO: Add a new value for IPFamily
57+
// If we add a new type of Middleware that will be reflected in the IPConfigsHandlerMiddleware value
5658
type HTTPRestService struct {
5759
*cns.Service
5860
dockerClient *dockerclient.Client

cns/service/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
14001400

14011401
// Start building the NNC Reconciler
14021402

1403+
// TODO: We need to return the IPFamilies from the reconciler so that they can be added to the Service struct
14031404
// get CNS Node IP to compare NC Node IP with this Node IP to ensure NCs were created for this node
14041405
nodeIP := configuration.NodeIP()
14051406
nncReconciler := nncctrl.NewReconciler(httpRestServiceImplementation, poolMonitor, nodeIP)
@@ -1430,6 +1431,7 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
14301431
}
14311432
}
14321433

1434+
// TODO: If we need special middleware this is where we would be setting it
14331435
if cnsconfig.EnableSwiftV2 {
14341436
if err := mtpncctrl.SetupWithManager(manager); err != nil {
14351437
return errors.Wrapf(err, "failed to setup mtpnc reconciler with manager")

0 commit comments

Comments
 (0)