Skip to content

Commit

Permalink
Enable LVM implmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
electrocucaracha committed Dec 13, 2024
1 parent ef28864 commit 8817ee8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
23 changes: 19 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,23 @@ Vagrant.configure("2") do |config|
chmod 600 ~/.ssh/authorized_keys
sudo sed -i '/^PermitRootLogin no/d' /etc/ssh/sshd_config
SHELL

# Define mount and/or volumes
volume_mounts_dict = ""
volume_groups_dict = Hash.new { |h, k| h[k] = [] }
if node.key? "volumes"
node["volumes"].each do |volume|
volume_mounts_dict += "#{volume['name']}=#{volume['mount']}," if volume.key? "mount"
if volume.key? "mount"
raise "`mount` and `volume_group` values have been provided for #{volume['name']} volume in #{node['name']} node, use only one of them." if volume.key? "volume_group"

volume_mounts_dict += "/dev/#{volume['name']}=#{volume['mount']},"
end
volume_groups_dict[volume["volume_group"]] << "/dev/#{volume['name']}" if volume.key? "volume_group"
end
end
vgs = ""
volume_groups_dict.each { |k, v| vgs += "#{k}=#{v.join(' ')}," }

# Setup QAT nodes
nodeconfig.vm.provision "shell", inline: <<-SHELL
source /etc/os-release || source /usr/lib/os-release
Expand Down Expand Up @@ -300,14 +311,18 @@ Vagrant.configure("2") do |config|
KRD_DEBUG: debug.to_s,
PKG_DEBUG: debug.to_s,
NODE_SRIOV_NUMVFS: node.fetch("sriov_numvfs", 0),
NODE_VOLUME: volume_mounts_dict[0...-1].to_s
NODE_VOLUME_MOUNTS: volume_mounts_dict[0...-1].to_s,
NODE_VOLUME_GROUPS: vgs[0...-1].to_s
}
sh.inline = <<-SHELL
set -o xtrace
cd /vagrant
cmd="./node.sh"
if [[ $NODE_VOLUME ]]; then
cmd+=" -v $NODE_VOLUME"
if [[ $NODE_VOLUME_MOUNTS ]]; then
cmd+=" -v $NODE_VOLUME_MOUNTS"
fi
if [[ $NODE_VOLUME_GROUPS ]]; then
cmd+=" -g $NODE_VOLUME_GROUPS"
fi
cmd+=" | tee ~/node.log"
eval $cmd
Expand Down
2 changes: 1 addition & 1 deletion ci/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if [[ ${TEST_MULTINODE:-false} == "false" ]]; then
device: 0
- name: sde
size: 20
mount: /mnt/disks/vol3
volume_group: myvg1
controller: ${VBOX_CONTROLLER:-Virtual I/O Device SCSI controller}
port: 4
device: 0
Expand Down
23 changes: 20 additions & 3 deletions node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ function usage {
cat <<EOF
usage: $0 [-v volumes]
Optional Argument:
-v List of key pair values for volumes and mount points ( e. g. sda=/var/lib/docker/,sdb=/var/lib/libvirt/ )
-v List of key pair values for volumes and mount points ( e. g. /dev/sda=/var/lib/docker/,/dev/sdb=/var/lib/libvirt/ )
-c List of key pair values for volumes groups and physical volumes ( e. g. vg1=/dev/sda /dev/sdb,vg2=/dev/sdc )
EOF
}

# mount_external_partition() - Create partition and mount the external volume
function mount_external_partition {
local dev_name="/dev/$1"
local dev_name=$1
local mount_dir=$2

sudo sfdisk "$dev_name" --no-reread <<EOF
Expand Down Expand Up @@ -167,6 +168,18 @@ function mount_partitions {
fi
}

# create_volume_groups() - Create Logical Volume groups
function create_volume_groups {
if [ -n "${dict_volumes_groups-}" ]; then
command -v vgs >/dev/null || curl -fsSL http://bit.ly/install_pkg | PKG="lvm2" bash
for kv in ${dict_volumes_groups//,/ }; do
eval "sudo vgcreate ${kv%=*} ${kv#*=} -f"
done
sudo vgs
sudo pvdisplay
fi
}

# disable_k8s_ports() - Disable FirewallD ports used by Kubernetes Kubelet
function disable_k8s_ports {
local kubelet_ports=(6443 10250 10259 10257)
Expand Down Expand Up @@ -251,11 +264,14 @@ function create_simulated_sriov_dev {
ip link show
}

while getopts "h?v:" opt; do
while getopts "h?v:g:" opt; do
case $opt in
v)
dict_volumes="$OPTARG"
;;
g)
dict_volumes_groups="$OPTARG"
;;
h | \?)
usage
exit
Expand All @@ -277,6 +293,7 @@ for kmod in rbd ip6table_filter; do
done
install_deps
mount_partitions
create_volume_groups
disable_k8s_ports
create_pmem_namespaces
enable_nvdimm_mixed_mode
Expand Down

0 comments on commit 8817ee8

Please sign in to comment.