-
Notifications
You must be signed in to change notification settings - Fork 240
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
fix: dualnic options to avoid overwritting vlanMaps #2928
Conversation
7d8511d
to
65d80a1
Compare
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
b63c064
to
38c0b33
Compare
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Is it possible to add the vlan id to ep info pretty print (endpoint.go) or similar pretty string (should not panic/err if no vlan id is present/map is nil)?
we have already printed vlanID when setting options (key and value) |
At EndpointCreate, after we generate all epInfos, we print each endpointInfo. If the pretty string function printed the options map (similar to how we print the data map) this would catch the vlan id issue. The log statement in the setting options function would not catch this because it only prints the value for the current iteration and does not print out the previous values of epInfo vlan id to confirm that it has not been improperly modified. |
7f9d6d9
to
841cf46
Compare
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.
Ensure tested with partner teams if you haven't done so already
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
70805e3
to
b584723
Compare
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
ddc172b
to
1edf180
Compare
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
Reason for Change:
This PR is to fix dualnic options to avoid overwritting vlanMaps
In the windows dualnic multitenancy case, we receive two interface infos from cns and should create two corresponding networks and endpoints. The first and second endpoints created by hns should have vlan id 1 and vlan id 2, respectively. It is CNI's job to parse the cns input and send a request to hns to create the endpoints.
However, during testing both endpoints have vlan id 2. This is because the ipamAddConfig's
options
field is unintentionally shared between eachEndpointInfo
struct. Modifying the vlan id of one options field in an endpoint info struct inadvertently modifies every other endpoint info struct's options. So, the vlan id reflected during endpoint creation is of the last endpoint info's vlan id only, as all endpoint info option fields point to the same underlying object in memory.The proposed solution is to, for each endpoint info we create, we shallow copy the
ipamAddConfig
's options field. So, every endpoint info gets its own copy of the options field which it can modify and store without modifying the other endpoint infos.If the options field of type map[string]interface{} ever holds anything other than primitives before we perform the shallow copy (ex: if we store pointers to another object as a value in the map) the copied pointer will still be pointing to the same object and we will have the same issue, but as of now we have only identified a single instance where we write to the options field in
invoker_cns.go
(ncPrimaryIP
) where the value is of type string, which is immutable.Issue Fixed:
Requirements:
Notes:
To be tested by partner team(s) before being merged.