Skip to content

Commit

Permalink
Process only shutdown requests after pre shutdown (sonic-net#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Dec 5, 2018
1 parent 1288f77 commit a732858
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3672,7 +3672,9 @@ int syncd_main(int argc, char **argv)
{
SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_RESTART_WARM=true: %s for pre-shutdown",
sai_serialize_status(status).c_str());

shutdownType = SYNCD_RESTART_TYPE_COLD;

warmRestartTable->hset("warm-shutdown", "state", "set-flag-failed");
continue;
}
Expand All @@ -3681,14 +3683,22 @@ int syncd_main(int argc, char **argv)
attr.value.booldata = true;

status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);

if (status == SAI_STATUS_SUCCESS)
{
warmRestartTable->hset("warm-shutdown", "state", "pre-shutdown-succeeded");

s = swss::Select();

s.addSelectable(restartQuery.get());

SWSS_LOG_NOTICE("switched to PRE_SHUTDOWN, from now on accepting only shurdown requests");
}
else
{
SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_PRE_SHUTDOWN=true: %s",
sai_serialize_status(status).c_str());

warmRestartTable->hset("warm-shutdown", "state", "pre-shutdown-failed");

// Restore cold shutdown.
Expand Down

0 comments on commit a732858

Please sign in to comment.