Last active
November 15, 2023 14:14
-
-
Save kvaps/7ecfa5664c7588da53d2866e1549e2c2 to your computer and use it in GitHub Desktop.
LINSTOR fix wrong storage pool in version before 1.25 (error: Storage driver 'LVM_THIN' not allowed for volume.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make backup | |
kubectl get crds | grep -o ".*.internal.linstor.linbit.com" | xargs kubectl get crds -ojson > crds.json | |
kubectl get crds | grep -o ".*.internal.linstor.linbit.com" | xargs -i{} sh -xc "kubectl get {} -ojson > {}.json" | |
--- | |
# collect resources in weird states: | |
cat resources.internal.linstor.linbit.com.json | jq '.items[] | select(.spec.resource_flags>1024) | "\(.spec.resource_name) \(.spec.node_name) \(.spec.resource_flags)"' -r > list.txt | |
# reset them to 0: | |
while read res node flags; do cat resources.internal.linstor.linbit.com.json | jq '.items[] | select(.spec.resource_name==$res and .spec.node_name==$node) | .spec.resource_flags=0' --arg res $res --arg node $node -r ; done < list.txt > fix.json | |
kubectl delete -f fix.json | |
kubectl create -f fix.json | |
--- | |
# # collect all diskful resources according to flags (0 - means diskful) | |
# cat resources.internal.linstor.linbit.com.json | jq '.items[] | select(.spec.resource_flags==0) | "\(.spec.resource_name) \(.spec.node_name) \(.spec.resource_flags)"' -r > list.txt | |
# | |
# # collect ids of layervolumes from layers | |
# while read res node flags; do cat layerresourceids.internal.linstor.linbit.com.json | jq '.items[] | select(.spec.resource_name==$res and .spec.node_name==$node and .spec.layer_resource_kind=="STORAGE") | .spec.layer_resource_id' --arg res $res --arg node $node ; done < list.txt | sort -V > ids.txt | |
# | |
# # Prepare fix for layerstoragevolumes | |
# cat layerstoragevolumes.internal.linstor.linbit.com.json | jq '.items[]' -c | grep -E "\"layer_resource_id\":($(cat ids.txt | paste -s | sed 's/\t/\|/g'))" | grep DFLTDISKLESSSTORPOOL > fix.json | |
# | |
# sed -i 's|"provider_kind":"DISKLESS"|"provider_kind":"LVM_THIN"|g' fix.json | |
# sed -i 's|"stor_pool_name":"DFLTDISKLESSSTORPOOL"|"stor_pool_name":"THINDATA"|g' fix.json | |
# | |
# kubectl delete -f fix.json | |
# kubectl create -f fix.json | |
--- | |
# collect all diskful resources according to flags (0 - means diskful) | |
cat resources.internal.linstor.linbit.com.json | jq '.items[] | select(.spec.resource_flags==0) | "/RESOURCES/\(.spec.node_name)/\(.spec.resource_name)"' -r > list.txt | |
# prepare fix for propscontainers | |
cat propscontainers.internal.linstor.linbit.com.json | jq -c '.items[]' | grep "$(cat list.txt | paste -s -d',' | sed 's/,/\\|/g')" | grep DfltDisklessStorPool > fix2.json | |
sed -i 's/DfltDisklessStorPool/thindata/g' fix2.json | |
kubectl delete -f fix2.json | |
kubectl create -f fix2.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment