-
Notifications
You must be signed in to change notification settings - Fork 260
feat: CNS manages endpoints state for delegate IPAM use case #1500
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
Conversation
cns/restserver/ipam.go
Outdated
| defer service.Unlock() | ||
| logger.Printf("[updateEndpointState] Updating endpoint state for infra container %s", ipconfigRequest.InfraContainerID) | ||
| if endpointInfo, ok := service.EndpointState[ipconfigRequest.InfraContainerID]; ok { | ||
| logger.Printf("[updateEndpointState] Found existing endpoint state for infra container %s", ipconfigRequest.InfraContainerID) |
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.
when do we get this case? if code hits here, isnt something wrong?
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.
I don't have a case in mind, but it is generally better to check for duplicates in a map?
| type EndpointInfo struct { | ||
| PodName string | ||
| PodNamespace string | ||
| IfnameToIPMap map[string]*IPInfo // key : interface name, value : IPInfo |
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.
again why pointer? i guess only value will be saved here. is there any difference here if we have this as just "IPInfo"? @rbtr
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.
yeah, I only used pointer because I don't know how big the struct would grow to be. If the struct consistently stays relatively small, then I guess we don't have to use pointers.
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.
actually, we need pointers for IPInfo during IPconfig request and release, as we don't want to create a new copy of the arrays within IPInfo, update with new entries, and then reassign it every time.
| sync.RWMutex | ||
| dncPartitionKey string | ||
| dncPartitionKey string | ||
| EndpointState map[string]*EndpointInfo // key : container id |
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.
same as below. does it need to be pointer?
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.
maybe we don't need a pointer for this case?
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This is the draft PR for the endpoint state management functionality for CNS for when delegated IPAM is used
TODO: Handling state for release IP config request ✅