From 318237a7243177dbd14e4238f369e122edb66a80 Mon Sep 17 00:00:00 2001 From: Julien Leduc <julien.leduc@cern.ch> Date: Tue, 7 Feb 2017 12:24:47 +0100 Subject: [PATCH] Cleaning up run scripts for containers: going along Dockerfile and in /opt/run/bin: /shared still available for local scripts developments. --- .../docker/ctafrontend/cc7/Dockerfile | 4 +- .../cc7/opt/run/bin/ctafrontend.sh | 4 +- .../ctafrontend/cc7/opt/run/bin/init.sh | 6 +- .../ctafrontend/cc7/opt/run/bin/rmcd.sh | 4 +- .../ctafrontend/cc7/opt/run/bin/taped.sh | 8 +- .../orchestration/pods/init/cli.sh | 10 -- .../orchestration/pods/init/ctafrontend.sh | 11 -- .../orchestration/pods/init/init.sh | 39 ------- .../orchestration/pods/init/init_pod.sh | 9 -- .../orchestration/pods/init/mgm.sh | 110 ------------------ .../orchestration/pods/init/rmcd.sh | 17 --- .../orchestration/pods/init/taped.sh | 34 ------ 12 files changed, 13 insertions(+), 243 deletions(-) delete mode 100755 continuousintegration/orchestration/pods/init/cli.sh delete mode 100755 continuousintegration/orchestration/pods/init/ctafrontend.sh delete mode 100755 continuousintegration/orchestration/pods/init/init.sh delete mode 100755 continuousintegration/orchestration/pods/init/init_pod.sh delete mode 100755 continuousintegration/orchestration/pods/init/mgm.sh delete mode 100755 continuousintegration/orchestration/pods/init/rmcd.sh delete mode 100755 continuousintegration/orchestration/pods/init/taped.sh diff --git a/continuousintegration/docker/ctafrontend/cc7/Dockerfile b/continuousintegration/docker/ctafrontend/cc7/Dockerfile index 36e22f745d..b13dab49b2 100644 --- a/continuousintegration/docker/ctafrontend/cc7/Dockerfile +++ b/continuousintegration/docker/ctafrontend/cc7/Dockerfile @@ -58,8 +58,8 @@ RUN yum -y install cgdb less psmisc lynx strace ltrace cta-cli && yum clean all # Add pod specific configuration ADD ${BASEDIR}/config ${LOCALORCHESTRATIONDIR} -# Add orchestration init scripts locally -ADD ${ORCHESTRATIONDIR}/init ${LOCALORCHESTRATIONDIR} +# Add orchestration run scripts locally +ADD ${BASEDIR}/opt /opt # Docker image run setup ADD ${BASEDIR}/run.sh / diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctafrontend.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctafrontend.sh index 0d08a31277..f6defbcb9c 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctafrontend.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctafrontend.sh @@ -9,7 +9,7 @@ yum -y install cta-frontend cta-debuginfo cta-catalogueutils ceph-common yes | cp -r /opt/ci/ctafrontend/etc / -/shared/bin/init_objectstore.sh +/opt/run/bin/init_objectstore.sh . /tmp/objectstore-rc.sh echo "ObjectStore BackendPath $OBJECTSTOREURL" > /etc/cta/cta-frontend.conf @@ -17,7 +17,7 @@ echo "Catalogue NumberOfConnections 1" >>/etc/cta/cta-frontend.conf echo "Log URL file:/cta-frontend.log" >>/etc/cta/cta-frontend.conf -/shared/bin/init_database.sh +/opt/run/bin/init_database.sh . /tmp/database-rc.sh echo ${DATABASEURL} >/etc/cta/cta_catalogue_db.conf diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh index b16b50e57d..fb86543cc0 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh @@ -9,12 +9,12 @@ yum -y install cta-objectstore-tools cta-doc mt-st mtx lsscsi sg3_utils cta-cata yum clean packages echo "Using this configuration for library:" -/shared/bin/init_library.sh +/opt/run/bin/init_library.sh cat /tmp/library-rc.sh . /tmp/library-rc.sh echo "Creating objectstore" -/shared/bin/init_objectstore.sh +/opt/run/bin/init_objectstore.sh . /tmp/objectstore-rc.sh if [ "$OBJECTSTORETYPE" == "file" ]; then @@ -33,7 +33,7 @@ else fi echo "Creating DB" -/shared/bin/init_database.sh +/opt/run/bin/init_database.sh . /tmp/database-rc.sh if [ "$DATABASETYPE" == "sqlite" ]; then diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/rmcd.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/rmcd.sh index d425719f7a..fd2a78d7fd 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/rmcd.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/rmcd.sh @@ -7,11 +7,11 @@ yum-config-manager --enable castor # Install missing RPMs yum -y install mt-st mtx lsscsi sg3_utils cta-taped cta-debuginfo castor-rmc-server -/shared/bin/init_pod.sh +/opt/run/bin/init_pod.sh # source library configuration file echo "Using this configuration for library:" -/shared/bin/init_library.sh +/opt/run/bin/init_library.sh cat /tmp/library-rc.sh . /tmp/library-rc.sh diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh index f1914852d8..5424275d29 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh @@ -7,10 +7,10 @@ yum-config-manager --enable castor # Install missing RPMs yum -y install mt-st mtx lsscsi sg3_utils cta-taped cta-debuginfo castor-rmc-server ceph-common -/shared/bin/init_pod.sh +/opt/run/bin/init_pod.sh echo "Using this configuration for library:" -/shared/bin/init_library.sh +/opt/run/bin/init_library.sh cat /tmp/library-rc.sh . /tmp/library-rc.sh @@ -21,11 +21,11 @@ mkdir -p /etc/castor tpconfig="${DRIVENAMES[${driveslot}]} ${LIBRARYNAME} /dev/${DRIVEDEVICES[${driveslot}]} smc${driveslot}" -/shared/bin/init_objectstore.sh +/opt/run/bin/init_objectstore.sh . /tmp/objectstore-rc.sh echo "Configuring database" -/shared/bin/init_database.sh +/opt/run/bin/init_database.sh . /tmp/database-rc.sh echo ${DATABASEURL} >/etc/cta/cta_catalogue_db.conf diff --git a/continuousintegration/orchestration/pods/init/cli.sh b/continuousintegration/orchestration/pods/init/cli.sh deleted file mode 100755 index a827510a6b..0000000000 --- a/continuousintegration/orchestration/pods/init/cli.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -cat <<EOF > /etc/cta/cta-cli.conf -# The CTA frontend address in the form <FQDN>:<TCPPort> -# solved by kubernetes DNS server so KIS... -${frontend} -EOF - -# sleep forever but exit immediately when pod is deleted -exec /bin/bash -c "trap : TERM INT; sleep infinity & wait" diff --git a/continuousintegration/orchestration/pods/init/ctafrontend.sh b/continuousintegration/orchestration/pods/init/ctafrontend.sh deleted file mode 100755 index aa8496f9e0..0000000000 --- a/continuousintegration/orchestration/pods/init/ctafrontend.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -echo "ObjectStore BackendPath $objectstore" > /etc/cta/cta-frontend.conf -echo "Catalogue NumberOfConnections 1" >>/etc/cta/cta-frontend.conf - -echo ${catdb} >/etc/cta/cta_catalogue_db.conf - -useradd cta -# disable kerberos5 check for the admin privileges - sed -i -e "s/krb5/unix/" /usr/lib64/libXrdCtaOfs.so -runuser --shell='/bin/bash' --session-command='cd ~cta; xrootd -n cta -c /etc/xrootd/xrootd-cta.cfg -I v4' cta diff --git a/continuousintegration/orchestration/pods/init/init.sh b/continuousintegration/orchestration/pods/init/init.sh deleted file mode 100755 index f0f83377d1..0000000000 --- a/continuousintegration/orchestration/pods/init/init.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# copy library configuration from persistent volume to shared volume -mkdir -p /shared/${INSTANCE_NAME} -cp -f /library/config ${LIBRARY_CONFIG} - -echo "Using this configuration for library:" -cat ${LIBRARY_CONFIG} -. ${LIBRARY_CONFIG} - -rm -rf ${objectstore} -mkdir -p ${objectstore} - cta-objectstore-initialize ${objectstore} - chmod -R 777 ${objectstore} - -rm -rf ${catdbdir} -mkdir -p ${catdbdir} - sqlite3 ${catdbdir}/${catdbfile} < `rpm -ql cta-doc|grep sqlite` - chmod -R 777 ${catdbdir} - - -# library management -# BEWARE STORAGE SLOTS START @1 and DRIVE SLOTS START @0!! -echo "Labelling tapes using the first drive in ${LIBRARYNAME}: ${DRIVENAMES[0]} on /dev/${DRIVEDEVICES[0]}:" -for ((i=0; i<${#TAPES[@]}; i++)); do - vid=${TAPES[${i}]} - tapeslot=$((${i}+1)) # tape slot is 1 for tape[0] and so on... - - echo -n "${vid} in slot ${tapeslot} " - mtx -f /dev/${LIBRARYDEVICE} load ${tapeslot} 0 - cd /tmp - echo "VOL1${vid} CASTOR 3">label.file - dd if=label.file of=/dev/${DRIVEDEVICES[0]} bs=80 count=1 - mt -f /dev/${DRIVEDEVICES[0]} rewind - mtx -f /dev/${LIBRARYDEVICE} unload ${tapeslot} 0 - echo "OK" -done - -exit 0 diff --git a/continuousintegration/orchestration/pods/init/init_pod.sh b/continuousintegration/orchestration/pods/init/init_pod.sh deleted file mode 100755 index 24539f423d..0000000000 --- a/continuousintegration/orchestration/pods/init/init_pod.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -echo -n "Fixing reverse DNS for $(hostname): " -sed -i -c "s/^\($(hostname -i)\)\s\+.*$/\1 $(hostname -s).$(grep search /etc/resolv.conf | cut -d\ -f2) $(hostname -s)/" /etc/hosts -echo "DONE" - -echo -n "Yum should resolve names using IPv4 DNS: " -echo "ip_resolve=IPv4" >> /etc/yum.conf -echo "DONE" diff --git a/continuousintegration/orchestration/pods/init/mgm.sh b/continuousintegration/orchestration/pods/init/mgm.sh deleted file mode 100755 index 1d60f9bafa..0000000000 --- a/continuousintegration/orchestration/pods/init/mgm.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh - -# initialize pod -/shared/bin/init_pod.sh - -eoshost=`hostname -f` -eosInstanceName=`hostname -s` - -TAPE_FS_ID=65535 -CTA_BIN=/usr/bin/cta -CTA_KT=/etc/eoscta-cli.keytab -CTA_PROC_DIR=/eos/${eosInstanceName}/proc/cta -CTA_WF_DIR=${CTA_PROC_DIR}/workflow -CTA_TEST_DIR=/eos/${eosInstanceName}/cta - -# prepare CTA cli commands environment - echo ${frontend} > /etc/cta/cta-cli.conf - -# setup eos host and instance name - sed -i -e "s/DUMMY_HOST_TO_REPLACE/${eoshost}/" /etc/sysconfig/eos - sed -i -e "s/DUMMY_INSTANCE_TO_REPLACE/${eosInstanceName}/" /etc/sysconfig/eos - sed -i -e "s/DUMMY_HOST_TO_REPLACE/${eoshost}/" /etc/xrd.cf.mgm - sed -i -e "s/DUMMY_INSTANCE_TO_REPLACE/${eosInstanceName}/" /etc/xrd.cf.mgm - sed -i -e "s/DUMMY_HOST_TO_REPLACE/${eoshost}/" /etc/xrd.cf.mq - sed -i -e "s/DUMMY_HOST_TO_REPLACE/${eoshost}/" /etc/xrd.cf.fst - -# prepare eos startup - # skip systemd for eos initscripts - export SYSTEMCTL_SKIP_REDIRECT=1 - echo y | xrdsssadmin -k ${eosInstanceName} -u daemon -g daemon add /etc/eos.keytab - chmod 400 /etc/eos.keytab - chown daemon:daemon /etc/eos.keytab - mkdir -p /run/lock/subsys - mkdir -p /var/eos/config/${eoshost} - chown daemon:root /var/eos/config/${eoshost} - touch /var/eos/config/${eoshost}/default.eoscf - chown daemon:daemon /var/eos/config/${eoshost}/default.eoscf - - #/etc/init.d/eos master mgm - #/etc/init.d/eos master mq - touch /var/eos/eos.mq.master - touch /var/eos/eos.mgm.rw - echo "Configured mq mgm on localhost as master" - - source /etc/sysconfig/eos - - mkdir -p /fst - chown daemon:daemon /fst/ - -# start and setup eos for xrdcp to the ${CTA_TEST_DIR} - #/etc/init.d/eos start - /usr/bin/xrootd -n mq -c /etc/xrd.cf.mq -l /var/log/eos/xrdlog.mq -b -Rdaemon - /usr/bin/xrootd -n mgm -c /etc/xrd.cf.mgm -m -l /var/log/eos/xrdlog.mgm -b -Rdaemon - /usr/bin/xrootd -n fst -c /etc/xrd.cf.fst -l /var/log/eos/xrdlog.fst -b -Rdaemon - - eos vid enable sss - eos vid enable unix - EOS_MGM_URL="root://${eoshost}" eosfstregister -r /fst default:1 - - eos node set ${eoshost} on - eos space set default on - eos attr -r set default=replica /eos - eos attr -r set sys.forced.nstripes=1 /eos - - eos fs add -m ${TAPE_FS_ID} tape localhost:1234 /does_not_exist tape - eos mkdir ${CTA_PROC_DIR} - eos mkdir ${CTA_WF_DIR} - eos attr set CTA_TapeFsId=${TAPE_FS_ID} ${CTA_WF_DIR} - - eos mkdir ${CTA_TEST_DIR} - eos chmod 777 ${CTA_TEST_DIR} - eos attr set CTA_StorageClass=ctaStorageClass ${CTA_TEST_DIR} - - # hack before it is fixed in EOS - TAPE_FS_ID_TOSET=`eos attr ls ${CTA_WF_DIR} | grep CTA_TapeFsId= | tr '"' ' ' | cut -d ' ' -f 2` - eos attr set CTA_TapeFsId=${TAPE_FS_ID_TOSET} ${CTA_TEST_DIR} - - # Link the attributes of CTA worklow directory to the test directory - eos attr link ${CTA_WF_DIR} ${CTA_TEST_DIR} - -# test EOS -# eos slow behind us and we need to give it time to be ready -# 5 secs is not enough - sleep 10 - eos -b node ls - xrdcp /etc/group root://${eoshost}:/${CTA_TEST_DIR}/testFile - -# prepare EOS workflow - eos space config default space.wfe=on - - # ATTENTION - # for sss authorisation unix has to be replaced by sss - - # Set the worfklow rule for archiving files to tape - eos attr set sys.workflow.closew.default="bash:shell:cta XrdSecPROTOCOL=unix XrdSecSSSKT=${CTA_KT} ${CTA_BIN} archive --user <eos::wfe::rusername> --group <eos::wfe::rgroupname> --diskid <eos::wfe::fid> --instance eoscta --srcurl <eos::wfe::turl> --size <eos::wfe::size> --checksumtype <eos::wfe::checksumtype> --checksumvalue <eos::wfe::checksum> --storageclass <eos::wfe::cxattr:CTA_StorageClass> --diskfilepath <eos::wfe::path> --diskfileowner <eos::wfe::username> --diskfilegroup <eos::wfe::groupname> --recoveryblob:base64 <eos::wfe::base64:metadata> --diskpool default --throughput 10000 --stderr" ${CTA_WF_DIR} - # Set the worflow rule for creating tape file replicas in the EOS namespace - eos attr set sys.workflow.archived.default="bash:shell:cta eos file tag <eos::wfe::path> +<eos::wfe::cxattr:CTA_TapeFsId>" ${CTA_WF_DIR} - # Set the worfklow rule for retrieving file from tape - eos attr set sys.workflow.prepare.default="bash:shell:cta XrdSecPROTOCOL=unix XrdSecSSSKT=${CTA_KT} ${CTA_BIN} retrieve --user <eos::wfe::rusername> --group <eos::wfe::rgroupname> --id <eos::wfe::fxattr:sys.archiveFileId> --dsturl '<eos::wfe::turl>\&eos.injection=1\&eos.workflow=CTA_retrieve' --diskfilepath <eos::wfe::path> --diskfileowner <eos::wfe::username> --diskfilegroup <eos::wfe::groupname> --recoveryblob:base64 <eos::wfe::base64:metadata> --diskpool default --throughput 10001 --stderr" ${CTA_WF_DIR} - # Set the workflow rule for the closew event of the CTA_retrieve workflow. - # Using the CTA_retrieve workflow will prevent the default workflow from - # receiving the closew event. Triggering the default workflow in this way would - # haved causes the unwanted action of copying the disk file to tape again. - # The action of the CTA_retrieve workflow when triggered by the closew event is - # to set the CTA_retrieved_timestamp attribute. - eos attr set sys.workflow.closew.CTA_retrieve="bash:shell:cta eos attr set 'CTA_retrieved_timestamp=\"\`date\`\"' <eos::wfe::path>" ${CTA_WF_DIR} - -touch /shared/${INSTANCE_NAME}/mgm_ready - -/bin/bash diff --git a/continuousintegration/orchestration/pods/init/rmcd.sh b/continuousintegration/orchestration/pods/init/rmcd.sh deleted file mode 100755 index 550e364c19..0000000000 --- a/continuousintegration/orchestration/pods/init/rmcd.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -/shared/bin/init_pod.sh - -# source library configuration file -echo "Using this configuration for library:" -cat ${LIBRARY_CONFIG} - -. ${LIBRARY_CONFIG} - -# to get rmcd logs to stdout -mkfifo /var/log/castor/rmcd_legacy.log -for ((;;)); do cat </var/log/castor/rmcd_legacy.log; done & -disown - -ln -s /dev/${LIBRARYDEVICE} /dev/smc -/usr/bin/rmcd -f /dev/smc diff --git a/continuousintegration/orchestration/pods/init/taped.sh b/continuousintegration/orchestration/pods/init/taped.sh deleted file mode 100755 index df4160acae..0000000000 --- a/continuousintegration/orchestration/pods/init/taped.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -/shared/bin/init_pod.sh - -# source library configuration file -echo "Using this configuration for library:" -cat ${LIBRARY_CONFIG} - -. ${LIBRARY_CONFIG} - - -ln -s /dev/${LIBRARYDEVICE} /dev/smc -#/usr/bin/rmcd -f /dev/smc& - -mkdir -p /etc/castor - -tpconfig="${DRIVENAMES[${driveslot}]} ${LIBRARYNAME} /dev/${DRIVEDEVICES[${driveslot}]} smc0" - -# cta-tapserverd setup -# to be drop later - echo "${tpconfig}" > /etc/castor/TPCONFIG - echo "TapeServer ObjectStoreBackendPath $objectstore" >/etc/castor/castor.conf - echo "TapeServer BufSize 5242880" >>/etc/castor/castor.conf - echo "TapeServer NbBufs 10" >>/etc/castor/castor.conf - echo "TapeServer EOSRemoteHostAndPort ${eoshost}" >>/etc/castor/castor.conf - -# cta-taped setup - echo "taped BufferCount 10" > /etc/cta/cta.conf - echo "general ObjectStoreURL ${objectstore}" >> /etc/cta/cta.conf - echo "${tpconfig}" > /etc/cta/TPCONFIG - -echo ${catdb} >/etc/cta/cta_catalogue_db.conf - -/bin/cta-taped --stdout --foreground -- GitLab