mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #32655 from dshulyak/fix_node_fake_update
Automatic merge from submit-queue Fix FakeNodeHandler Update behaviour Two problems: 1. Get is always using Existing nodes slice, and you will for sure miss any updated data 2. Each Update adds a duplicate node entry to UpdatedNodes slice For the 1st, we will try to find a node in UpdatedNodes slice (same as for the List). 2nd - append only if there is no node with same name as updated, if there is we will replace object in UpdatedNodes slice.
This commit is contained in:
commit
6e25117891
@ -107,6 +107,12 @@ func (m *FakeNodeHandler) Get(name string) (*api.Node, error) {
|
||||
m.RequestCount++
|
||||
m.lock.Unlock()
|
||||
}()
|
||||
for i := range m.UpdatedNodes {
|
||||
if m.UpdatedNodes[i].Name == name {
|
||||
nodeCopy := *m.UpdatedNodes[i]
|
||||
return &nodeCopy, nil
|
||||
}
|
||||
}
|
||||
for i := range m.Existing {
|
||||
if m.Existing[i].Name == name {
|
||||
nodeCopy := *m.Existing[i]
|
||||
@ -169,6 +175,12 @@ func (m *FakeNodeHandler) Update(node *api.Node) (*api.Node, error) {
|
||||
m.lock.Unlock()
|
||||
}()
|
||||
nodeCopy := *node
|
||||
for i, updateNode := range m.UpdatedNodes {
|
||||
if updateNode.Name == nodeCopy.Name {
|
||||
m.UpdatedNodes[i] = &nodeCopy
|
||||
return node, nil
|
||||
}
|
||||
}
|
||||
m.UpdatedNodes = append(m.UpdatedNodes, &nodeCopy)
|
||||
return node, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user