Skip to content

[bug] The agent may be stopped and started while the configuration is applied #172

@nemesifier

Description

@nemesifier

In some cases it may happen that the agent is stopped and started again while the configuration is being applied.

If this happens, the configuration or config status of the device may remain in an inconsistent state (either the configuration may not be fully applied or it may not report that it has been applied to the OpenWISP server).

I am not able to replicate right now the steps which cause the agent to stop and start itself automatically.

Something like this was happening for the "reload" which we are already handling.

If we can confirm this issue, we could introduce a mechanism which delays the stop of the agent until the configuration has been applied, like we are doing in the reload:

reload_service() {
logger -s "$PROG_NAME received reload trigger" -t openwisp -p daemon.info
# avoid reloading while configuration is being applied
# will wait for a maximum of 30 seconds
for _ in $(seq 1 30); do
if [ -f "$CONTROL_FILE" ]; then
sleep 1
else
break
fi
done
rm -f "$CONTROL_FILE"
start
}

We can turn that code into a function and reuse in stop_service too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions