Skip to content

How to Fix a Failed PV in OpenShift Cluster

Avatar photo

https://www.linkedin.com/in/gineesh/ https://twitter.com/GiniGangadharan

Image : https://premierevanlines.com

There are several cases a PV (PersistentVolume) appear as Failed in OpenShift or Kubernetes cluster. Once of the reason is wrong ClaimRef by which PV will mark as claimed but actually not in use. Let’s see one example.

# oc get pv |grep lv-1g-110
lv-1g-110 1Gi RWO,ROX,RWX Recycle Failed newproject/postgresql-test-dep 26d

From above snippet we can understand that, the PV lv-1g-110 is claimed by a PVC (PersistentVolumeClaim) named postgresql-test-dep and this is under projectย newproject. So let us check that PVC details.

# oc get pvc -n newproject | grep postgresql-test-dep
# oc get pvc -n newproject | grep lv-1g-110
#

Aah ! now we got confused; there is no such PVC called postgresql-test-dep or anything with lv-1g-110. Means, lv-1g-110 is stuck with some wrong claim. Let us see what is holding inside PV config.

# oc describe pv lv-1g-110 |grep Claim
Claim: newproject/postgresql-test-de

No wonder, we can see the PV got a ClaimRef for a PVC which doesn’t exist at all ! Let’s remove this.

Method 1 : Using oc edit

oc edit and remove those ClaimRef lines.

# oc edit pv lv-1g-110

Then remove below lines and save it.

claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: postgresql-test-de
namespace: newproject
resourceVersion: "569221692"
uid: 44aa4a1a-e3fd-11e8-83ad-65efe91e200

Method 2 : Using oc patch

# oc patch pv/lv-1g-110 --type json -p '[{ "op": "remove", "path": "/spec/claimRef" }]'

Now we check the pv status.

# oc get pv |grep lv-5g-293
lv-1g-110 1Gi RWO,ROX,RWX Recycle Available 8

That’s all; our pv is Available for next claim.

Disclaimer:

The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Avatar photo


https://www.linkedin.com/in/gineesh/ https://twitter.com/GiniGangadharan
Gineesh Madapparambath is the founder of techbeatly and he is the author of the book - ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—น-๐—Ÿ๐—ถ๐—ณ๐—ฒ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan - iamgini.com)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.