From c588778ac348661cc56674890957bc9872e7f834 Mon Sep 17 00:00:00 2001
From: Jorge Camarero Vera <jorge.camarero@cern.ch>
Date: Tue, 10 Aug 2021 16:54:48 +0200
Subject: [PATCH] Solved DriveHandler problem with the Tape Drive creation

---
 tapeserver/daemon/DriveHandler.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tapeserver/daemon/DriveHandler.cpp b/tapeserver/daemon/DriveHandler.cpp
index 600f2920b9..a2c3b608dd 100644
--- a/tapeserver/daemon/DriveHandler.cpp
+++ b/tapeserver/daemon/DriveHandler.cpp
@@ -1101,19 +1101,20 @@ int DriveHandler::runChild() {
           return castor::tape::tapeserver::daemon::Session::MARK_DRIVE_AS_DOWN;
         }
 
-        scheduler.reportDriveStatus(driveInfo, common::dataStructures::MountType::NoMount, common::dataStructures::DriveStatus::Down, lc);
         cta::common::dataStructures::SecurityIdentity securityIdentity;
         cta::common::dataStructures::DesiredDriveState driveState;
         driveState.up = false;
         driveState.forceDown = false;
+        scheduler.createTapeDriveStatus(driveInfo, driveState, common::dataStructures::MountType::NoMount,
+          common::dataStructures::DriveStatus::Down, m_configLine, securityIdentity, lc);
+
         // Get the drive state to see if there is a reason or not, we don't want to change the reason
         // why a drive is down at the startup of the tapeserver
         cta::common::dataStructures::DesiredDriveState  currentDesiredDriveState = scheduler.getDesiredDriveState(m_configLine.unitName,lc);
         if(!currentDesiredDriveState.reason){
           driveState.setReasonFromLogMsg(logLevel,msg);
         }
-        scheduler.createTapeDriveStatus(driveInfo, driveState, common::dataStructures::MountType::NoMount,
-          common::dataStructures::DriveStatus::Down, m_configLine, securityIdentity, lc);
+        scheduler.reportDriveStatus(driveInfo, common::dataStructures::MountType::NoMount, common::dataStructures::DriveStatus::Down, lc);
         scheduler.reportDriveConfig(m_configLine, m_tapedConfig,lc);
       } catch (cta::exception::Exception & ex) {
         params.add("Message", ex.getMessageValue())
-- 
GitLab