Skip to content

Commit 4e784d4

Browse files
committed
move commands into an until loop
Signed-off-by: Oleg S <[email protected]>
1 parent baaa95f commit 4e784d4

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

test-kuttl/e2e-copy/private-network/10-test-data-creation.sh

+19-6
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,36 @@ main() {
4545

4646
# this fails
4747
echo "grabbing the content ID"
48-
myCID=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi; ipfs-cluster-ctl add /tmp/testfile.txt' | awk '{print $2}')
48+
myCID=""
49+
until [[ -n $myCID ]]; do
50+
myCID=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi; ipfs-cluster-ctl add /tmp/testfile.txt' | awk '{print $2}') || true
51+
[[ -z $myCID ]] && sleep 5
52+
echo "trying again"
53+
done
4954
echo "content ID is: ${myCID}"
55+
56+
# myCID=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi; ipfs-cluster-ctl add /tmp/testfile.txt' | awk '{print $2}')
5057

5158
# read the value
5259
echo "getting the other ipfs cluster podname"
5360
ipfsClusterPodname2=$(kubectl get pod -n "${NAMESPACE}" -l "${labelName}=${labelValue}" -o jsonpath='{.items[1].metadata.name}')
5461

5562
# delete the lockfile if it exists
5663
echo "deleting the other lockfile now"
57-
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs-cluster -- sh -c 'if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi'
58-
echo "checking to see if lockfile still exists"
59-
results=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs-cluster -- sh -c 'ls -al /data/ipfs' | grep 'repo.lock')
60-
echo "lockfile: ${results}"
64+
# kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs-cluster -- sh -c 'if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi'
65+
# echo "checking to see if lockfile still exists"
66+
# results=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs-cluster -- sh -c 'ls -al /data/ipfs' | grep 'repo.lock')
67+
# echo "lockfile: ${results}"
6168

6269
ipfsCommand="if [ -e /data/ipfs/repo.lock ]; then rm /data/ipfs/repo.lock; fi; ipfs get --output /tmp/myfile.txt -- ${myCID}"
70+
6371
echo "reading a file from ${ipfsClusterPodname2} using command: '${ipfsCommand}'"
64-
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs -- sh -c "${ipfsCommand}"
72+
until kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs -- sh -c "${ipfsCommand}"; do
73+
echo "failed, sleeping..."
74+
sleep 5
75+
done
76+
77+
# kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs -- sh -c "${ipfsCommand}"
6578
echo "success!"
6679
}
6780

0 commit comments

Comments
 (0)