Skip to content

Commit

Permalink
change registryNamespace back to default on rollback (#1405)
Browse files Browse the repository at this point in the history
* change registryNamespace back to default on rollback

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

* make scripts executable by default

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

---------

Signed-off-by: Ben Luzarraga <[email protected]>
  • Loading branch information
bluzarraga authored Aug 3, 2023
1 parent c3bc8a1 commit f04e1bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions rollback-multi-instance.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function rollback() {
removeNSS
cleanupZenService
update_opreqs
un_isolate_odlm "ibm-odlm" $MASTER_NS
# scale back up
Expand Down Expand Up @@ -535,6 +536,34 @@ function cleanup_webhook() {

}

function update_opreqs(){
title "Updating Operand Requests to use Operand Registry in new CS namespace"
#check map to namespaces, get list of requested from ns from there
#update opreq in list of namespaces from common-service-maps configmap

#this command gets all of the ns listed in requested from namesapce fields
requested_ns=$("${OC}" get configmap -n kube-public -o yaml common-service-maps | yq '.data[]' | yq '.namespaceMapping[].requested-from-namespace' | awk '{print $2}' | tr '\n' ' ')

for ns in $requested_ns
do
opreqs=$(${OC} get operandrequests -n $ns --no-headers | awk '{print $1}' | tr '\n' ' ')
for opreq in $opreqs
do
${OC} get opreq $opreq -n $ns -o yaml > tmp.yaml
${YQ} -i 'del(.metadata.creationTimestamp)' tmp.yaml
${YQ} -i 'del(.metadata.resourceVersion)' tmp.yaml
${YQ} -i 'del(.metadata.uid)' tmp.yaml
${YQ} -i 'del(.metadata.generation)' tmp.yaml
${YQ} -i 'del(.metadata.managedFields)' tmp.yaml
${YQ} -i '.spec.requests[0].registryNamespace = "ibm-common-services"' tmp.yaml
${OC} apply -n $ns -f tmp.yaml || error "Failed to update registryNamespace value for operand request $opreq in namespace $ns."
info "Operand request $opreq in namespace $ns updated to use ibm-common-services as registryNamespace."
rm -f tmp.yaml
done
done
success "Operand requests' registryNamespace values updated."
}

function msg() {
printf '%b\n' "$1"
}
Expand Down
Empty file modified uninstall-dedicated-cs-instance.sh
100644 → 100755
Empty file.

0 comments on commit f04e1bd

Please sign in to comment.