Skip to content

Commit 2ef149a

Browse files
committed
Add retry for pv creation commands
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 ```
1 parent fb6fdcc commit 2ef149a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ yq
99
openshift-clients/
1010
podman-remote/
1111
.sw[a-p]
12+
tmp_pv.yaml

Diff for: snc-library.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,20 @@ function create_pvs() {
170170

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

179180
# Apply registry pvc to bound with pv0001
180-
${OC} apply -f registry_pvc.yaml
181+
retry ${OC} apply -f registry_pvc.yaml
181182

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

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

0 commit comments

Comments
 (0)