Skip to content

Avoid looping in Cleaning Up state

As @jleduc reported the drive was changing from DOWN to CLEANING_UP and vice-versa constantly. This behavior is set here https://gitlab.cern.ch/cta/CTA/-/blob/main/tapeserver/daemon/DriveHandler.cpp#L902

// 2) If the previous session crashed, we might want to run a cleaner session, depending
  // on the previous state
  std::set<SessionState> statesRequiringCleaner = {SessionState::Mounting,
                                                   SessionState::Running, SessionState::Unmounting};
  if (m_previousSession == PreviousSession::Crashed && statesRequiringCleaner.count(m_previousState)) {

So if the tape drive crash during the unmount of a tape and this one is stuck, it will enter in this repetitive behavior.

But we have this another case:

// 1) Special case first, if we crashed in a cleaner session, we put the drive down
if (m_previousSession == PreviousSession::Crashed && m_previousType == SessionType::Cleanup) {

The problem is that the case 2 doesn't set the variable m_sessionState to SessionType::Cleanup, so always it's calling the same case instead of after failing case 2 and going to case 1, it fails and it keeps calling the crashing case.

The fix is easy, to add m_sessionState = SessionType::Cleanup when the case 2 starts.

Related: https://gitlab.cern.ch/cta/operations/-/issues/1156