Skip to content

Commit

Permalink
Add retry for pv creation commands
Browse files Browse the repository at this point in the history
This patch will fix following error from CI
```
./openshift-clients/linux/oc create -f -
error: error when creating "STDIN": Post "https://api.crc.testing:6443/api/v1/persistentvolumes?fieldManager=kubectl-create": dial tcp 192.168.126.11:6443: connect: connection refused
```
  • Loading branch information
praveenkumar committed Aug 2, 2021
1 parent fb6fdcc commit 2ef149a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ yq
openshift-clients/
podman-remote/
.sw[a-p]
tmp_pv.yaml
9 changes: 5 additions & 4 deletions snc-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,20 @@ function create_pvs() {

for pvname in $(seq -f "pv%04g" 1 ${count}); do
if ! ${OC} get pv "${pvname}" &> /dev/null; then
generate_pv "${pvdir}/${pvname}" "${pvname}" | ${OC} create -f -
generate_pv "${pvdir}/${pvname}" "${pvname}" > tmp_pv.yaml
retry ${OC} create -f tmp_pv.yaml
else
echo "persistentvolume ${pvname} already exists"
fi
done

# Apply registry pvc to bound with pv0001
${OC} apply -f registry_pvc.yaml
retry ${OC} apply -f registry_pvc.yaml

# Add registry storage to pvc
${OC} patch config.imageregistry.operator.openshift.io/cluster --patch='[{"op": "add", "path": "/spec/storage/pvc", "value": {"claim": "crc-image-registry-storage"}}]' --type=json
retry ${OC} patch config.imageregistry.operator.openshift.io/cluster --patch='[{"op": "add", "path": "/spec/storage/pvc", "value": {"claim": "crc-image-registry-storage"}}]' --type=json
# Remove emptyDir as storage for registry
${OC} patch config.imageregistry.operator.openshift.io/cluster --patch='[{"op": "remove", "path": "/spec/storage/emptyDir"}]' --type=json
retry ${OC} patch config.imageregistry.operator.openshift.io/cluster --patch='[{"op": "remove", "path": "/spec/storage/emptyDir"}]' --type=json
}

# This follows https://blog.openshift.com/enabling-openshift-4-clusters-to-stop-and-resume-cluster-vms/
Expand Down

0 comments on commit 2ef149a

Please sign in to comment.