Skip to content

Commit

Permalink
[vs] Fail switch create when warm boot requested and no warm boot sta…
Browse files Browse the repository at this point in the history
…te (sonic-net#739)

* [vs] Fail switch create when warm boot requested and no warm boot state

Print extra information about loading warm boot state file, like file
size and number of switches loaded from that file.

* [syncd] Add explicit warning log when syncd start type is overridden
  • Loading branch information
kcudnik committed Dec 12, 2020
1 parent ccf59d7 commit 60c15e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ void Syncd::performStartupLogic()

if (m_isWarmStart && (m_commandLineOptions->m_startType != SAI_START_TYPE_FASTFAST_BOOT))
{
SWSS_LOG_WARN("override command line startType=%s via SAI_START_TYPE_WARM_BOOT",
CommandLineOptions::startTypeToString(m_commandLineOptions->m_startType).c_str());

m_commandLineOptions->m_startType = SAI_START_TYPE_WARM_BOOT;
}

Expand Down
11 changes: 9 additions & 2 deletions vslib/src/VirtualSwitchSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,10 @@ sai_status_t VirtualSwitchSaiInterface::create(

if (warmBootState == nullptr)
{
SWSS_LOG_WARN("warm boot was requested on switch %s, but warm boot state is NULL, will perform COLD boot",
SWSS_LOG_ERROR("warm boot was requested on switch %s, but warm boot state is NULL",
sai_serialize_object_id(switchId).c_str());

return SAI_STATUS_FAILURE;
}
}

Expand Down Expand Up @@ -1362,6 +1364,11 @@ bool VirtualSwitchSaiInterface::readWarmBootFile(
return false;
}

{
std::ifstream in(warmBootFile, std::ifstream::ate | std::ifstream::binary);
SWSS_LOG_NOTICE("%s file size: %zu", warmBootFile, (size_t)in.tellg());
}

std::ifstream ifs;

ifs.open(warmBootFile);
Expand Down Expand Up @@ -1467,7 +1474,7 @@ bool VirtualSwitchSaiInterface::readWarmBootFile(

ifs.close();

SWSS_LOG_NOTICE("warm boot file %s stats:", warmBootFile);
SWSS_LOG_NOTICE("warm boot file %s stats, loaded switches: %zu", warmBootFile, m_warmBootState.size());

for (auto& kvp: m_warmBootState)
{
Expand Down

0 comments on commit 60c15e5

Please sign in to comment.