Developing lightweight computation at the DSG edge

Commit c65d3b2f authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Unassign devices from a monitor before leaving



When a monitor leaves the system, it now first unassigns all devices it has,
then deregisters from the list and quits.

The previous behaviour, for which it would just deregister and quit, meant it
left outdated assignations in the database, that some other monitor would have
to clean.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 4a553d5b
......@@ -112,9 +112,29 @@ func main() {
signal.Notify(signalChan, os.Interrupt)
go func() {
for _ = range signalChan {
fmt.Println("\nReceived an interrupt, deregistering from the monitors list and quitting...")
if len(localAssign) > 0 {
if len(localAssign) > 1 {
fmt.Println("\nReceived an interrupt, unassigning", len(localAssign), "devices from this monitor before quitting...")
} else {
fmt.Println("\nReceived an interrupt, unassigning 1 device from this monitor before quitting...")
}
var unassigned = 0
for _, v := range localAssign {
if unassignMonitorFromDevice(ID, v.Device.ID) {
unassigned = unassigned + 1
}
}
if unassigned == 1 && len(localAssign) == 1 {
fmt.Println("1 device out of 1 successfully unassigned.")
} else {
fmt.Println(unassigned, "devices out of", len(localAssign), "successfully unassigned.")
}
}
fmt.Println("Deregistering from the monitors list...")
deregisterMonitorInAntidote(ID)
cleanupDone <- true
}
}()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment