Skip to content

Commit

Permalink
Rerun preload (#2127)
Browse files Browse the repository at this point in the history
* add rerun parameter

Signed-off-by: Ben Luzarraga <[email protected]>

* update logging, add ignore not found

Signed-off-by: Ben Luzarraga <[email protected]>

* update logging

Signed-off-by: Ben Luzarraga <[email protected]>

* remove ignore not found for patch commands

Signed-off-by: Ben Luzarraga <[email protected]>

* error handle

Signed-off-by: Ben Luzarraga <[email protected]>

* change cleanup success log

Signed-off-by: Ben Luzarraga <[email protected]>

---------

Signed-off-by: Ben Luzarraga <[email protected]>
  • Loading branch information
bluzarraga authored Aug 2, 2024
1 parent 808ff0c commit c6a3189
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions preload_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function main() {
trap cleanup_log EXIT
prereq
if [[ $RERUN == "true" ]]; then
info "Rerun specified..."
deletemongocopy
fi
# run backup preload
Expand Down Expand Up @@ -1902,25 +1903,24 @@ function deletemongocopy {
${OC} delete cm namespace-scope --ignore-not-found

#delete mongodump pvc and pv
VOL=$(${OC} get pvc cs-mongodump -o=jsonpath='{.spec.volumeName}')
VOL=$(${OC} get pvc cs-mongodump -o=jsonpath='{.spec.volumeName}' --ignore-not-found)
if [[ -z "$VOL" ]]; then
error "Volume for pvc cs-mongodump not found in $TO_NAMESPACE"
fi

${OC} patch pv $VOL -p '{"spec": { "persistentVolumeReclaimPolicy" : "Delete" }}'

${OC} delete pvc cs-mongodump -n $TO_NAMESPACE --ignore-not-found --timeout=10s
if [ $? -ne 0 ]; then
info "Failed to delete pvc cs-mongodump, patching its finalizer to null..."
${OC} patch pvc cs-mongodump -n $TO_NAMESPACE --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
fi
${OC} delete pv $VOL --ignore-not-found --timeout=10s
if [ $? -ne 0 ]; then
info "Failed to delete pv $VOL, patching its finalizer to null..."
${OC} patch pv $VOL --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
warning "Volume for pvc cs-mongodump not found in $TO_NAMESPACE. It may have already been deleted."
else
${OC} patch pv $VOL -p '{"spec": { "persistentVolumeReclaimPolicy" : "Delete" }}'
${OC} delete pvc cs-mongodump -n $TO_NAMESPACE --ignore-not-found --timeout=10s
if [ $? -ne 0 ]; then
info "Failed to delete pvc cs-mongodump, patching its finalizer to null..."
${OC} patch pvc cs-mongodump -n $TO_NAMESPACE --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]' --ignore-not-found
fi
${OC} delete pv $VOL --ignore-not-found --timeout=10s
if [ $? -ne 0 ]; then
info "Failed to delete pv $VOL, patching its finalizer to null..."
${OC} patch pv $VOL --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
fi
fi

success "MongoDB restored to new namespace $TO_NAMESPACE"
success "MongoDB removed from services namespace $TO_NAMESPACE"

} # deletemongocopy

Expand Down

0 comments on commit c6a3189

Please sign in to comment.