Skip to content

Commit

Permalink
Move away sairedis logrotate from signal handler (#1153)
Browse files Browse the repository at this point in the history
* Move away sairedis logrotate from signal handler

* Update tests
  • Loading branch information
kcudnik authored Dec 22, 2019
1 parent 9f6efa0 commit 77fa5a4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
11 changes: 2 additions & 9 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int gBatchSize = DEFAULT_BATCH_SIZE;
bool gSairedisRecord = true;
bool gSwssRecord = true;
bool gLogRotate = false;
bool gSaiRedisLogRotate = false;
bool gSyncMode = false;

ofstream gRecordOfs;
Expand All @@ -73,15 +74,7 @@ void sighup_handler(int signo)
* Don't do any logging since they are using mutexes.
*/
gLogRotate = true;

sai_attribute_t attr;
attr.id = SAI_REDIS_SWITCH_ATTR_PERFORM_LOG_ROTATE;
attr.value.booldata = true;

if (sai_switch_api != NULL)
{
sai_switch_api->set_switch_attribute(gSwitchId, &attr);
}
gSaiRedisLogRotate = true;
}

void syncd_apply_view()
Expand Down
14 changes: 14 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace swss;

extern sai_switch_api_t* sai_switch_api;
extern sai_object_id_t gSwitchId;
extern bool gSaiRedisLogRotate;

extern void syncd_apply_view();
/*
Expand Down Expand Up @@ -400,6 +401,19 @@ void OrchDaemon::flush()
SWSS_LOG_ERROR("Failed to flush redis pipeline %d", status);
exit(EXIT_FAILURE);
}

// check if logroate is requested
if (gSaiRedisLogRotate)
{
SWSS_LOG_NOTICE("performing log rotate");

gSaiRedisLogRotate = false;

attr.id = SAI_REDIS_SWITCH_ATTR_PERFORM_LOG_ROTATE;
attr.value.booldata = true;

sai_switch_api->set_switch_attribute(gSwitchId, &attr);
}
}

void OrchDaemon::start()
Expand Down
3 changes: 2 additions & 1 deletion tests/mock_tests/mock_orchagent_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ int gBatchSize = DEFAULT_BATCH_SIZE;
bool gSairedisRecord = true;
bool gSwssRecord = true;
bool gLogRotate = false;
bool gSaiRedisLogRotate = false;
ofstream gRecordOfs;
string gRecordFile;

MirrorOrch *gMirrorOrch;
VRFOrch *gVrfOrch;

void syncd_apply_view() {}
void syncd_apply_view() {}
1 change: 1 addition & 0 deletions tests/mock_tests/mock_orchagent_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern int gBatchSize;
extern bool gSwssRecord;
extern bool gSairedisRecord;
extern bool gLogRotate;
extern bool gSaiRedisLogRotate;
extern ofstream gRecordOfs;
extern string gRecordFile;

Expand Down

0 comments on commit 77fa5a4

Please sign in to comment.