diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8b4b237b2008809525788431eb8c505f7b92ec96..c06b6458b7afbbac19f95eacdab1abb9e0a2dcb5 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,6 +2,7 @@ ## Summary ### Features +- cta/CTA#41 - Delete verification_status of tape when tape is reclaimed - cta/CTA#153 - Allow verification status to be cleared with cta-admin ### Bug fixes - cta/CTA#161 - Fix bug when using temporary tables with PostgreSQL diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index d38b93b715ef64cd62e484d9ca3813e28c65f572..a9a474d235f5c968408bd846ece3c40d2a676a0d 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -6363,7 +6363,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapeVerificationStatus) { const common::dataStructures::Tape tape = tapes.front(); ASSERT_EQ(m_tape1.vid, tape.vid); - ASSERT_EQ(tape.verificationStatus.has_value(), false); + ASSERT_FALSE(tape.verificationStatus); } } @@ -16284,6 +16284,7 @@ TEST_P(cta_catalogue_CatalogueTest, reclaimTape_full_lastFSeq_0_no_tape_files) { ASSERT_EQ(m_vo.name, tape.vo); ASSERT_EQ(m_mediaType.capacityInBytes, tape.capacityInBytes); ASSERT_FALSE(tape.full); + ASSERT_FALSE(tape.verificationStatus); ASSERT_FALSE(tape.isFromCastor); ASSERT_EQ(m_tape1.comment, tape.comment); diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index 677d715bd8563bfa4acf0c7e990bd25fd5975ebc..be1b28b65942c5ae934d5494690b272d2478d7b3 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -4718,6 +4718,7 @@ void RdbmsCatalogue::resetTapeCounters(rdbms::Conn& conn, const common::dataStru "COPY_NB_GT_1_IN_BYTES = 0," "IS_FULL = '0'," "IS_FROM_CASTOR = '0'," + "VERIFICATION_STATUS = :VERIFICATION_STATUS," "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME," "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME," "LAST_UPDATE_TIME = :LAST_UPDATE_TIME," @@ -4725,6 +4726,7 @@ void RdbmsCatalogue::resetTapeCounters(rdbms::Conn& conn, const common::dataStru "WHERE " "VID = :VID"; auto stmt = conn.createStmt(sql); + stmt.bindString(":VERIFICATION_STATUS", std::nullopt); stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); @@ -4748,29 +4750,29 @@ void RdbmsCatalogue::reclaimTape(const common::dataStructures::SecurityIdentity TapeSearchCriteria searchCriteria; searchCriteria.vid = vid; const auto tapes = getTapes(conn, searchCriteria); - tl.insertAndReset("getTapesTime",t); + tl.insertAndReset("getTapesTime", t); - if(tapes.empty()) { + if (tapes.empty()) { throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it does not exist"); } else { - if(!tapes.front().full){ + if (!tapes.front().full) { throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it is not FULL"); } } - //The tape exists and is full, we can try to reclaim it - if(this->getNbFilesOnTape(conn,vid) == 0){ - tl.insertAndReset("getNbFilesOnTape",t); - //There is no files on the tape, we can reclaim it : delete the files and reset the counters - deleteFilesFromRecycleLog(conn,vid,lc); - tl.insertAndReset("deleteFileFromRecycleLogTime",t); - resetTapeCounters(conn,admin,vid); - tl.insertAndReset("resetTapeCountersTime",t); + // The tape exists and is full, we can try to reclaim it + if (this->getNbFilesOnTape(conn, vid) == 0) { + tl.insertAndReset("getNbFilesOnTape", t); + // There is no files on the tape, we can reclaim it : delete the files and reset the counters + deleteFilesFromRecycleLog(conn, vid, lc); + tl.insertAndReset("deleteFileFromRecycleLogTime", t); + resetTapeCounters(conn, admin, vid); + tl.insertAndReset("resetTapeCountersTime", t); log::ScopedParamContainer spc(lc); - spc.add("vid",vid); - spc.add("host",admin.host); - spc.add("username",admin.username); + spc.add("vid", vid); + spc.add("host", admin.host); + spc.add("username", admin.username); tl.addToLog(spc); - lc.log(log::INFO,"In RdbmsCatalogue::reclaimTape(), tape reclaimed."); + lc.log(log::INFO, "In RdbmsCatalogue::reclaimTape(), tape reclaimed."); } else { throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because there is at least one tape" " file in the catalogue that is on the tape"); diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 635ee667aa502202674731c7169fff4f67e2d79e..7a95c2c23c6f30fb6f509cc0e28cd16294c77975 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -2005,7 +2005,7 @@ void RequestMessage::processTape_Reclaim(cta::xrd::Response &response) auto &vid = getRequired(OptionString::VID); - m_catalogue.reclaimTape(m_cliIdentity, vid,m_lc); + m_catalogue.reclaimTape(m_cliIdentity, vid, m_lc); response.set_type(cta::xrd::Response::RSP_SUCCESS); }