Skip to content

Commit 4749e36

Browse files
committed
Fix CNI server state behavior on reload.
This patch fixes the behavior of CNI server state reload on error. It addresses the two following issues. - If the state file is corrupted and parsing errors, we should return, not proceed as the parsed cniServerState might contain partial data. - When VPP re-programmation completes, we overwrite the state file so that we remove pods that yielded errors or for which the linux ns was removed. Signed-off-by: Nathan Skrzypczak <[email protected]>
1 parent 2004ae4 commit 4749e36

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

calico-vpp-agent/cni/cni_server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ func (s *Server) rescanState() {
191191
if err != nil {
192192
s.log.Errorf("Could not remove %s, %s", config.CniServerStateFilename, err)
193193
}
194+
// if the cniServerState file is corrupted, we remove it and give up.
195+
return
194196
}
195197

196198
s.log.Infof("RescanState: re-creating all interfaces")
@@ -216,6 +218,13 @@ func (s *Server) rescanState() {
216218
}
217219
}
218220
}
221+
err = model.PersistCniServerState(
222+
model.NewCniServerState(s.podInterfaceMap),
223+
config.CniServerStateFilename,
224+
)
225+
if err != nil {
226+
s.log.Errorf("CNI state persist errored %v", err)
227+
}
219228
}
220229

221230
func (s *Server) DelRedirectToHostOnInterface(swIfIndex uint32) error {

0 commit comments

Comments
 (0)