Skip to content

Commit

Permalink
Refactor expand disk commands
Browse files Browse the repository at this point in the history
  • Loading branch information
haijianyang committed Apr 22, 2024
1 parent 5417cc1 commit a54b5c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions pkg/hostagent/tasks/expand_root_partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
tasks:
- name: Get root path
shell: |
ostype=$(cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2)
. /etc/os-release
rootpath="/dev/mapper/rl-root"
if [[ $ostype == '"openEuler"' ]]; then
if [[ $ID == 'openEuler' ]]; then
rootpath="/dev/mapper/openeuler-root"
fi
echo $rootpath
Expand All @@ -28,7 +28,7 @@
shell: pvresize /dev/vda2
- name: Extend root
shell: |
result=$(lvextend -l+100%FREE -n {{ rootpath.stdout }} 2>&1)
result=$(lvextend -r -l+100%FREE -n {{ rootpath.stdout }} 2>&1)
if [[ $? == 0 ]]; then
echo "$result"
elif [[ $result == *'matches existing size'* ]]; then
Expand All @@ -37,5 +37,3 @@
echo "$result"
exit 1
fi
- name: Resize root
shell: resize2fs {{ rootpath.stdout }}
10 changes: 4 additions & 6 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ spec:
#! to the system disk through Tower API. These commands will add the new
#! capacity of the system disk to the root partition.
#! - |
#! ostype=$(cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2)
#! . /etc/os-release
#! rootpath="/dev/mapper/rl-root"
#! if [[ $ostype == '"openEuler"' ]]; then
#! if [[ $ID == 'openEuler' ]]; then
#! rootpath="/dev/mapper/openeuler-root"
#! fi
#! - |
Expand All @@ -130,7 +130,6 @@ spec:
#! echo "$result"
#! exit 1
#! fi
#! - "resize2fs $rootpath"
useExperimentalRetryJoin: true
files:
- content: |
Expand Down Expand Up @@ -286,9 +285,9 @@ spec:
#! to the system disk through Tower API. These commands will add the new
#! capacity of the system disk to the root partition.
#! - |
#! ostype=$(cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2)
#! . /etc/os-release
#! rootpath="/dev/mapper/rl-root"
#! if [[ $ostype == '"openEuler"' ]]; then
#! if [[ $ID == 'openEuler' ]]; then
#! rootpath="/dev/mapper/openeuler-root"
#! fi
#! - |
Expand All @@ -312,7 +311,6 @@ spec:
#! echo "$result"
#! exit 1
#! fi
#! - "resize2fs $rootpath"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ElfMachineTemplate
Expand Down

0 comments on commit a54b5c7

Please sign in to comment.