Azure / Azure/WALinuxAgent

[BUG] `/etc/mariner-release` check in `get_distro()` is dead code on Azure Linux — potential footgun

Open
#3,602 1 comment 0 reactions 1 assignee Claimed by @narrieta View on GitHub
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

**Describe the bug:**

`get_distro()` checks for `/etc/mariner-release` to override `osinfo[0]` to `"mariner"`. On Azure Linux, this file does not exist — the distro ships `/etc/azurelinux-release` instead.

https://github.com/Azure/WALinuxAgent/blob/a976115fd7254f4f9f54cc33528f0817b07b7976/azurelinuxagent/common/version.py#L137

Distro detection works correctly today because `get_linux_distribution()` (called earlier in the function) reads `/etc/os-release` (`ID=azurelinux`) and returns `"azurelinux"` before the `/etc/mariner-release` override is reached.

However, the dead code is a potential footgun:
- If `/etc/mariner-release` is ever added to Azure Linux for backward compatibility, it would incorrectly override `"azurelinux"` back to `"mariner"` because the `if` block runs after `get_linux_distribution()`.
- There is no corresponding `/etc/azurelinux-release` check in the code for consistency with the other distro-specific overrides (oracle, euleros, photonos, etc.).

Current flow in get_distro():

osinfo = get_linux_distribution(0, 'alpine') # returns 'azurelinux' from os-release
...
if os.path.exists("/etc/mariner-release"): # does NOT exist on AZL — skipped
osinfo[0] = "mariner"
# No check for /etc/azurelinux-release

Steps to reproduce:

python3 -c "import azurelinuxagent.common.version as v; print(v.DISTRO_NAME)"
# azurelinux <-- works correctly today

ls /etc/*-release
# /etc/azurelinux-release /etc/os-release /etc/system-release
# No /etc/mariner-release exists

**Distro and WALinuxAgent details:**
- Distro and Version: Azure Linux
- WALinuxAgent version: 2.15.0.1 (waagent-2.15.0.1-1.azl4)

**Additional context**

This is a low-severity/informational issue. No functional impact today. Filing for awareness so the team can decide whether to:
1. Add an `/etc/azurelinux-release` check for consistency
2. Remove the `/etc/mariner-release` override entirely (since `os-release` handles detection)
3. Leave as-is if considered harmless

**Log file attached**

N/A — no functional failure, detection works correctly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.