kit: start spamming the logs when linking/copying is slowww
This is sometimes the case in docker when the link operation 'copies up' things from lower layers to the working docker container's layer. In such cases, let the admin know. Change-Id: Ib72b67304a292c3832838379cc76bcb4a7268cb3 Reviewed-on: https://gerrit.libreoffice.org/48710 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
This commit is contained in:
parent
9ea81e7921
commit
1d22f7bc54
1 changed files with 24 additions and 0 deletions
24
kit/Kit.cpp
24
kit/Kit.cpp
|
@ -120,6 +120,9 @@ namespace
|
|||
LinkOrCopyType linkOrCopyType;
|
||||
std::string sourceForLinkOrCopy;
|
||||
Path destinationForLinkOrCopy;
|
||||
std::chrono::time_point<std::chrono::steady_clock> linkOrCopyStartTime;
|
||||
bool linkOrCopyVerboseLogging = false;
|
||||
unsigned slowLinkOrCopyLimitInSecs = 10; // after this much seconds, start spamming the logs
|
||||
|
||||
bool shouldCopyDir(const char *path)
|
||||
{
|
||||
|
@ -151,6 +154,18 @@ namespace
|
|||
if (strcmp(fpath, sourceForLinkOrCopy.c_str()) == 0)
|
||||
return 0;
|
||||
|
||||
if (!linkOrCopyVerboseLogging)
|
||||
{
|
||||
const auto durationInSecs = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::steady_clock::now() - linkOrCopyStartTime);
|
||||
if (durationInSecs.count() > slowLinkOrCopyLimitInSecs)
|
||||
{
|
||||
LOG_WRN("Linking/copying files from " << sourceForLinkOrCopy << " to " << destinationForLinkOrCopy.toString() <<
|
||||
" is taking too much time. Enabling verbose link/copy logging at information level.");
|
||||
linkOrCopyVerboseLogging = true;
|
||||
}
|
||||
}
|
||||
|
||||
assert(fpath[strlen(sourceForLinkOrCopy.c_str())] == '/');
|
||||
const char *relativeOldPath = fpath + strlen(sourceForLinkOrCopy.c_str()) + 1;
|
||||
Path newPath(destinationForLinkOrCopy, Path(relativeOldPath));
|
||||
|
@ -160,6 +175,9 @@ namespace
|
|||
case FTW_F:
|
||||
case FTW_SLN:
|
||||
File(newPath.parent()).createDirectories();
|
||||
|
||||
if (linkOrCopyVerboseLogging)
|
||||
LOG_INF("Linking file \"" << fpath << "\" to \"" << newPath.toString() << "\"");
|
||||
if (link(fpath, newPath.toString().c_str()) == -1)
|
||||
{
|
||||
LOG_SYS("link(\"" << fpath << "\", \"" <<
|
||||
|
@ -223,10 +241,16 @@ namespace
|
|||
if (sourceForLinkOrCopy.back() == '/')
|
||||
sourceForLinkOrCopy.pop_back();
|
||||
destinationForLinkOrCopy = destination;
|
||||
linkOrCopyStartTime = std::chrono::steady_clock::now();
|
||||
if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == -1)
|
||||
{
|
||||
LOG_ERR("linkOrCopy: nftw() failed for '" << source << "'");
|
||||
}
|
||||
if (linkOrCopyVerboseLogging)
|
||||
{
|
||||
LOG_INF("Linking/Copying of files to " << destinationForLinkOrCopy.toString() << " finished.");
|
||||
linkOrCopyVerboseLogging = false;
|
||||
}
|
||||
}
|
||||
|
||||
void dropCapability(cap_value_t capability)
|
||||
|
|
Loading…
Reference in a new issue