Skip to content

Commit

Permalink
Use abort instead of exit in case calling SAI API failure (#2170)
Browse files Browse the repository at this point in the history
- What I did
Use abort instead of exit in case calling SAI API failure
Currently, exit is used in functions handleSai{Create,Remove,Set,Get}Status on SAI failure while abort is used in some other functions on SAI failure.
IMO using abort yields benefits:

Consistent behavior in orchagent on SAI failure in mocked test, in case SAI failure occurs the test process will just exit silently, which makes it very difficult for developers to find out what happened. by using abort, a coredump will be generated, which helps developers nail down the issue.
So we would like to use abort in all cases of receiving SAI failure.

- Why I did it

- How I verified it
Manually test.

Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs authored and judyjoseph committed Mar 20, 2022
1 parent e767137 commit 459aee0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,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());
exit(EXIT_FAILURE);
abort();
}
break;
case SAI_API_HOSTIF:
Expand All @@ -900,7 +900,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());
exit(EXIT_FAILURE);
abort();
}
default:
switch (status)
Expand All @@ -911,7 +911,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());
exit(EXIT_FAILURE);
abort();
}
}
return task_need_retry;
Expand Down Expand Up @@ -952,12 +952,12 @@ 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());
exit(EXIT_FAILURE);
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());
exit(EXIT_FAILURE);
abort();
}

return task_need_retry;
Expand Down Expand Up @@ -985,7 +985,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());
exit(EXIT_FAILURE);
abort();
}
return task_need_retry;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ void OrchDaemon::flush()
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to flush redis pipeline %d", status);
exit(EXIT_FAILURE);
abort();
}

// check if logroate is requested
Expand Down

0 comments on commit 459aee0

Please sign in to comment.