diff --git a/examples/wordpress/pv-nfs-1.yaml b/examples/wordpress/pv-nfs-1.yaml index 2bbf833b1c23..60d59a28cbec 100644 --- a/examples/wordpress/pv-nfs-1.yaml +++ b/examples/wordpress/pv-nfs-1.yaml @@ -8,6 +8,7 @@ spec: accessModes: - ReadWriteOnce - ReadWriteMany + persistentVolumeReclaimPolicy: Recycle nfs: server: localhost path: /home/data/pv0001 diff --git a/examples/wordpress/pv-nfs-2.yaml b/examples/wordpress/pv-nfs-2.yaml index 7b7b350f5b02..da1349f49b69 100644 --- a/examples/wordpress/pv-nfs-2.yaml +++ b/examples/wordpress/pv-nfs-2.yaml @@ -7,6 +7,7 @@ spec: storage: 5Gi accessModes: - ReadWriteOnce + persistentVolumeReclaimPolicy: Recycle nfs: server: localhost path: /home/data/pv0002 diff --git a/images/origin/scripts/recycler.sh b/images/origin/scripts/recycler.sh index 685fc673fef7..b799df6e9e30 100755 --- a/images/origin/scripts/recycler.sh +++ b/images/origin/scripts/recycler.sh @@ -1,43 +1,35 @@ #!/bin/bash -# 'recycle' performs an 'rm -rf' on a volume to scrub it clean before its reuse as a cluster resource. -# this script is intended to be used in a pod that performs the scrub. -# the container in the pod should succeed or fail based on the exit status of this script. - -set -o errexit -set -o nounset -set -o pipefail - -function recycle(){ - - # first and only arg is the directory to scrub - dir=$1 - - if [ -z "$dir" ]; then - echo "Usage: scrub_directory some/path/to/scrub" - return 1 - fi - - if [ ! -e $dir ]; then - echo "scrub directory $dir does not exist" - return 1 - fi - - # remove everything but keep the directory for re-use as a volume - rm -rfv $dir/* - - if [ -z "$(ls -A $dir)" ]; then - echo "scrub directory $dir is empty" - return 0 - else - echo "scrub directory $dir is not empty" - return 1 - fi -} - -if recycle $1; then - echo "Scrub OK" - exit 0 -else +# 'recycler' performs an 'rm -rf' on a volume to scrub it clean before it's +# reused as a cluster resource. This script is intended to be used in a pod that +# performs the scrub. The container in the pod should succeed or fail based on +# the exit status of this script. + +set -e -o pipefail + +shopt -s dotglob nullglob + +if [[ $# -ne 1 ]]; then + echo >&2 "Usage: $0 some/path/to/scrub" exit 1 fi + +# first and only arg is the directory to scrub +dir=$1 + +if [[ ! -d ${dir} ]]; then + echo >&2 "Error: scrub directory '${dir}' does not exist" + exit 1 +fi + +# shred all files +find ${dir} -type f -exec shred -fuvz {} \; + +# remove everything that was left, keeping the directory for re-use as a volume +if rm -rfv ${dir}/*; then + echo 'Scrub OK' + exit 0 +fi + +echo 'Scrub failed' +exit 1