Skip to content

Commit e0768a4

Browse files
committed
feat: skip in deleting ips and networks
1 parent 29f2027 commit e0768a4

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

pkg/ipam/initialize.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
// +kubebuilder:rbac:groups=ipam.liqo.io,resources=networks,verbs=get;list;watch
2626

2727
func (lipam *LiqoIPAM) initialize(ctx context.Context) error {
28+
lipam.mutex.Lock()
29+
defer lipam.mutex.Unlock()
2830
klog.Info("Initializing IPAM")
2931

3032
if err := lipam.initializeNetworks(ctx); err != nil {

pkg/ipam/ips.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func (lipam *LiqoIPAM) listIPsOnCluster(ctx context.Context, cl client.Client) (
9393
for i := range ipList.Items {
9494
ip := &ipList.Items[i]
9595

96+
deleting := !ip.GetDeletionTimestamp().IsZero()
97+
if deleting {
98+
continue
99+
}
100+
96101
address := ip.Status.IP.String()
97102
if address == "" {
98103
klog.Warningf("IP %q has no address", ip.Name)

pkg/ipam/networks.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (lipam *LiqoIPAM) listNetworksOnCluster(ctx context.Context, cl client.Clie
9292
for i := range networks.Items {
9393
net := &networks.Items[i]
9494

95+
deleting := !net.GetDeletionTimestamp().IsZero()
96+
if deleting {
97+
continue
98+
}
99+
95100
cidr := net.Status.CIDR.String()
96101
if cidr == "" {
97102
continue

pkg/ipam/sync.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func (lipam *LiqoIPAM) sync(ctx context.Context, syncFrequency time.Duration) {
3939

4040
err := wait.PollUntilContextCancel(ctx, syncFrequency, false,
4141
func(ctx context.Context) (done bool, err error) {
42+
lipam.mutex.Lock()
43+
defer lipam.mutex.Unlock()
4244
klog.Info("Started IPAM cache sync routine")
4345

4446
// Sync networks.

0 commit comments

Comments
 (0)