-
Notifications
You must be signed in to change notification settings - Fork 14
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
controller: use slice instead of map to conserve consistent order #1052
controller: use slice instead of map to conserve consistent order #1052
Conversation
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.
the general direction is fine, thanks for the fix!
some improvements and followups as inline comments.
func syncNodeGroupsStatus(instance *nropv1.NUMAResourcesOperator, dsPerMCP []MCPDaemonSetPair) []nropv1.NodeGroupStatus { | ||
ngStatuses := []nropv1.NodeGroupStatus{} | ||
for _, mcp := range instance.Status.MachineConfigPools { | ||
status := nropv1.NodeGroupStatus{ | ||
PoolName: mcp.Name, | ||
Config: *mcp.Config, | ||
DaemonSet: dsPerMCP[mcp.Name], | ||
for _, info := range dsPerMCP { | ||
if mcp.Name != info.MCPName { | ||
continue | ||
} | ||
|
||
status := nropv1.NodeGroupStatus{ | ||
PoolName: mcp.Name, | ||
Config: *mcp.Config, | ||
DaemonSet: info.Daemonset, | ||
} | ||
ngStatuses = append(ngStatuses, status) |
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.
thanks for the fix. We can use another fix later: this function should create the NodeGroupStatus
using dsPerMCP
as master source (iterating over there) and not depend on other status fields like instance.Status.MachineConfigPools
.
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 need to be aligned with the status update on MCP, currently the config won't be updated there if MCP is not completely ready. I'll look into this anyhow, we can use an improvement here indeed
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.
fine, material for another PR anyway.
4e62f4d
to
83e0ba7
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.
/approve
/lgtm
/hold |
83e0ba7
to
181a8f6
Compare
Using map to store the daemonset of the targeted MCPs turned out to be a not the best data structure especially when we would like to conserve a consistent order of the elements that aligns with the rest of the slices in the operator status. The problem with map is that it cannot be guaranteed that the elements will be ordered in the same order they were placed. To fix that, define a new struct of an MCP and its respective created RTE daemonset and replace the map with a slice of this struct which ensures that same data will produce same output every time. ref: https://groups.google.com/g/golang-nuts/c/YfDxpkI34hY/m/4pktJI2ytusJ Signed-off-by: Shereen Haj <[email protected]>
181a8f6
to
8c847f8
Compare
/unhold |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, shajmakh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Using map to store the daemonset of the targeted MCPs turned out to be a not the best data structure especially when we would like to conserve a consistent order of the elements that aligns with the rest of the slices in the operator status.
The problem with map is that it cannot be guaranteed that the elements will be ordered in the same order they were placed. To fix that, define a new struct of an MCP and its respective created RTE daemonset and replace the map with a slice of this struct which ensures that same data will produce same output every time.
ref: https://groups.google.com/g/golang-nuts/c/YfDxpkI34hY/m/4pktJI2ytusJ