-
Notifications
You must be signed in to change notification settings - Fork 260
CNS IPAM for CNI #584
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
CNS IPAM for CNI #584
Conversation
Codecov Report
@@ Coverage Diff @@
## master #584 +/- ##
==========================================
- Coverage 39.88% 37.30% -2.58%
==========================================
Files 42 47 +5
Lines 4586 5203 +617
==========================================
+ Hits 1829 1941 +112
- Misses 2502 3000 +498
- Partials 255 262 +7 |
260fc97 to
5c56f56
Compare
tamilmani1989
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments. One concern is that changed introduced in getnetworkcontainerrequest struct should not regress multitenancy scenario.
|
|
||
| // If IPConfig is already allocated for pod, it returns that else it returns one of the available ipconfigs. | ||
| func requestIPConfigHelper(service *HTTPRestService, req cns.GetNetworkContainerRequest) (*cns.ContainerIPConfigState, error) { | ||
| func requestIPConfigHelper(service *HTTPRestService, req cns.GetIPConfigRequest) (*cns.ContainerIPConfigState, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this method, we check for an existing ipConfig, when would there already exist an ipConfig for the particular pod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the pod dies and is restarted, or if the node reboots and all pods are restarted
| // If IPConfig is already allocated for pod, it returns that else it returns one of the available ipconfigs. | ||
| func requestIPConfigHelper(service *HTTPRestService, req cns.GetNetworkContainerRequest) (*cns.ContainerIPConfigState, error) { | ||
| func requestIPConfigHelper(service *HTTPRestService, req cns.GetIPConfigRequest) (*cns.ContainerIPConfigState, error) { | ||
| var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on in this method, it checks that the ipconfig already exists for the pod, and returns the ipstate if err!= nil || isExist. Wouldn't we want to return the ipstate if err == nil && isExist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, inside the implementation of "GetExistingIPConfig", the "err" var goes unused basically, the only time it is used is to return nil, so maybe switch that last return to return nil like you did inside the if statement and get rid of the err var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing in "GetExistingIPConfig", the returned error message is "Pod->IPIP exists..." but I think you meant "Pod->IPID exists..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on in this method, it checks that the ipconfig already exists for the pod, and returns the ipstate if err!= nil || isExist. Wouldn't we want to return the ipstate if err == nil && isExist?
good catch, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, inside the implementation of "GetExistingIPConfig", the "err" var goes unused basically, the only time it is used is to return nil, so maybe switch that last return to return nil like you did inside the if statement and get rid of the err var.
true, reused skeleton, fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing in "GetExistingIPConfig", the returned error message is "Pod->IPIP exists..." but I think you meant "Pod->IPID exists..."
Updated the comment
tamilmani1989
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of nits..rest lgtm
cni/network/network.go
Outdated
| plugin.report.ContainerName = k8sPodName + ":" + k8sNamespace | ||
|
|
||
| if nwCfg.MultiTenancy { | ||
| if nwCfg.MultiTenancy || nwCfg.Ipam.Type == azureCNSIPAM { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should refactor CNI to implement interfaces and and have specific implementation according to the scenario. Not required to do in this change only, but we should take care of as it will get difficult to parse the code with more scenarios coming in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes CNI work is being done in a separate PR to do just that
cni/network/network.go
Outdated
| return plugin.Errorf(err.Error()) | ||
| } | ||
|
|
||
| result, resultV6, err = cnsClient.RequestIPAddress(orchestratorContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt this be part of plugin.IpamAdd call?
cns/restserver/ipam.go
Outdated
| if ipState, isExist = service.PodIPConfigState[ipID]; isExist { | ||
| return ipState, isExist, nil | ||
| } | ||
| return ipState, isExist, fmt.Errorf("Pod->IPIP exists but IPID to IPConfig doesn't exist") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means our CNS state is corrupted right? We should log this error into kusto and raise alert to see if we ever reach this state. Can be handled in a separate PR though
tamilmani1989
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
What this PR does / why we need it:
Adds two new API's in CNS which will enable it to act as an IPAM.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note: