From 8617e484571642ada9e4e9868b1d5d060791f4a9 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Fri, 14 Aug 2020 19:31:52 +1000 Subject: [PATCH] Write to IPAM checkpoint file immediately after reading from CRI The current migration logic has a corner case: if we upgrade 1.6->1.7->1.8 and _never_ see a pod create/delete during the 1.7 phase, then we never write the IPAM checkpoint file. This change just writes the file immediately after reading state from CRI, if in migration phase1. --- pkg/ipamd/datastore/data_store.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/ipamd/datastore/data_store.go b/pkg/ipamd/datastore/data_store.go index adbb764ef0..0d44466f07 100644 --- a/pkg/ipamd/datastore/data_store.go +++ b/pkg/ipamd/datastore/data_store.go @@ -359,6 +359,16 @@ func (ds *DataStore) ReadBackingStore() error { ds.log.Debugf("Recovered %s => %s/%s", allocation.IPAMKey, eni.ID, addr.Address) } + if ds.CheckpointMigrationPhase == 1 { + // For phase1: write whatever we just read above from + // CRI to backingstore immediately - just in case we + // _never_ see an add/del request before we upgrade to + // phase2. + if err := ds.writeBackingStoreUnsafe(); err != nil { + return err + } + } + ds.log.Debugf("Completed ipam state recovery") return nil }