kraftkit
kraftkit copied to clipboard
fix(machine): Remove link from store if already deleted
Prerequisite checklist
- [x] Read the contribution guidelines regarding submitting new changes to the project;
- [x] Tested your changes against relevant architectures and platforms;
- [x] Ran
make fmt
on your commit series before opening this PR; - [ ] Updated relevant documentation.
Description of changes
This fixes the case where someone creates a network with kraftkit and removes it with something else like ifconfig
/ip link del
and the entry stays in the list.
Partial fix for: #820
Ok then the fix would be to remove from the store on list?
It will still fail if you run ip link del
+ kraft net rm
without kraft net ls
in between
When kraft net ls
is run, eventually the network controller/v1alpha1 implemention will be called which calls List
. This prototype will receive a "stale" list of networks in the positional parameter networks
:
func (service *v1alpha1Network) List(ctx context.Context, networks *networkv1alpha1.NetworkList) (*networkv1alpha1.NetworkList, error) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The value of networks
was populated by going through the store. During the iteration of this list, items need to be added and removed based on whether they exist or not. Clearly this is not working correctly here.
The result List
should return an up-to-date list of networks which then is passed back to the store and saved.
The store essentially provides us with "enriched" metadata about items.
Ok I can try to fix there. Hopefully the store is also updated by the returned value, otherwise things will never be removed there
Converting to draft as not really ready
The bug is still there by the way