cybozu-go/coil

Fix the IP address allocation logic from AddressBlock

terassyi opened this issue · 3 comments

What

We want to avoid not reusing the address released in a short time.

Now Coil allocates an IP Address from an AddressBlock, it allocates the address of the smallest available index.
Therefore, we should fix not to use the address released in a short time.

How

The AddressBlock resource should have the index last allocated by Coil (lastAllocatedIndex).
And when Coil allocates the new address to a pod, Coil should pick the address next to lastAllocatedIndex.

Checklist

  • Finish implentation of the issue
  • Test all functions
  • Have enough logs to trace activities
  • Notify developers of necessary actions

The AddressBlock resource should have the index last allocated by Coil (lastAllocatedIndex)

@terassyi
Do you mean AddressBlock resource will be updated every time a new address is
assigned to / freed from a Pod? If so, I don't think it's a good idea.

Coil v1 had a performance problem because of this very behavior, so
Coil v2 was redesigned not to update resources in the kube-apiserver when
it allocates IP addresses from an AddressBlock.

Thank you for your comment.

Do you mean AddressBlock resource will be updated every time a new address is
assigned to / freed from a Pod? If so, I don't think it's a good idea.

I misunderstand what struct should have information.

The AddressBlock resource is the target of the reconciliation loop.
So if AddressBlock has the lastAllocatedIndex parameter, every time lastAllocatedIndex is updated, the reconciliation loop is triggered.

So we should avoid that AddressBlock has the lastAllocatedIndex.
Is it correct?

Now, I think the struct that should have information on the index last allocated is allocator.
How about this idea?

type allocator struct {

So we should avoid that AddressBlock has the lastAllocatedIndex.
Is it correct?

Correct.

Now, I think the struct that should have information on the index last allocated is allocator.

SGTM.