scripts/update-guardian-set: move new-guardianset.prototxt to /tmp/

before it created it in the current folder, causing Tilt to reload resources and ultimately failing ci tests
This commit is contained in:
tbjump 2023-06-07 17:14:11 +00:00 committed by tbjump
parent 2e6001b47a
commit a77fb68c78
1 changed files with 16 additions and 10 deletions

View File

@ -16,11 +16,12 @@ namespace=$3
echo "namespace ${namespace}" echo "namespace ${namespace}"
# file & path to save governance VAA # file & path to save governance VAA
fileName=new-guardianset.prototxt tmpFile=$(mktemp -q)
localPath=./scripts/$fileName if [ $? -ne 0 ]; then
containerPath=/tmp/$fileName echo "$0: Can't create temp file, bye.."
echo "localPath: ${localPath}" exit 1
echo "containerPath: ${containerPath}" fi
trap 'rm -f -- "$tmpFile"' EXIT
# the admin socket of the devnet guardians. used for executing commands in guardian pods. # the admin socket of the devnet guardians. used for executing commands in guardian pods.
sock=/tmp/admin.sock sock=/tmp/admin.sock
@ -43,7 +44,7 @@ if [ ${currentNumGuardians} == ${newNumGuardians} ]; then
fi fi
echo "creating guardian set update governance message template prototext" echo "creating guardian set update governance message template prototext"
minikube kubectl -- exec -n ${namespace} guardian-0 -c guardiand -- /guardiand template guardian-set-update --num=${newNumGuardians} --idx=${currentIndex} > ${localPath} minikube kubectl -- exec -n ${namespace} guardian-0 -c guardiand -- /guardiand template guardian-set-update --num=${newNumGuardians} --idx=${currentIndex} > ${tmpFile}
# for i in $(seq ${newNumGuardians}) # for i in $(seq ${newNumGuardians})
for i in $(seq ${currentNumGuardians}) for i in $(seq ${currentNumGuardians})
@ -53,10 +54,10 @@ do
# create the governance guardian set update prototxt file in the container # create the governance guardian set update prototxt file in the container
echo "created governance file for guardian-${guardianIndex}" echo "created governance file for guardian-${guardianIndex}"
minikube kubectl -- cp ${localPath} ${namespace}/guardian-${guardianIndex}:${containerPath} -c guardiand minikube kubectl -- cp ${tmpFile} ${namespace}/guardian-${guardianIndex}:${tmpFile} -c guardiand
# inject the guardian set update # inject the guardian set update
minikube kubectl -- exec -n ${namespace} guardian-${guardianIndex} -c guardiand -- /guardiand admin governance-vaa-inject --socket $sock $containerPath minikube kubectl -- exec -n ${namespace} guardian-${guardianIndex} -c guardiand -- /guardiand admin governance-vaa-inject --socket $sock $tmpFile
echo "injected governance VAA for guardian-${guardianIndex}" echo "injected governance VAA for guardian-${guardianIndex}"
done done
@ -73,8 +74,8 @@ function get_sequence_from_prototext {
fi fi
done < "$path" done < "$path"
} }
sequence=$(get_sequence_from_prototext ${localPath}) sequence=$(get_sequence_from_prototext ${tmpFile})
echo "got sequence: ${sequence} from ${localPath}" echo "got sequence: ${sequence} from ${tmpFile}"
# get vaa # get vaa
governanceChain="1" governanceChain="1"
@ -118,3 +119,8 @@ else
fi fi
echo "update-guardian-set.sh succeeded." echo "update-guardian-set.sh succeeded."
# clean up logic
rm -f -- "$tmpFile"
trap - EXIT
exit