Skip to content

Commit f0c4779

Browse files
committed
Add basic azl4 support
1 parent 30e6cbc commit f0c4779

24 files changed

Lines changed: 240 additions & 103 deletions

docs/imagecustomizer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ other Linux distributions as well.
5959
Image Customizer supports the following input image distributions:
6060

6161
- Azure Linux 3.0
62+
- Azure Linux 4.0
6263
- Ubuntu 22.04
6364
- Ubuntu 24.04
6465

docs/imagecustomizer/api/distribution-support.md

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

docs/imagecustomizer/developer-guide.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ sudo go test -C ./toolkit/tools ./...
4141

4242
- [Azure Linux 2.0 core-efi](https://github.com/microsoft/azurelinux/blob/2.0/toolkit/imageconfigs/core-efi.json)
4343
- [Azure Linux 3.0 core-efi](https://github.com/microsoft/azurelinux/blob/3.0/toolkit/imageconfigs/core-efi.json)
44+
- Azure Linux 4.0 core-efi
4445
- [Azure Linux 2.0 core-legacy](https://github.com/microsoft/azurelinux/blob/2.0/toolkit/imageconfigs/core-legacy.json)
4546
- [Azure Linux 3.0 core-legacy](https://github.com/microsoft/azurelinux/blob/3.0/toolkit/imageconfigs/core-legacy.json)
4647
- [Ubuntu 22.04 Azure cloud](https://cloud-images.ubuntu.com/releases/22.04/release/) (download the `*-azure.vhd.tar.gz` and extract)
@@ -57,6 +58,7 @@ sudo go test -C ./toolkit/tools ./...
5758
```bash
5859
AZURE_LINUX_2_CORE_EFI_VHDX="<core-efi-2.0.vhdx>"
5960
AZURE_LINUX_3_CORE_EFI_VHDX="<core-efi-3.0.vhdx>"
61+
AZURE_LINUX_4_CORE_EFI_VHDX="<core-efi-4.0.vhdx>"
6062
AZURE_LINUX_2_CORE_LEGACY_VHD="<core-legacy-2.0.vhd>"
6163
AZURE_LINUX_3_CORE_LEGACY_VHD="<core-legacy-3.0.vhd>"
6264
UBUNTU_2204_AZURE_CLOUD_VHD="<ubuntu-22.04-azure-cloud.vhd>"
@@ -65,6 +67,7 @@ sudo go test -C ./toolkit/tools ./...
6567
sudo go test -C ./toolkit/tools ./pkg/imagecustomizerlib -args \
6668
--base-image-core-efi-azl2 "$AZURE_LINUX_2_CORE_EFI_VHDX" \
6769
--base-image-core-efi-azl3 "$AZURE_LINUX_3_CORE_EFI_VHDX" \
70+
--base-image-core-efi-azl4 "$AZURE_LINUX_4_CORE_EFI_VHDX" \
6871
--base-image-bare-metal-azl2 "$AZURE_LINUX_2_CORE_LEGACY_VHD" \
6972
--base-image-bare-metal-azl3 "$AZURE_LINUX_3_CORE_LEGACY_VHD" \
7073
--base-image-azure-cloud-ubuntu2204 "$UBUNTU_2204_AZURE_CLOUD_VHD" \

test/vmtests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ test-imagecustomizer:
8888
--logs-dir="${LOGS_DIR}" \
8989
--core-efi-azl2="${CORE_EFI_AZL2}" \
9090
--core-efi-azl3="${CORE_EFI_AZL3}" \
91+
--core-efi-azl4="${CORE_EFI_AZL4}" \
9192
--core-legacy-azl2="${CORE_LEGACY_AZL2}" \
9293
--core-legacy-azl3="${CORE_LEGACY_AZL3}" \
9394
--rpm-sources-azl3="${RPM_SOURCES_AZL3}" \

test/vmtests/vmtests/imagecustomizer/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99

1010
def pytest_addoption(parser: pytest.Parser) -> None:
11-
# customize subcommand test options (Azure Linux 2/3)
11+
# customize subcommand test options (Azure Linux 2/3/4)
1212
parser.addoption("--core-efi-azl2", action="store", help="Path to Azure Linux 2 core EFI image")
1313
parser.addoption("--core-efi-azl3", action="store", help="Path to Azure Linux 3 core EFI image")
14+
parser.addoption("--core-efi-azl4", action="store", help="Path to Azure Linux 4 core EFI image")
1415
parser.addoption("--core-legacy-azl2", action="store", help="Path to Azure Linux 2 core legacy image")
1516
parser.addoption("--core-legacy-azl3", action="store", help="Path to Azure Linux 3 core legacy image")
1617

@@ -37,6 +38,14 @@ def core_efi_azl3(request: pytest.FixtureRequest) -> Generator[Path, None, None]
3738
yield Path(image)
3839

3940

41+
@pytest.fixture(scope="session")
42+
def core_efi_azl4(request: pytest.FixtureRequest) -> Generator[Path, None, None]:
43+
image = request.config.getoption("--core-efi-azl4")
44+
if not image:
45+
pytest.skip("--core-efi-azl4 is required for test")
46+
yield Path(image)
47+
48+
4049
@pytest.fixture(scope="session")
4150
def core_legacy_azl2(request: pytest.FixtureRequest) -> Generator[Path, None, None]:
4251
image = request.config.getoption("--core-legacy-azl2")

test/vmtests/vmtests/imagecustomizer/test_min_change.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def run_basic_checks(
157157
elif input_image_azl_release == 3:
158158
assert "ID=azurelinux" in os_release_text
159159
assert 'VERSION_ID="3.0"' in os_release_text
160+
elif input_image_azl_release == 4:
161+
assert "ID=azurelinux" in os_release_text
162+
assert "VERSION_ID=4.0" in os_release_text
160163
else:
161164
assert False, "Unexpected image identity in /etc/os-release"
162165

toolkit/tools/imagegen/diskutils/filesystem.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ var (
6868
Checksum: "crc32c",
6969
}
7070

71+
// The default btrfs options used by an Azure Linux 4.0 image (kernel v6.18).
72+
// Same as AZL3 since nothing has changed since v5.15.
73+
azl4BtrfsOptions = btrfsOptions{
74+
Features: []string{"extref", "skinny-metadata", "no-holes", "free-space-tree"},
75+
Checksum: "crc32c",
76+
}
77+
7178
// The default btrfs options used by Fedora 42 (kernel v6.11+)
7279
fedora42BtrfsOptions = btrfsOptions{
7380
Features: []string{"extref", "skinny-metadata", "no-holes", "free-space-tree"},
@@ -119,6 +126,17 @@ var (
119126
},
120127
}
121128

129+
// The default ext4 options used by an Azure Linux 4.0 image.
130+
// See, the /etc/mke2fs.conf file in an Azure Linux 4.0 imag.
131+
azl4Ext4Options = ext4Options{
132+
BlockSize: 4096,
133+
Features: []string{
134+
"sparse_super", "large_file", "filetype", "resize_inode", "dir_index", "ext_attr", "has_journal", "extent",
135+
"huge_file", "flex_bg", "metadata_csum", "metadata_csum_seed", "64bit", "dir_nlink", "extra_isize",
136+
"orphan_file",
137+
},
138+
}
139+
122140
// The default ext4 options used by Fedora 42 (kernel v6.11+)
123141
// Based on typical Fedora defaults with modern ext4 features
124142
fedora42Ext4Options = ext4Options{
@@ -170,6 +188,17 @@ var (
170188
Features: []string{"bigtime", "crc", "finobt", "inobtcount", "reflink", "rmapbt", "sparse"},
171189
}
172190

191+
// The default xfs options used by an Azure Linux 4.0 image (kernel v6.18).
192+
// See, the /usr/share/xfsprogs/mkfs/lts_6.12.conf file.
193+
azl4XfsOptions = xfsOptions{
194+
Features: []string{"bigtime", "crc", "finobt", "inobtcount", "reflink", "rmapbt", "sparse", "nrext64"},
195+
}
196+
197+
// GRUB 2.12 supports 'nrext64'.
198+
azl4BootXfsOptions = xfsOptions{
199+
Features: []string{"bigtime", "crc", "finobt", "inobtcount", "reflink", "rmapbt", "sparse", "nrext64"},
200+
}
201+
173202
// The default xfs options used by Fedora 42 (kernel v6.11+)
174203
// Based on modern XFS features supported in recent kernels
175204
fedora42XfsOptions = xfsOptions{
@@ -207,6 +236,12 @@ var (
207236
Xfs: azl3XfsOptions,
208237
BootXfs: azl3BootXfsOptions,
209238
},
239+
targetos.TargetOsAzureLinux4: {
240+
Btrfs: azl4BtrfsOptions,
241+
Ext4: azl4Ext4Options,
242+
Xfs: azl4XfsOptions,
243+
BootXfs: azl4BootXfsOptions,
244+
},
210245
targetos.TargetOsFedora42: {
211246
Btrfs: fedora42BtrfsOptions,
212247
Ext4: fedora42Ext4Options,

toolkit/tools/internal/targetos/targetos.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type TargetOs string
1515
const (
1616
TargetOsAzureLinux2 TargetOs = "azl2"
1717
TargetOsAzureLinux3 TargetOs = "azl3"
18+
TargetOsAzureLinux4 TargetOs = "azl4"
1819
TargetOsFedora42 TargetOs = "fedora42"
1920
TargetOsUbuntu2204 TargetOs = "ubuntu2204"
2021
TargetOsUbuntu2404 TargetOs = "ubuntu2404"
@@ -44,6 +45,9 @@ func GetInstalledTargetOs(rootfs string) (TargetOs, error) {
4445
case "3.0":
4546
return TargetOsAzureLinux3, nil
4647

48+
case "4.0":
49+
return TargetOsAzureLinux4, nil
50+
4751
default:
4852
return "", fmt.Errorf("unknown VERSION_ID (%s) for Azure Linux in /etc/os-release", versionId)
4953
}

toolkit/tools/pkg/imagecustomizerlib/baseconfigs_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestBaseConfigsFullRun(t *testing.T) {
7676
}
7777

7878
if runtime.GOARCH == "arm64" {
79-
t.Skip("systemd-boot not available on AZL3 ARM64 yet")
79+
t.Skip("systemd-boot not available on AZL3+ ARM64 yet")
8080
}
8181

8282
testTmpDir := filepath.Join(tmpDir, "TestBaseConfigsFullRun")
@@ -163,10 +163,15 @@ func TestBaseConfigsFullRun(t *testing.T) {
163163
verifyFileContentsSame(t, plantsFileOrigPath, plantsFileNewPath)
164164

165165
// Verify packages
166-
curlInstalled := isPackageInstalled(imageConnection.Chroot(), "curl")
166+
distroHandler, err := NewDistroHandlerFromChroot(imageConnection.Chroot())
167+
if !assert.NoError(t, err) {
168+
return
169+
}
170+
171+
curlInstalled := distroHandler.IsPackageInstalled(imageConnection.Chroot(), "curl")
167172
assert.True(t, curlInstalled)
168173

169-
nginxInstalled := isPackageInstalled(imageConnection.Chroot(), "nginx")
174+
nginxInstalled := distroHandler.IsPackageInstalled(imageConnection.Chroot(), "nginx")
170175
assert.True(t, nginxInstalled)
171176

172177
nginxVersionOutput, err := getPkgVersionFromChroot(imageConnection, "nginx")
@@ -176,7 +181,7 @@ func TestBaseConfigsFullRun(t *testing.T) {
176181
assert.Containsf(t, nginxVersionOutput, nginxExpectedVersion,
177182
"should install nginx version %s, but got: %s", nginxExpectedVersion, nginxVersionOutput)
178183

179-
sshdInstalled := isPackageInstalled(imageConnection.Chroot(), "openssh-server")
184+
sshdInstalled := distroHandler.IsPackageInstalled(imageConnection.Chroot(), "openssh-server")
180185
assert.True(t, sshdInstalled)
181186

182187
systemdBootVersionOutput, err := getPkgVersionFromChroot(imageConnection, "systemd-boot")

toolkit/tools/pkg/imagecustomizerlib/customizebootloader_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func testCustomizeImageMultiKernel(t *testing.T, testName string, baseImageInfo
3838

3939
case baseImageVersionAzl3:
4040
configFile = filepath.Join(testDir, "multikernel-azl3.yaml")
41+
42+
case baseImageVersionAzl4:
43+
configFile = filepath.Join(testDir, "multikernel-azl4.yaml")
4144
}
4245

4346
// Customize image.
@@ -66,7 +69,7 @@ func testCustomizeImageMultiKernel(t *testing.T, testName string, baseImageInfo
6669
// AZL2's default grub.cfg file doesn't support multiple kernels.
6770
assert.GreaterOrEqual(t, len(matches), 1, "grub.cfg:\n%s", grubCfgContents)
6871

69-
case baseImageVersionAzl3:
72+
case baseImageVersionAzl3, baseImageVersionAzl4:
7073
// There should be multiple matching linux kernels, one for each installed kernel.
7174
assert.GreaterOrEqual(t, len(matches), 2, "grub.cfg:\n%s", grubCfgContents)
7275
}

0 commit comments

Comments
 (0)