Commit 71cbce25 authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[repack] A repack request cannot be submitted when the mount policy is

not given
parent c5d9538c
......@@ -575,7 +575,7 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = {
{{ AdminCmd::CMD_MOUNTPOLICY, AdminCmd::SUBCMD_LS }, { }},
/*----------------------------------------------------------------------------------------------------*/
{{ AdminCmd::CMD_REPACK, AdminCmd::SUBCMD_ADD },
{ opt_vid.optional(), opt_vidfile.optional(), opt_bufferurl.optional(), opt_justmove.optional(), opt_justaddcopies.optional(), opt_mountpolicy.optional(), opt_disabled_tape.optional() }},
{ opt_vid.optional(), opt_vidfile.optional(), opt_bufferurl.optional(), opt_justmove.optional(), opt_justaddcopies.optional(), opt_mountpolicy, opt_disabled_tape.optional() }},
{{ AdminCmd::CMD_REPACK, AdminCmd::SUBCMD_RM }, { opt_vid }},
{{ AdminCmd::CMD_REPACK, AdminCmd::SUBCMD_LS }, { opt_vid.optional() }},
{{ AdminCmd::CMD_REPACK, AdminCmd::SUBCMD_ERR }, { opt_vid }},
......
......@@ -127,7 +127,7 @@ allPid=()
for vid in ${tapesToRepack[@]}
do
echo "Launching repack requests on vid $vid"
bash /root/repack_systemtest.sh -v $vid -b ${REPACK_BUFFER_URL} -t 500 &
bash /root/repack_systemtest.sh -v $vid -b ${REPACK_BUFFER_URL} -t 500 -n ctasystest &
allPid+=($!)
done
......
......@@ -123,7 +123,7 @@ kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin --json version | jq
--cartridge "T10000" \
--comment "Oracle T10000 cartridge formated at 500 GB (for developers only)"
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin mediatype add \
--name 3592JC7T
--name 3592JC7T \
--capacity 7000000000000 \
--primarydensitycode 84 \
--cartridge "3592JC" \
......@@ -152,13 +152,6 @@ kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin --json version | jq
--primarydensitycode 94 \
--cartridge "LTO-8" \
--comment "LTO-8 cartridge formated at 12 TB"
# add the media type of the tapes in the CI
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin mediatype add \
--name "T10K500G" \
--capacity 500000000000 \
--primarydensitycode 74 \
--cartridge "T10000" \
--comment "T10000A"
# add all tapes
for ((i=0; i<${#TAPES[@]}; i++)); do
VID=${TAPES[${i}]}
......
......@@ -14,8 +14,9 @@ die() {
}
usage() { cat <<EOF 1>&2
Usage: $0 -v <vid> -b <bufferURL> [-e <eosinstance>] [-t <timeout>] [-r <reportDirectory>] [-a] [-m] [-d]
Usage: $0 -v <vid> -b <bufferURL> -n <mountPolicyName> [-e <eosinstance>] [-t <timeout>] [-r <reportDirectory>] [-a] [-m] [-d]
(bufferURL example : /eos/ctaeos/repack)
mountPolicyName: the name of the mountPolicy to be applied to the repack request (example: ctasystest)
eosinstance : the name of the ctaeos instance to be used (default : $EOSINSTANCE)
timeout : the timeout in seconds to wait for the repack to be done
reportDirectory : the directory to generate the report of the repack test (default : $REPORT_DIRECTORY)
......@@ -40,13 +41,13 @@ testRepackBufferURL(){
echo "Test repack buffer URL OK"
}
if [ $# -lt 2 ]
if [ $# -lt 3 ]
then
usage
fi;
DISABLED_TAPE_FLAG=""
while getopts "v:e:b:t:r:amdp" o; do
while getopts "v:e:b:t:r:n:amdp" o; do
case "${o}" in
v)
VID_TO_REPACK=${OPTARG}
......@@ -75,6 +76,9 @@ while getopts "v:e:b:t:r:amdp" o; do
p)
BACKPRESSURE_TEST=1
;;
n)
MOUNT_POLICY_NAME=${OPTARG}
;;
*)
usage
;;
......@@ -92,6 +96,11 @@ if [ "x${VID_TO_REPACK}" = "x" ]; then
die "No vid to repack provided."
fi
if [ "x${MOUNT_POLICY_NAME}" = "x" ]; then
usage
die "No mount policy name provided."
fi
REPACK_OPTION=""
if [ "x${ADD_COPIES_ONLY}" != "x" ] && [ "x${MOVE_ONLY}" != "x" ]; then
......@@ -130,7 +139,7 @@ fi
echo "Launching repack request for VID ${VID_TO_REPACK}, bufferURL = ${FULL_REPACK_BUFFER_URL}"
admin_cta repack add --vid ${VID_TO_REPACK} ${REPACK_OPTION} --bufferurl ${FULL_REPACK_BUFFER_URL} ${DISABLED_TAPE_FLAG}
admin_cta repack add --mountpolicy ${MOUNT_POLICY_NAME} --vid ${VID_TO_REPACK} ${REPACK_OPTION} --bufferurl ${FULL_REPACK_BUFFER_URL} ${DISABLED_TAPE_FLAG}
if [ ! -z $BACKPRESSURE_TEST ]; then
echo "Backpressure test: waiting to see a report of sleeping retrieve queue."
......
......@@ -67,7 +67,7 @@ roundTripRepack() {
then
echo
echo "Launching the repack \"just move\" test on VID ${VID_TO_REPACK} (with backpressure)"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step1-RoundTripRepack -p || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step1-RoundTripRepack -p -n ctasystest || exit 1
else
echo "No vid found to repack"
exit 1
......@@ -81,7 +81,7 @@ roundTripRepack() {
then
echo
echo "Launching the repack \"just move\" test on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RoundTripRepack || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RoundTripRepack -n ctasystest || exit 1
else
echo "No vid found to repack"
exit 1
......@@ -110,7 +110,7 @@ repackDisableTape() {
echo "Waiting 20 seconds so that the RetrieveQueueStatisticsCache is flushed"
sleep 20
echo "Launching the repack request test on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackDisabledTape && echo "The repack request is Complete instead of Failed, it should be failed as the tape is disabled" && exit 1 || echo "REPACK FAILED, the tape is disabled so, Test OK"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackDisabledTape -n ctasystest && echo "The repack request is Complete instead of Failed, it should be failed as the tape is disabled" && exit 1 || echo "REPACK FAILED, the tape is disabled so, Test OK"
else
echo "No vid found to repack"
exit 1
......@@ -118,7 +118,7 @@ repackDisableTape() {
echo
echo "Launching the repack request test on VID ${VID_TO_REPACK} with the --disabledtape flag"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -d -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackDisabledTape || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -d -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackDisabledTape -n ctasystest || exit 1
echo "Reclaiming tape ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin tape reclaim --vid ${VID_TO_REPACK}
......@@ -140,7 +140,7 @@ repackJustMove() {
then
echo
echo "Launching the repack test \"just move\" on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackJustMove || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackJustMove -n ctasystest || exit 1
else
echo "No vid found to repack"
exit 1
......@@ -164,7 +164,7 @@ repackJustAddCopies() {
if [ "$VID_TO_REPACK" != "null" ]
then
echo "Launching the repack \"just add copies\" test on VID ${VID_TO_REPACK} with all copies already on CTA"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -a -r ${BASE_REPORT_DIRECTORY}/Step$1-JustAddCopiesAllCopiesInCTA
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -a -r ${BASE_REPORT_DIRECTORY}/Step$1-JustAddCopiesAllCopiesInCTA -n ctasystest
else
echo "No vid found to repack"
exit 1
......@@ -204,7 +204,7 @@ repackCancellation() {
then
echo
echo "Launching a repack request on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackCancellation & 2>/dev/null
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackCancellation -n ctasystest & 2>/dev/null
pid=$!
else
echo "No vid found to repack"
......@@ -338,7 +338,7 @@ repackMoveAndAddCopies() {
VID_TO_REPACK=$(getFirstVidContainingFiles)
echo "Launching the repack \"Move and add copies\" test on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -t 600 -r ${BASE_REPORT_DIRECTORY}/Step$1-MoveAndAddCopies || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -t 600 -r ${BASE_REPORT_DIRECTORY}/Step$1-MoveAndAddCopies -n ctasystest || exit 1
repackLsResult=`kubectl -n ${NAMESPACE} exec ctacli -- cta-admin --json repack ls --vid ${VID_TO_REPACK} | jq ". [0]"`
totalFilesToRetrieve=`echo $repackLsResult | jq -r ".totalFilesToRetrieve"`
......@@ -421,7 +421,7 @@ repackTapeRepair() {
done
echo "Launching a repack request on the vid ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackTapeRepair || exit 1
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -m -r ${BASE_REPORT_DIRECTORY}/Step$1-RepackTapeRepair -n ctasystest || exit 1
repackLsResult=`kubectl -n ${NAMESPACE} exec ctacli -- cta-admin --json repack ls --vid ${VID_TO_REPACK} | jq -r ". [0]"`
userProvidedFiles=`echo $repackLsResult | jq -r ".userProvidedFiles"`
......
......@@ -44,7 +44,7 @@ echo
echo "Marking the tape ${VID_TO_REPACK} as full"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin tape ch --vid ${VID_TO_REPACK} -f true
echo "Launching the repack test on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL}
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -n ctasystest
else
echo "No vid found to repack"
exit 1
......@@ -60,7 +60,7 @@ echo
echo "Marking the tape ${VID_TO_REPACK} as full"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin tape ch --vid ${VID_TO_REPACK} -f true
echo "Launching the repack test on VID ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL}
kubectl -n ${NAMESPACE} exec client -- bash /root/repack_systemtest.sh -v ${VID_TO_REPACK} -b ${REPACK_BUFFER_URL} -n ctasystest
else
echo "No vid found to repack"
exit 1
......
......@@ -1405,79 +1405,73 @@ void RequestMessage::processMountPolicy_Ls(cta::xrd::Response &response, XrdSsiS
void RequestMessage::processRepack_Add(cta::xrd::Response &response)
{
using namespace cta::admin;
using namespace cta::admin;
// VIDs can be provided as a single option or as a list
std::vector<std::string> vid_list;
std::string bufferURL;
// VIDs can be provided as a single option or as a list
std::vector<std::string> vid_list;
std::string bufferURL;
auto vidl = getOptional(OptionStrList::VID);
if(vidl) vid_list = vidl.value();
auto vid = getOptional(OptionString::VID);
if(vid) vid_list.push_back(vid.value());
auto vidl = getOptional(OptionStrList::VID);
if(vidl) vid_list = vidl.value();
auto vid = getOptional(OptionString::VID);
if(vid) vid_list.push_back(vid.value());
if(vid_list.empty()) {
throw cta::exception::UserError("Must specify at least one vid, using --vid or --vidfile options");
}
if(vid_list.empty()) {
throw cta::exception::UserError("Must specify at least one vid, using --vid or --vidfile options");
}
auto buff = getOptional(OptionString::BUFFERURL);
if (buff){
//The buffer is provided by the user
bufferURL = buff.value();
}
else {
//Buffer is not provided by the user, try to get the one from the configuration file
if(m_repackBufferURL){
bufferURL = m_repackBufferURL.value();
} else {
//Buffer is neither provided by the user, neither provided by the frontend configuration file, exception
throw cta::exception::UserError("Must specify the buffer URL using --bufferurl option or using the frontend configuration file.");
}
}
typedef common::dataStructures::MountPolicy MountPolicy;
MountPolicy mountPolicy = MountPolicy::s_defaultMountPolicyForRepack;
auto mountPolicyProvidedByUserOpt = getOptional(OptionString::MOUNT_POLICY);
if(mountPolicyProvidedByUserOpt){
//The user specified a mount policy name for this repack request
std::string mountPolicyProvidedByUser = mountPolicyProvidedByUserOpt.value();
//Get the mountpolicy from the catalogue
typedef std::list<common::dataStructures::MountPolicy> MountPolicyList;
MountPolicyList mountPolicies = m_catalogue.getMountPolicies();
MountPolicyList::const_iterator repackMountPolicyItor = std::find_if(mountPolicies.begin(),mountPolicies.end(),[mountPolicyProvidedByUser](const common::dataStructures::MountPolicy & mp){
return mp.name == mountPolicyProvidedByUser;
});
if(repackMountPolicyItor != mountPolicies.end()){
//The mount policy exists
mountPolicy = *repackMountPolicyItor;
} else {
//The mount policy does not exist, throw a user error
throw cta::exception::UserError("The mount policy name provided does not match any existing mount policy.");
}
}
auto mountPolicyProvidedByUser = getRequired(OptionString::MOUNT_POLICY);
//Get the mountpolicy from the catalogue
common::dataStructures::MountPolicy mountPolicy;
typedef std::list<common::dataStructures::MountPolicy> MountPolicyList;
MountPolicyList mountPolicies = m_catalogue.getMountPolicies();
MountPolicyList::const_iterator repackMountPolicyItor = std::find_if(mountPolicies.begin(),mountPolicies.end(),[mountPolicyProvidedByUser](const common::dataStructures::MountPolicy & mp){
return mp.name == mountPolicyProvidedByUser;
});
if(repackMountPolicyItor != mountPolicies.end()){
//The mount policy exists
mountPolicy = *repackMountPolicyItor;
} else {
//The mount policy does not exist, throw a user error
throw cta::exception::UserError("The mount policy name provided does not match any existing mount policy.");
}
// Expand, repack, or both ?
cta::common::dataStructures::RepackInfo::Type type;
auto buff = getOptional(OptionString::BUFFERURL);
if (buff){
//The buffer is provided by the user
bufferURL = buff.value();
} else {
//Buffer is not provided by the user, try to get the one from the configuration file
if(m_repackBufferURL){
bufferURL = m_repackBufferURL.value();
} else {
//Buffer is neither provided by the user, neither provided by the frontend configuration file, exception
throw cta::exception::UserError("Must specify the buffer URL using --bufferurl option or using the frontend configuration file.");
}
}
if(has_flag(OptionBoolean::JUSTADDCOPIES) && has_flag(OptionBoolean::JUSTMOVE)) {
throw cta::exception::UserError("--justaddcopies and --justmove are mutually exclusive");
} else if(has_flag(OptionBoolean::JUSTADDCOPIES)) {
type = cta::common::dataStructures::RepackInfo::Type::AddCopiesOnly;
} else if(has_flag(OptionBoolean::JUSTMOVE)) {
type = cta::common::dataStructures::RepackInfo::Type::MoveOnly;
} else {
type = cta::common::dataStructures::RepackInfo::Type::MoveAndAddCopies;
}
bool forceDisabledTape = has_flag(OptionBoolean::DISABLED);
// Expand, repack, or both ?
cta::common::dataStructures::RepackInfo::Type type;
// Process each item in the list
for(auto it = vid_list.begin(); it != vid_list.end(); ++it) {
m_scheduler.queueRepack(m_cliIdentity, *it, bufferURL, type, mountPolicy, forceDisabledTape, m_lc);
}
if(has_flag(OptionBoolean::JUSTADDCOPIES) && has_flag(OptionBoolean::JUSTMOVE)) {
throw cta::exception::UserError("--justaddcopies and --justmove are mutually exclusive");
} else if(has_flag(OptionBoolean::JUSTADDCOPIES)) {
type = cta::common::dataStructures::RepackInfo::Type::AddCopiesOnly;
} else if(has_flag(OptionBoolean::JUSTMOVE)) {
type = cta::common::dataStructures::RepackInfo::Type::MoveOnly;
} else {
type = cta::common::dataStructures::RepackInfo::Type::MoveAndAddCopies;
}
response.set_type(cta::xrd::Response::RSP_SUCCESS);
bool forceDisabledTape = has_flag(OptionBoolean::DISABLED);
// Process each item in the list
for(auto it = vid_list.begin(); it != vid_list.end(); ++it) {
m_scheduler.queueRepack(m_cliIdentity, *it, bufferURL, type, mountPolicy, forceDisabledTape, m_lc);
}
response.set_type(cta::xrd::Response::RSP_SUCCESS);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment