Skip to content

Commit 0258fc5

Browse files
s4heidMSSeduschnaioja
authored
Forward‑porting Azure-related changes from Jammy to Noble (#476)
* Fix cloud-init logging format The typo leads to problems when cloud-init attempts to load the logging configuration. This is evident in the logs, as shown by the following stack trace: > cloud-init[515]: 2025-09-24 12:07:29,260 - util.py[WARNING]: Failed > loading yaml blob. Invalid format at line 10 column 1: "expected ? '<document start>', but found '<block mapping start>' > cloud-init[515]: in "<unicode string>", line 10, column 1: > cloud-init[515]: _log: > cloud-init[515]: ^" * Disable floppy module * Prevent kernel from auto-loading floppy In a previous change (#449), loading the floppy module was disabled by redirecting the floppy command to true. However, Buffer I/O errors observed in the `dmesg` output indicate that the kernel is still attempting to load the floppy module when the hardware supports it. ```txt blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0 floppy0: disk absent or changed during operation ``` This suggests that during boot: 1. Kernel detects floppy controller hardware 2. udev/kernel auto-loads floppy module (install directive not active yet) 3. Floppy driver starts, finds no disk → I/O errors 4. install directive becomes active (too late!) The blacklist in /etc/modprobe.d only affects modprobe after the root filesystem is active. If the initramfs contains a `floppy.ko` file and is not rebuilt after the blacklist has been applied, the initramfs auto-loads the floppy driver. `update-initramfs` rebuilds the initramfs and includes the /etc/modprobe.d rules to the root fs. * Mount /sys in system_kernel_modules for initramfs generation The system_kernel_modules stage fails when running update-initramfs with FIPS kernels because the FIPS initramfs hooks require /sys to be mounted for hardware introspection when MODULES=dep is configured. The run_in_chroot helper creates an isolated mount namespace via unshare -m, which only mounts /dev and /proc but not /sys. This causes mkinitramfs to fail with "MODULES dep requires mounted sysfs on /sys" when the FIPS hooks attempt to scan hardware capabilities. Mount /sys explicitly in system_kernel_modules/apply.sh before calling update-initramfs to ensure the kernel device model and driver information is available for initramfs generation. * Add hvperv-kv daemon for Azure stemcells Azure runs on the Hyper-V hypervisor, and Linux VMs rely on Linux Integration Services (LIS) to communicate with the host. These services include kernel modules (like hv_utils) and daemons (hv_kvp_daemon, hv_vss_daemon, etc.) that handle: - Host-to-guest communication - IP address reporting - VM metadata exchange - Backup coordination (via VSS) The hv_kvp_daemon specifically manages key-value pair exchange between the Azure host and the Linux guest. If the daemon is missing, Azure may not be able to retrieve guest metadata (e.g., hostname, IP address) This can affect Azure Resource Graph queries, scripts that rely on guest-reported data, backup and monitoring tools that use KVP for coordination cloud-init writes warnings about events that could not be sent to hv-kvp: ```txt $ grep kvp /var/log/cloud-init.log failed to truncate kvp pool file, [Errno 2] No such file or directory: '/var/lib/hyperv/.kvp_pool_1' failed posting events to kvp, [Errno 2] No such file or directory: '/var/lib/hyperv/.kvp_pool_1' ``` * Add missing tests for waagent.service * Add linux-cloud-tools to expected azure packages Fixes #453 * Enable cloud-init apt-configure module for Azure stemcells Azure stemcells now properly use Azure-optimized APT mirrors (azure.archive.ubuntu.com) by enabling the apt-configure module in cloud-init configuration. The LISA (Linux Integration Services Automation) test suite's verify_repository_installed test was failing because Azure VMs were using archive.ubuntu.com instead of azure.archive.ubuntu.com for APT package repositories. While the Azure mirror configuration existed in /etc/cloud/cloud.cfg.d/90-azure-apt-sources.cfg, it was never applied because the apt-configure module was not enabled in cloud-init's module list. Added apt-configure to the cloud_init_modules list in cloud.cfg, which instructs cloud-init to read and apply the Azure APT mirror configuration at VM boot time. This ensures /etc/apt/sources.list is automatically updated to use Azure-optimized mirrors. * Update waagent to `v2.15.0.1` and keep systemd config in sync * upgrades waagent to the latest version * syncs the systemd config, which adds memory-accounting and a dependency to cloud-init.service, which ensures that the waagent.service does not start before cloud-init has finished. <https://github.com/Azure/WALinuxAgent/blob/v2.15.0.1/init/ubuntu/walinuxagent.service> * Initialize log directory required by waagent waagent assumes that the `/var/log/azure` directory exists and raises an exception in the telemetry module if it does not. ```sh ERROR TelemetryEventsCollector ExtHandler Event: name=WALinuxAgent, op=ExtensionTelemetryEventProcessing, message=Unknown error occurred when trying to collect extension events:[Errno 2] No such file or directory: '/var/log/azure' ``` * Improve chrony clock settings Co-Authored-By: Sebastian Heid <8442432+s4heid@users.noreply.github.com> * Improve chrony reliability on Azure add systemd override (FIFO scheduling, priority 50, OOMScoreAdjust -500) change Hyper-V PTP refclock poll 3 -> -1 (sampling interval max from 8s to 0.5s; with dpoll -2 dynamic range shifts from 2-8s to 0.125-0.5s) for tighter offset/jitter. (#442) Co-Authored-By: Sebastian Heid <8442432+s4heid@users.noreply.github.com> * Fix path to chrony.service This change sets the correct path when creating the chrony.service directory. The wrong path was introduced in #442. * Set linux-cloud-tools version to 6.8 in expectation --------- Co-authored-by: Sebastian Max Dusch <sedusch@microsoft.com> Co-authored-by: Adrian Joian <6505576+naioja@users.noreply.github.com>
1 parent ae70313 commit 0258fc5

9 files changed

Lines changed: 94 additions & 9 deletions

File tree

bosh-stemcell/spec/assets/dpkg-list-ubuntu-azure-additions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
azure-vm-utils
22
cloud-init
3+
linux-cloud-tools-6.8
4+
linux-cloud-tools-6.8-generic
5+
linux-cloud-tools-common
6+
linux-cloud-tools-generic
37
netplan.io
48
python-is-python3
59
python3-attr

bosh-stemcell/spec/stemcells/azure_spec.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,52 @@
4040
its(:content) { should include('"PartitionerType": "parted"') }
4141
end
4242
end
43+
44+
context 'cloud-init Azure APT mirror configuration' do
45+
describe file('/etc/cloud/cloud.cfg.d/90-azure-apt-sources.cfg') do
46+
it { should be_file }
47+
its(:content) { should include('http://azure.archive.ubuntu.com/ubuntu/') }
48+
end
49+
50+
describe file('/etc/cloud/cloud.cfg') do
51+
it { should be_file }
52+
its(:content) { should include('apt-configure') }
53+
end
54+
end
55+
56+
context 'installed by system_azure_init', {
57+
exclude_on_alicloud: true,
58+
exclude_on_aws: true,
59+
exclude_on_google: true,
60+
exclude_on_vcloud: true,
61+
exclude_on_vsphere: true,
62+
exclude_on_warden: true,
63+
exclude_on_openstack: true,
64+
exclude_on_softlayer: true,
65+
} do
66+
describe 'Hyper-V KVP daemon' do
67+
describe command('which hv_kvp_daemon') do
68+
its(:exit_status) { should eq 0 }
69+
end
70+
71+
describe service('hv-kvp-daemon') do
72+
it { should be_enabled }
73+
end
74+
end
75+
76+
describe 'WALinuxAgent configuration' do
77+
describe file('/etc/waagent.conf') do
78+
it { should be_owned_by('root') }
79+
end
80+
81+
describe file('/lib/systemd/system/walinuxagent.service') do
82+
it { should be_mode(0644) }
83+
it { should be_owned_by('root') }
84+
end
85+
86+
describe service('walinuxagent') do
87+
it { should be_enabled }
88+
end
89+
end
90+
end
4391
end

bosh-stemcell/spec/support/os_image_linux_kernel_modules_shared_examples.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,10 @@
7878
its(:content) { should match 'install rds /bin/true' }
7979
end
8080
end
81+
82+
context 'prevent floppy module from being loaded' do
83+
describe file('/etc/modprobe.d/blacklist.conf') do
84+
its(:content) { should match 'install floppy /bin/true' }
85+
end
86+
end
8187
end

stemcell_builder/stages/bosh_azure_chrony/apply.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@ base_dir=$(readlink -nf $(dirname $0)/../..)
66
source $base_dir/lib/prelude_apply.bash
77
source $base_dir/lib/prelude_bosh.bash
88

9+
mkdir -p $chroot/etc/systemd/system/chrony.service.d
10+
11+
cat > $chroot/etc/systemd/system/chrony.service.d/chrony-systemd-override.conf <<EOF
12+
# created by $0
13+
[Service]
14+
# Set the CPU scheduling policy to FIFO (First-In, First-Out), a real-time policy.
15+
CPUSchedulingPolicy=fifo
16+
17+
# Set the real-time priority to the highest possible value (99).
18+
# This ensures chronyd runs before any other non-kernel, non-real-time tasks.
19+
CPUSchedulingPriority=50
20+
21+
# Make the process less likely to be killed by the OOM killer
22+
OOMScoreAdjust=-500
23+
EOF
24+
925
cat > $chroot/etc/chrony/conf.d/azure_ptp.conf <<EOF
1026
# created by $0
1127
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync#chrony
12-
refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0
28+
refclock PHC /dev/ptp_hyperv poll -1 dpoll -2 offset 0 stratum 2
1329
EOF

stemcell_builder/stages/system_azure_init/apply.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ set -e
55
base_dir=$(readlink -nf $(dirname $0)/../..)
66
source $base_dir/lib/prelude_apply.bash
77

8-
packages="python3 python3-pyasn1 python3-setuptools python3-distro python-is-python3 cloud-init azure-vm-utils"
8+
packages="python3 python3-pyasn1 python3-setuptools python3-distro python-is-python3 \
9+
cloud-init azure-vm-utils linux-cloud-tools-common linux-cloud-tools-generic"
910
pkg_mgr install $packages
1011

11-
wala_release=2.9.1.1
12-
wala_expected_sha1=b61bd57f3b2f7b048d6bab2739690bbf1d9c213b
12+
wala_release=2.15.0.1
13+
wala_expected_sha1=155fd6f326a2bf2ff97b4ea2e2c83dc16a9c1768
1314

1415
curl -L https://github.com/Azure/WALinuxAgent/archive/v${wala_release}.tar.gz > /tmp/wala.tar.gz
1516
sha1=$(cat /tmp/wala.tar.gz | openssl dgst -sha1 | awk 'BEGIN {FS="="}; {gsub(/ /,"",$2); print $2}')
@@ -32,6 +33,7 @@ run_in_chroot $chroot "
3233
sudo rm -fr WALinuxAgent-${wala_release}
3334
rm wala.tar.gz
3435
"
36+
mkdir -p $chroot/var/log/azure
3537
cp -f $dir/assets/etc/waagent/waagent.conf $chroot/etc/waagent.conf
3638
cp -f $dir/assets/etc/waagent/walinuxagent.service $chroot/lib/systemd/system/walinuxagent.service
3739
chmod 0644 $chroot/lib/systemd/system/walinuxagent.service
@@ -70,3 +72,6 @@ cat $chroot/etc/rsyslog.d/21-cloudinit.conf >> $chroot/etc/rsyslog.d/50-default.
7072

7173
rm $chroot/etc/rsyslog.d/21-cloudinit.conf
7274

75+
76+
# Enable Hyper-V KVP daemon (installed via linux-cloud-tools)
77+
run_in_chroot "$chroot" "systemctl enable hv-kvp-daemon.service"

stemcell_builder/stages/system_azure_init/assets/etc/cloud-init/05-logging.cfg

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
=## This yaml formated config file handles setting
1+
## This yaml formatted config file handles setting
22
## logger information. The values that are necessary to be set
33
## are seen at the bottom. The top '_log' are only used to remove
4-
## redundency in a syslog and fallback-to-file case.
4+
## redundancy in a syslog and fallback-to-file case.
55
##
66
## The 'log_cfgs' entry defines a list of logger configs
77
## Each entry in the list is tried, and the first one that
@@ -68,5 +68,4 @@ log_cfgs:
6868
# This tells cloud-init to redirect its stdout and stderr to
6969
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
7070
# there without needing to look on the console.
71-
output: {all: '| tee -a /var/log/cloud-init-output.log'}
72-
71+
output: {all: '| tee -a /var/log/cloud-init-output.log'}

stemcell_builder/stages/system_azure_init/assets/etc/cloud-init/cloud.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cloud_init_modules:
1010
- update_etc_hosts
1111
- users-groups
1212
- ssh
13+
- apt-configure
1314
cloud_config_modules:
1415
- ssh-import-id
1516
- set-passwords

stemcell_builder/stages/system_azure_init/assets/etc/waagent/walinuxagent.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ExecStart=/usr/bin/python3 -u /usr/sbin/waagent -daemon
2020
Restart=always
2121
Slice=azure.slice
2222
CPUAccounting=yes
23+
MemoryAccounting=yes
2324

2425
[Install]
2526
WantedBy=multi-user.target

stemcell_builder/stages/system_kernel_modules/apply.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ install hfs /bin/true
1818
install hfsplus /bin/true
1919
install squashfs /bin/true
2020
install udf /bin/true
21-
install rds /bin/true' >> $chroot/etc/modprobe.d/blacklist.conf
21+
install rds /bin/true
22+
install floppy /bin/true' >> $chroot/etc/modprobe.d/blacklist.conf
2223

2324
echo '# prevent nouveau from loading
2425
blacklist nouveau
@@ -28,3 +29,7 @@ alias nouveau off
2829
alias lbm-nouveau off' >> $chroot/etc/modprobe.d/blacklist-nouveau.conf
2930

3031
rm -rf $chroot/lib/modules/*/kernel/zfs $chroot/usr/src/linux-headers-*/zfs
32+
33+
mount --bind /sys "$chroot/sys"
34+
add_on_exit "umount $chroot/sys"
35+
run_in_chroot $chroot "update-initramfs -u -k all"

0 commit comments

Comments
 (0)