mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
* Support for live patching systemVMs and deprecating systemVM.iso. Includes: - fix systemVM template version - Include agent.zip, cloud-scripts.tgz to the commons package - Support for live-patching systemVMs - CPVM, SSVM, Routers - Fix Unit test - Remove systemvm.iso dependency * The following commit: - refactors logic added to support SystemVM deployment on KVM - Adds support to copy specific files (required for patching) to the hosts on Xenserver - Modifies vmops method - createFileInDomr to take cleanup param - Adds configuratble sleep param to CitrixResourceBase::connect() used to verify if telnet to specifc port is possible (if sleep is 0, then default to _sleep = 10000ms) - Adds Command/Answer for patch systemVMs on XenServer/Xcp * - Support to patch SystemVMs - VMWare - Remove attaching systemvm.iso to systemVMs - Modify / Refactor VMware start command to copy patch related files to the systemvms - cleanup * Commit comprises of: - remove docker from systemvm template - use containerd as container runtime - update create-k8s-binaries script to use ctr for all docker operations - Update userdata sent to the k8s nodes - update cksnode script, run during patching of the cks/k8s nodes * Add ssh to k8s nodes details in the Access tab on the UI * test * Refactor ca/cert patching logic * Commit comprises of the following changes: - Use restart network/VPC API to patch routers - use livePatch API support patching of only cpvm/ssvm - add timeout to the keystore setup/import script * remove all references of systemvm.iso * Fix keystore-cert-import invocation + refactor cert timeout in CP/SS VMs * fix script timeout * Refactor cert patching for systemVMs + update keystore-cert-import script + patch-sysvms script + remove patchSysvmCommand from networkelementcommand * remove commented code + change core user to cloud for cks nodes * Update ownership of ssh directory * NEED TO DISCUSS - add on the fly template conversion as an ExecStartPre action (systemd) * Add UI changes + move changes from patch file to runcmd * test: validate performance for template modification during seeding * create vms folder in cloudstack-commons directory - debian rules * remove logic for on the fly template convert + update k8s test * fix syntax issue - causing issue with shared network tests * Code cleanup * refactor patching logic - certs * move logic of fixing rootdiskcontroller from upgrade to kubernetes service * add livepatch option to restart network & vpc * smooth upgrade of cks clusters * Support for live patching systemVMs and deprecating systemVM.iso. Includes: - fix systemVM template version - Include agent.zip, cloud-scripts.tgz to the commons package - Support for live-patching systemVMs - CPVM, SSVM, Routers - Fix Unit test - Remove systemvm.iso dependency * The following commit: - refactors logic added to support SystemVM deployment on KVM - Adds support to copy specific files (required for patching) to the hosts on Xenserver - Modifies vmops method - createFileInDomr to take cleanup param - Adds configuratble sleep param to CitrixResourceBase::connect() used to verify if telnet to specifc port is possible (if sleep is 0, then default to _sleep = 10000ms) - Adds Command/Answer for patch systemVMs on XenServer/Xcp * - Support to patch SystemVMs - VMWare - Remove attaching systemvm.iso to systemVMs - Modify / Refactor VMware start command to copy patch related files to the systemvms - cleanup * Commit comprises of: - remove docker from systemvm template - use containerd as container runtime - update create-k8s-binaries script to use ctr for all docker operations - Update userdata sent to the k8s nodes - update cksnode script, run during patching of the cks/k8s nodes * Add ssh to k8s nodes details in the Access tab on the UI * test * Refactor ca/cert patching logic * Commit comprises of the following changes: - Use restart network/VPC API to patch routers - use livePatch API support patching of only cpvm/ssvm - add timeout to the keystore setup/import script * remove all references of systemvm.iso * Fix keystore-cert-import invocation + refactor cert timeout in CP/SS VMs * fix script timeout * Refactor cert patching for systemVMs + update keystore-cert-import script + patch-sysvms script + remove patchSysvmCommand from networkelementcommand * remove commented code + change core user to cloud for cks nodes * Update ownership of ssh directory * NEED TO DISCUSS - add on the fly template conversion as an ExecStartPre action (systemd) * Add UI changes + move changes from patch file to runcmd * test: validate performance for template modification during seeding * create vms folder in cloudstack-commons directory - debian rules * remove logic for on the fly template convert + update k8s test * fix syntax issue - causing issue with shared network tests * Code cleanup * add cgroup config for containerd * add systemd config for kubelet * add additional info during image registry config * address comments * add temp links of download.cloudstack.org * address part of the comments * address comments * update containerd config - as version has upgraded to 1.5 from 1.4.12 in 4.17.0 * address comments - simplify * fix vue3 related icon changes * allow network commands when router template version is lower but is patched * add internal LB to the list of routers to be patched on network restart with live patch * add unit tests for API param validations and new helper utilities - file scp & checksum validations * perform patching only for non-user i.e., system VMs * add test to validate params * remove unused import * add column to domain_router to display software version and support networkrestart with livePatch from router view * Requires upgrade column to consider package (cloud-scripts) checksum to identify if true/false * use router software version instead of checksum * show N/A if no software version reported i.e., in upgraded envs * fix deb failure * update pom to official links of systemVM template
217 lines
7.2 KiB
Bash
217 lines
7.2 KiB
Bash
#!/bin/bash
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you 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.
|
|
|
|
set -x
|
|
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
|
CMDLINE=/var/cache/cloud/cmdline
|
|
|
|
hypervisor() {
|
|
if [ -d /proc/xen ]; then
|
|
mount -t xenfs none /proc/xen
|
|
$(dmesg | grep -q "Xen HVM")
|
|
if [ $? -eq 0 ]; then # 1=PV,0=HVM
|
|
echo "xen-hvm" && return 0
|
|
else
|
|
echo "xen-pv" && return 0
|
|
fi
|
|
fi
|
|
|
|
[ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) )
|
|
if [ "$facts" != "" ]; then
|
|
# Xen HVM is recognized as Hyperv when Viridian extensions are enabled
|
|
if [ "${facts[-1]}" == "xen-domU" ] && [ "${facts[0]}" == "hyperv" ]; then
|
|
echo "xen-hvm" && return 0
|
|
else
|
|
echo ${facts[-1]} && return 0
|
|
fi
|
|
fi
|
|
|
|
grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0
|
|
grep -q QEMU /var/log/messages && echo "kvm" && return 0
|
|
|
|
vmware-checkvm &> /dev/null && echo "vmware" && return 0
|
|
|
|
echo "unknown" && return 1
|
|
}
|
|
|
|
config_guest() {
|
|
[ ! -d /proc/xen ] && sed -i 's/^vc/#vc/' /etc/inittab && telinit q
|
|
[ -d /proc/xen ] && sed -i 's/^#vc/vc/' /etc/inittab && telinit q
|
|
|
|
systemctl daemon-reload
|
|
|
|
case $HYPERVISOR in
|
|
xen-pv|xen-domU)
|
|
systemctl stop ntpd
|
|
systemctl disable ntpd
|
|
systemctl enable xe-daemon
|
|
systemctl start xe-daemon
|
|
|
|
cat /proc/cmdline > $CMDLINE
|
|
sed -i "s/%/ /g" $CMDLINE
|
|
;;
|
|
xen-hvm)
|
|
systemctl stop ntpd
|
|
systemctl disable ntpd
|
|
systemctl enable xe-daemon
|
|
systemctl start xe-daemon
|
|
|
|
if [ ! -f /usr/bin/xenstore-read ]; then
|
|
log_it "ERROR: xentools not installed, cannot found xenstore-read" && exit 5
|
|
fi
|
|
/usr/bin/xenstore-read vm-data/cloudstack/init > $CMDLINE
|
|
sed -i "s/%/ /g" $CMDLINE
|
|
;;
|
|
kvm)
|
|
# Configure kvm hotplug support
|
|
if grep -E 'CONFIG_HOTPLUG_PCI=y|CONFIG_HOTPLUG_PCI_ACPI=y' /boot/config-`uname -r`; then
|
|
log_it "acpiphp and pci_hotplug module already compiled in"
|
|
else
|
|
modprobe acpiphp 2> /dev/null && log_it "acpiphp module loaded" || true
|
|
modprobe pci_hotplug 2> /dev/null && log_it "pci_hotplug module loaded" || true
|
|
fi
|
|
|
|
sed -i -e "/^s0:2345:respawn.*/d" /etc/inittab
|
|
sed -i -e "/6:23:respawn/a\s0:2345:respawn:/sbin/getty -L 115200 ttyS0 vt102" /etc/inittab
|
|
systemctl enable qemu-guest-agent
|
|
systemctl start qemu-guest-agent
|
|
|
|
# Wait for $CMDLINE file to be written by the qemu-guest-agent
|
|
for i in {1..60}; do
|
|
if [ -s $CMDLINE ]; then
|
|
log_it "Received a new non-empty cmdline file from qemu-guest-agent"
|
|
# Remove old configuration files in /etc/cloudstack if VR is booted from cloudstack
|
|
rm -rf /etc/cloudstack/*.json
|
|
log_it "Booting from cloudstack, remove old configuration files in /etc/cloudstack/"
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
if [ ! -s $CMDLINE ]; then
|
|
log_it "Failed to receive the cmdline file via the qemu-guest-agent"
|
|
fi
|
|
;;
|
|
vmware)
|
|
# system time sync'd with host via vmware tools
|
|
systemctl stop ntpd
|
|
systemctl disable ntpd
|
|
systemctl enable open-vm-tools
|
|
systemctl start open-vm-tools
|
|
|
|
vmtoolsd --cmd 'machine.id.get' > $CMDLINE
|
|
;;
|
|
virtualpc|hyperv)
|
|
# Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed using KVP Daemon
|
|
systemctl enable hyperv-daemons.hv-fcopy-daemon.service hyperv-daemons.hv-kvp-daemon.service hyperv-daemons.hv-vss-daemon.service
|
|
systemctl start hyperv-daemons.hv-fcopy-daemon.service hyperv-daemons.hv-kvp-daemon.service hyperv-daemons.hv-vss-daemon.service
|
|
sleep 5
|
|
cp -f /var/opt/hyperv/.kvp_pool_0 $CMDLINE
|
|
cat /dev/null > /var/opt/hyperv/.kvp_pool_0
|
|
;;
|
|
virtualbox)
|
|
# Virtualbox is used to test the virtual router
|
|
# get the commandline from a dmistring (yes, hacky!)
|
|
dmidecode | grep cmdline | sed 's/^.*cmdline://' > $CMDLINE
|
|
RV=$?
|
|
if [ $RV -ne 0 ] ; then
|
|
log_it "Failed to get cmdline from a virtualbox dmi property"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
if [ -f /mnt/cmdline ]; then
|
|
cat /mnt/cmdline > $CMDLINE
|
|
fi
|
|
|
|
# Find and export guest type
|
|
export TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE)
|
|
}
|
|
|
|
setup_interface_sshd() {
|
|
|
|
if [ "$TYPE" != "cksnode" ]; then
|
|
log_it "Applying iptables rules"
|
|
if [ "$TYPE" != "dhcpsrvr" ]; then
|
|
cp /etc/iptables/iptables-$TYPE /etc/iptables/rules.v4
|
|
else
|
|
cp /etc/iptables/iptables-router /etc/iptables/rules.v4
|
|
fi
|
|
fi
|
|
|
|
if [ "$TYPE" == "consoleproxy" ] || [ "$TYPE" == "secstorage" ]; then
|
|
setup_common eth0 eth1 eth2
|
|
log_it "Configuring sshd"
|
|
local hyp=$HYPERVISOR
|
|
if [ "$hyp" == "vmware" ] || [ "$hyp" == "hyperv" ]; then
|
|
setup_sshd $ETH1_IP "eth1"
|
|
else
|
|
setup_sshd $ETH0_IP "eth0"
|
|
fi
|
|
|
|
elif [ "$TYPE" == "router" ]; then
|
|
if [ -n "$ETH2_IP" ]; then
|
|
setup_common eth0 eth1 eth2
|
|
|
|
if [ -n "$EXTRA_PUBNICS" ]; then
|
|
for ((i = 3; i < 3 + $EXTRA_PUBNICS; i++)); do
|
|
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
|
done
|
|
fi
|
|
else
|
|
setup_common eth0 eth1
|
|
if [ -n "$EXTRA_PUBNICS" ]; then
|
|
for ((i = 2; i < 2 + $EXTRA_PUBNICS; i++)); do
|
|
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
|
done
|
|
fi
|
|
fi
|
|
setup_sshd $ETH1_IP "eth1"
|
|
|
|
elif [ "$TYPE" == "vpcrouter" ]; then
|
|
setup_interface "0" $ETH0_IP $ETH0_MASK $GW
|
|
setup_sshd $ETH0_IP "eth0"
|
|
|
|
elif [ "$TYPE" == "ilbvm" ]; then
|
|
setup_common eth0 eth1
|
|
setup_sshd $ETH1_IP "eth1"
|
|
|
|
elif [ "$TYPE" == "elbvm" ] || [ "$TYPE" == "dhcpsrvr" ]; then
|
|
setup_common eth0 eth1
|
|
if [ "$SSHONGUEST" == "true" ]; then
|
|
setup_sshd $ETH0_IP "eth0"
|
|
else
|
|
setup_sshd $ETH1_IP "eth1"
|
|
fi
|
|
elif [ "$TYPE" == "cksnode" ]; then
|
|
setup_common eth0
|
|
fi
|
|
|
|
systemctl restart systemd-journald
|
|
# Patch known systemd/sshd memory leak - https://github.com/systemd/systemd/issues/8015#issuecomment-476160981
|
|
echo '@include null' >> /etc/pam.d/systemd-user
|
|
# Enable and Start SSH
|
|
systemctl enable --now --no-block ssh
|
|
}
|
|
|
|
export HYPERVISOR=$(hypervisor)
|
|
[ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out" && exit 10
|
|
log_it "Starting guest services for $HYPERVISOR"
|
|
|
|
config_guest
|
|
source /opt/cloud/bin/setup/common.sh
|
|
setup_interface_sshd |