From e315befd27bfb7aa0ec04040e2ade5535f3b090f Mon Sep 17 00:00:00 2001 From: Jorge Camarero Vera <jorge.camarero@cern.ch> Date: Wed, 24 Nov 2021 11:52:43 +0100 Subject: [PATCH] Resolve "fix STALE message when cta-taped is restarting" --- ReleaseNotes.md | 1 + scheduler/TapeDrivesCatalogueState.cpp | 12 +++++++++--- xroot_plugins/XrdCtaDriveLs.hpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 39cacbb6e9..24a37ad625 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -14,6 +14,7 @@ - cta/CTA#1059 - Clean up warnings reported by static analysis - cta/CTA#1062 - cta-admin tf rm should store the diskFilePath when deleting the tape file copy - cta/CTA#1073 - Retry failed reporting for archive jobs +- cta/CTA#1078 - fix STALE message when cta-taped is restarting # v4.3-3 diff --git a/scheduler/TapeDrivesCatalogueState.cpp b/scheduler/TapeDrivesCatalogueState.cpp index 4e1843a14a..1b73114b9d 100644 --- a/scheduler/TapeDrivesCatalogueState.cpp +++ b/scheduler/TapeDrivesCatalogueState.cpp @@ -619,7 +619,7 @@ common::dataStructures::TapeDrive TapeDrivesCatalogueState::setTapeDriveStatus( const common::dataStructures::DesiredDriveState & desiredState, const common::dataStructures::MountType& type, const common::dataStructures::DriveStatus& status, const tape::daemon::TpconfigLine& tpConfigLine, const common::dataStructures::SecurityIdentity& identity) { - const time_t reportTime = time(NULL); + const time_t reportTime = time(nullptr); common::dataStructures::TapeDrive tapeDriveStatus; tapeDriveStatus.driveName = driveInfo.driveName; tapeDriveStatus.host = driveInfo.host; @@ -636,8 +636,14 @@ common::dataStructures::TapeDrive TapeDrivesCatalogueState::setTapeDriveStatus( tapeDriveStatus.reservedBytes = 0; tapeDriveStatus.devFileName = tpConfigLine.devFilename; tapeDriveStatus.rawLibrarySlot = tpConfigLine.rawLibrarySlot; - tapeDriveStatus.creationLog = common::dataStructures::EntryLog(identity.username, identity.host, reportTime); - tapeDriveStatus.lastModificationLog = common::dataStructures::EntryLog(identity.username, identity.host, reportTime); + if (identity.username.empty()) { + tapeDriveStatus.creationLog = common::dataStructures::EntryLog("NO_USER", driveInfo.host, reportTime); + tapeDriveStatus.lastModificationLog = common::dataStructures::EntryLog("NO_USER", driveInfo.host, reportTime); + } else { + tapeDriveStatus.creationLog = common::dataStructures::EntryLog(identity.username, identity.host, reportTime); + tapeDriveStatus.lastModificationLog = common::dataStructures::EntryLog(identity.username, identity.host, + reportTime); + } return tapeDriveStatus; } diff --git a/xroot_plugins/XrdCtaDriveLs.hpp b/xroot_plugins/XrdCtaDriveLs.hpp index 880dae0dbf..4289418953 100644 --- a/xroot_plugins/XrdCtaDriveLs.hpp +++ b/xroot_plugins/XrdCtaDriveLs.hpp @@ -127,7 +127,7 @@ int DriveLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) { else dr_item->set_latest_bandwidth(0); dr_item->set_session_id(dr.sessionId ? dr.sessionId.value() : 0); - const auto lastUpdateTime = dr.lastModificationLog ? dr.lastModificationLog.value().time : 0; + const auto lastUpdateTime = dr.lastModificationLog ? dr.lastModificationLog.value().time : time(nullptr); dr_item->set_time_since_last_update(time(nullptr) - lastUpdateTime); dr_item->set_current_priority(dr.currentPriority ? dr.currentPriority.value() : 0); dr_item->set_current_activity(dr.currentActivity ? dr.currentActivity.value() : ""); -- GitLab