Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ void syncd_apply_view()
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to notify syncd APPLY_VIEW %d", status);
exit(EXIT_FAILURE);
notifyAbort();
abort();
}
}

Expand Down Expand Up @@ -486,6 +487,9 @@ int main(int argc, char **argv)
DBConnector config_db("CONFIG_DB", 0);
DBConnector state_db("STATE_DB", 0);

/* Clears the ORCH_ABORT_STATUS flag in STATE_DB */
state_db.del(ORCH_ABRT);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

@vivekrnv vivekrnv Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be done, but clearing it here gives more time buffer to the processes dependent on this flag.


// Get switch_type
getCfgSwitchType(&config_db, gMySwitchType);

Expand Down Expand Up @@ -634,7 +638,8 @@ int main(int argc, char **argv)
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to get MAC address from switch, rv:%d", status);
exit(EXIT_FAILURE);
notifyAbort();
abort();
}
else
{
Expand All @@ -649,7 +654,8 @@ int main(int argc, char **argv)
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Fail to get switch virtual router ID %d", status);
exit(EXIT_FAILURE);
notifyAbort();
abort();
}

gVirtualRouterId = attr.value.oid;
Expand Down Expand Up @@ -691,7 +697,8 @@ int main(int argc, char **argv)
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to create underlay router interface %d", status);
exit(EXIT_FAILURE);
notifyAbort();
abort();
}

SWSS_LOG_NOTICE("Created underlay router interface ID %" PRIx64, gUnderlayIfId);
Expand Down
14 changes: 14 additions & 0 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ extern ofstream gRecordOfs;
extern bool gLogRotate;
extern string gRecordFile;

void notifyAbort(){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API name is not aligned to the functionality. This is doing both notify and abort. API gives the indication that it is only notification. Please move abort to original code and use it only to notify or change the name to say notifyAndAbort

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled

/*
* This function sets the ORCH_ABORT_STATUS flag in STATE_DB and aborts itself
*/
swss::DBConnector m_db("STATE_DB", 0);
m_db.set(ORCH_ABRT, "1");
}

Orch::Orch(DBConnector *db, const string tableName, int pri)
{
addConsumer(db, tableName, pri);
Expand Down Expand Up @@ -887,6 +895,7 @@ task_process_status Orch::handleSaiCreateStatus(sai_api_t api, sai_status_t stat
default:
SWSS_LOG_ERROR("Encountered failure in create operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}
break;
Expand All @@ -905,6 +914,7 @@ task_process_status Orch::handleSaiCreateStatus(sai_api_t api, sai_status_t stat
default:
SWSS_LOG_ERROR("Encountered failure in create operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}
default:
Expand All @@ -916,6 +926,7 @@ task_process_status Orch::handleSaiCreateStatus(sai_api_t api, sai_status_t stat
default:
SWSS_LOG_ERROR("Encountered failure in create operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}
}
Expand Down Expand Up @@ -957,11 +968,13 @@ task_process_status Orch::handleSaiSetStatus(sai_api_t api, sai_status_t status,
default:
SWSS_LOG_ERROR("Encountered failure in set operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}
default:
SWSS_LOG_ERROR("Encountered failure in set operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}

Expand Down Expand Up @@ -990,6 +1003,7 @@ task_process_status Orch::handleSaiRemoveStatus(sai_api_t api, sai_status_t stat
default:
SWSS_LOG_ERROR("Encountered failure in remove operation, exiting orchagent, SAI API: %s, status: %s",
sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str());
notifyAbort();
abort();
}
return task_need_retry;
Expand Down
4 changes: 4 additions & 0 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const char state_db_key_delimiter = '|';
#define CONFIGDB_KEY_SEPARATOR "|"
#define DEFAULT_KEY_SEPARATOR ":"
#define VLAN_SUB_INTERFACE_SEPARATOR "."
#define ORCH_ABRT "ORCH_ABRT_STATUS"

const int default_orch_pri = 0;

Expand All @@ -58,6 +59,9 @@ typedef enum
task_duplicated
} task_process_status;


void notifyAbort();

typedef struct
{
// m_objsDependingOnMe stores names (without table name) of all objects depending on the current obj
Expand Down
1 change: 1 addition & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ void OrchDaemon::flush()
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to flush redis pipeline %d", status);
notifyAbort();
abort();
}
}
Expand Down