diff --git a/managed/node-agent/resources/node-agent-provision.yaml b/managed/node-agent/resources/node-agent-provision.yaml index 9c0b67b584e4..c8c93a921607 100644 --- a/managed/node-agent/resources/node-agent-provision.yaml +++ b/managed/node-agent/resources/node-agent-provision.yaml @@ -12,7 +12,6 @@ ynp: use_system_level_systemd: false ip_address: "127.0.0.1" tmp_directory: /tmp - mount_points: /data # Comma separated values. yba: url: @@ -32,3 +31,5 @@ yba: cores: cores memory_size: size volume_size: size + mount_points: + - /mnt/d1 diff --git a/managed/node-agent/resources/ynp/commands/provision_command.py b/managed/node-agent/resources/ynp/commands/provision_command.py index 3c8ae873e4a8..8cd23192950f 100644 --- a/managed/node-agent/resources/ynp/commands/provision_command.py +++ b/managed/node-agent/resources/ynp/commands/provision_command.py @@ -123,7 +123,6 @@ def _generate_template(self): context = self.config[key] context["templatedir"] = os.path.join(os.path.dirname(module[1]), "templates") - logger.info(context) module_instance = module[0]() rendered_template = module_instance.render_templates(context) if rendered_template is not None: diff --git a/managed/node-agent/resources/ynp/configs/config.j2 b/managed/node-agent/resources/ynp/configs/config.j2 index b93148165671..b70ec256f02e 100644 --- a/managed/node-agent/resources/ynp/configs/config.j2 +++ b/managed/node-agent/resources/ynp/configs/config.j2 @@ -32,7 +32,7 @@ nproc_limit = 12000 vm_swappiness = 0 kernel_core_pattern = {{ ynp.yb_home_dir }}/cores/core_%%p_%%t_%%E vm_max_map_count = 262144 -mount_points = {{ ynp.mount_points }} +mount_points = {{ yba.instance_type.mount_points | join(' ') }} [ConfigureOs.limits] core = unlimited @@ -71,5 +71,4 @@ ports = 7000 7100 9000 9100 18018 22 5433 9042 9070 9300 12000 13000 yb_user = yugabyte yb_home_dir = {{ ynp.yb_home_dir }} tmp_directory = {{ ynp.tmp_directory }} -mount_points = {{ ynp.mount_points }} diff --git a/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/precheck.j2 b/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/precheck.j2 index 128e5d9c618e..8896e04aa772 100644 --- a/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/precheck.j2 +++ b/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/precheck.j2 @@ -87,11 +87,12 @@ else add_result "kernel.core_pattern" "FAIL" "kernel.core_pattern is set to $kernel_core_pattern_value (expected: {{ kernel_core_pattern }})" fi +threshold=49 #Gigabytes mount_point_array={{ mount_points }} # Verify each mount point for mount_point in "${mount_point_array[@]}"; do if [ -d "$mount_point" ]; then - if [ -w "$mount_point" ] && [ "$(stat -c %A "$mount_point" | cut -c 10)" == "w" ]; then + if [ -w "$mount_point" ] && [ $(( $(stat -c %a "$mount_point") % 10 & 2 )) -ne 0 ]; then result="PASS" message="Directory $mount_point exists and is world-writable." echo "[PASS] $message" @@ -107,6 +108,19 @@ for mount_point in "${mount_point_array[@]}"; do echo "[FAIL] $message" any_fail=1 fi - add_result "$mount_point Check" "$result" "$message" + + # Get the available disk space in gigabytes. + free_space_gb=$(df -BG --output=avail "$MOUNT_POINT" | tail -n 1 | tr -d 'G ') + if [ "$free_space_gb" -gt "$threshold" ]; then + result="PASS" + message="Sufficient disk space available: ${AVAILABLE}G" + echo "[PASS] $message" + else + result="FAIL" + message="Insufficient disk space: ${AVAILABLE}G available, ${THRESHOLD}G required" + echo "[FAIL] $message" + any_fail=1 + fi + add_result "$mount_point Free space check" "$result" "$message" done diff --git a/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/run.j2 b/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/run.j2 index 50e94dbeb573..7cb60c58272c 100644 --- a/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/run.j2 +++ b/managed/node-agent/resources/ynp/modules/provision/configure_os/templates/run.j2 @@ -68,66 +68,4 @@ sysctl -w vm.max_map_count={{ vm_max_map_count }} echo "Kernel settings configured." - -echo "Mounting volumes." -# Excluding the known mounts that we have to avoid. -{% set excluded_mounts = ["/", "boot", "efi"] %} - -# Generate a unique backup filename for /etc/fstab -backup_file="/etc/fstab.bak.$(date +%s)" -cp /etc/fstab $backup_file -echo "Backup of /etc/fstab created at $backup_file." - -# Get list of available volumes excluding the root and specified excluded mounts -volumes=$(lsblk -lnpo NAME,MOUNTPOINT | awk '$2 == "" {print $1}' | grep -vE 'NAME|MOUNTPOINT') - -# Prepare and mount each volume -index=1 -for volume in $volumes; do - if [[ $volume =~ /dev/nvme[0-9]n[0-9]p[0-9]+ ]]; then - echo "Skipping volume $volume" - continue - fi - mount_point="/mnt/d${index}" - - mkdir -p ${mount_point} - - if mount | grep -qE "^${volume}|^${volume}[0-9]"; then - echo "${volume} or one of its partitions is currently mounted. Skipping..." - continue - fi - - # Check if filesystem already exists - if ! blkid ${volume} | grep -q "TYPE=\"xfs\""; then - mkfs -t xfs ${volume} - echo "Filesystem created on ${volume}." - else - echo "Filesystem already exists on ${volume}." - fi - - # Add entry to /etc/fstab if it doesn't already exist - if ! grep -q "^${volume}" /etc/fstab; then - echo "${volume} ${mount_point} xfs noatime 0 0" | tee -a /etc/fstab - else - echo "Entry for ${volume} already exists in /etc/fstab." - fi - - # Mount the volume if it's not already mounted - if ! mountpoint -q ${mount_point}; then - mount ${mount_point} || fail "Failed to mount ${volume} at ${mount_point}." - echo "Mounted ${volume} at ${mount_point}." - else - echo "${mount_point} is already mounted." - fi - - # Set ownership and permissions - chown yugabyte:yugabyte ${mount_point} || fail "Failed to set ownership for ${mount_point}." - chmod 755 ${mount_point} || fail "Failed to set permissions for ${mount_point}." - echo "Set ownership and permissions for ${mount_point}." - - index=$((index + 1)) -done - -echo "Volume mounting process completed." - echo "OS Configuration applied successfully."