Skip to content

Commit

Permalink
Replace customize-vm service with boot script
Browse files Browse the repository at this point in the history
Currently the VM guests are configured on a service added on the
customize-vm script created in the image building process.
There is no real need for the script to run on that context, and it is
easier to manage if it runs as part of the cloud-init context.
This commits:
- Runs the boot script on the cloud-init context.
- Removes it from the images customize-vm scripts.

Signed-off-by: Ram Lavi <ralavi@redhat.com>
  • Loading branch information
RamLavi committed Mar 28, 2024
1 parent ea73b86 commit 0095444
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 76 deletions.
1 change: 1 addition & 0 deletions pkg/internal/checkup/checkup.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func realtimeVMIBootCommands(configDiskSerial string) []string {
fmt.Sprintf("mount /dev/$(lsblk --nodeps -no name,serial | grep %s | cut -f1 -d' ') %s", configDiskSerial, configMountDirectory),
fmt.Sprintf("cp %s %s", path.Join(configMountDirectory, config.BootScriptName), config.BootScriptBinDirectory),
fmt.Sprintf("chmod 744 %s", path.Join(config.BootScriptBinDirectory, config.BootScriptName)),
path.Join(config.BootScriptBinDirectory, config.BootScriptName),
}
}

Expand Down
76 changes: 0 additions & 76 deletions vms/vm-under-test/scripts/customize-vm
Original file line number Diff line number Diff line change
Expand Up @@ -39,82 +39,6 @@ disable_swap() {
sed -i '/swap/s/^/#/' /etc/fstab
}

# Create and enable the boot checkup service
setup_boot_service() {
local service_name="realtime-checkup-boot.service"
local checkup_boot_script_full_path="/usr/bin/realtime-checkup-boot.sh"
local checkup_boot_service_full_path="/usr/lib/systemd/system/$service_name"

setup_checkup_boot_script "$checkup_boot_script_full_path"

cat <<EOF > "$checkup_boot_service_full_path"
[Unit]
Description=Checkup Boot Script
Before=qemu-guest-agent.service
[Service]
Type=oneshot
ExecStart=$checkup_boot_script_full_path
Restart=no
User=root
Group=root
[Install]
WantedBy=multi-user.target
Wants=first-boot-complete.target
EOF

systemctl enable "$checkup_boot_service_full_path"
systemctl start "$checkup_boot_service_full_path"
}

setup_checkup_boot_script() {
local checkup_boot_script_full_path=$1
cat <<'EOF' > "$checkup_boot_script_full_path"
#!/usr/bin/env bash
#
# This file is part of the kiagnose project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2024 Red Hat, Inc.
#
set -x
checkup_tuned_adm_set_marker_full_path="/var/realtime-checkup-tuned-adm-set-marker"
if systemctl --type swap list-units | grep -q '.swap'; then
systemctl mask "$(systemctl --type swap list-units | grep '.swap' | awk '{print $1}')"
fi
if [ ! -f "$checkup_tuned_adm_set_marker_full_path" ]; then
tuned_conf="/etc/tuned/realtime-virtual-guest-variables.conf"
echo "isolated_cores=2-3" > "$tuned_conf"
echo "isolate_managed_irq=Y" >> "$tuned_conf"
tuned-adm profile realtime-virtual-guest
touch $checkup_tuned_adm_set_marker_full_path
reboot
exit 0
fi
boot_script_readiness_marker_full_path="/tmp/realtime-checkup-ready-marker"
touch $boot_script_readiness_marker_full_path
EOF

chmod +x "$checkup_boot_script_full_path"
}

disable_services
install_packages
disable_swap
setup_boot_service

0 comments on commit 0095444

Please sign in to comment.