Skip to content

Commit 5cb69df

Browse files
hedibouattoursknat
authored andcommitted
vpp: recover from panic in vpp manager
Previously, any return from the VPP manager was treated as an indication that VPP had exited or crashed, triggering configuration restoration. However, if the VPP manager itself panicked while VPP was still running, the deferred logic would interpret this as a VPP crash and attempt to restore the configuration. Since VPP was actually still alive, the restoration could hang and the original panic would never be properly surfaced. This change adds panic recovery in the VPP manager to prevent false assumptions about VPP state and avoid blocking during restore when the failure originates in the manager itself. When VPPmanager crashes we kill VPP, wait a bit, then restore the config.
1 parent 46c6675 commit 5cb69df

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

vpp-manager/vpp_runner.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,10 +945,23 @@ func (v *VppRunner) runVpp() (err error) {
945945
vppProcess = vppCmd.Process
946946
}
947947

948-
/**
949-
* From this point it is very important that every exit
950-
* path calls restoreConfiguration after vpp exits */
951-
defer v.restoreConfiguration(v.allInterfacesPhysical())
948+
defer func() {
949+
if r := recover(); r != nil {
950+
// we recover and log the error if there is a bug in vpp-manager
951+
fmt.Println("Recovered. Error:\n", r)
952+
// then we kill vpp and restore configuration
953+
terminateVpp("Killing VPP, error in vpp-manager : %v", r)
954+
// we need to wait a bit to make sure VPP is dead before restoring config
955+
time.Sleep(time.Second * 5)
956+
v.restoreConfiguration(v.allInterfacesPhysical())
957+
} else {
958+
/**
959+
* From this point it is very important that every exit
960+
* path calls restoreConfiguration if vpp exits
961+
* this is called when vppDeadChan is triggered */
962+
v.restoreConfiguration(v.allInterfacesPhysical())
963+
}
964+
}()
952965

953966
log.Infof("VPP started [PID %d]", vppProcess.Pid)
954967
runningCond.Broadcast()

0 commit comments

Comments
 (0)