kraftkit icon indicating copy to clipboard operation
kraftkit copied to clipboard

fix(machine): Remove link from store if already deleted

Open craciunoiuc opened this issue 1 year ago • 5 comments

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

craciunoiuc avatar Sep 20 '23 10:09 craciunoiuc

Ok then the fix would be to remove from the store on list?

craciunoiuc avatar Sep 20 '23 14:09 craciunoiuc

It will still fail if you run ip link del + kraft net rm without kraft net ls in between

craciunoiuc avatar Sep 20 '23 14:09 craciunoiuc

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.

nderjung avatar Sep 20 '23 14:09 nderjung

Ok I can try to fix there. Hopefully the store is also updated by the returned value, otherwise things will never be removed there

craciunoiuc avatar Sep 21 '23 08:09 craciunoiuc

Converting to draft as not really ready

The bug is still there by the way

craciunoiuc avatar Dec 19 '23 10:12 craciunoiuc