Skip to content

Commit

Permalink
[metalos] Include {os_version} in PRETTY_NAME
Browse files Browse the repository at this point in the history
Summary:
# This diff
Add the version to `os-release` PRETTY_NAME explicitly, this used to be included implicitly when {os_name} was set to "CentOS Stream X" but was removed in D47242191 to confirm with CentOS's standard value.

This value is used in ANR to set the value in serf, this diff results in serf OS strings of the form

`CentOS Stream 9 MclassicA`

Per this transform used by the os.py driver.

https://www.internalfb.com/code/fbsource/fbcode/machinechecker/anrsnapshot/drivers/os.py?lines=50-54

# Broader thoughts
The approach of executing a big shell command with conditional `cat` from various files is a bit wild. The additional naive parsing os the os-release format double so.

This driver probably needs a better rethink.

Test Plan:
## os-release File
```
devvm20063.prn0:~/fbsource/fbcode$ buck run metalos/os/facebook/classic/vmtest:switchroot-cached-c9 -- --shell=console
[root@vmtest ~]# cat /etc/os-release
NAME="CentOS Stream"
ID="centos"
VERSION="9"
PRETTY_NAME="CentOS Stream 9 MclassicA (0a658f98fcba6a779b2a123d1cfb83ad7da39966)"
IMAGE_ID="local"
IMAGE_LAYER="fbcode//metalos/os/facebook/classic:classic.c9"
IMAGE_VCS_REV="0a658f98fcba6a779b2a123d1cfb83ad7da39966"
IMAGE_VCS_REV_TIME="2023-07-17T14:07:19-0700"
VARIANT="MclassicA"
VARIANT_ID="mclassica"
ANSI_COLOR="0;34"
API_VER_KDUMP_SUBVOL="1"
API_VER_NETWORKD_ROUTES_IGNORE="1"
API_VER_SERVICE_IMAGE_GC="1"
API_VER_SERVICE_IMAGE_HELPER="1"
API_VER_SYSTEMD_KEXEC_LOAD="1"
API_VER_TMP_SUBVOL="2"
API_VER_TW_SUBVOL="1"
API_VER_USE_SYSTEMD_EXCEPTION="1"
```

Reviewed By: cooperlees

Differential Revision: D47529019

fbshipit-source-id: 33a4bf7a1fc4e3905757b4a44944dee5bb0d98ae
  • Loading branch information
Aijay Adams authored and facebook-github-bot committed Jul 18, 2023
1 parent 85519a8 commit 40da88a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion antlir/bzl/linux/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ cat > $OUT << EOF
NAME="{os_name}"
ID="{os_id}"
VERSION="{os_version}"
PRETTY_NAME="{os_name} {variant} ($rev)"
PRETTY_NAME="{os_name} {os_version} {variant} ($rev)"
IMAGE_ID="{image_id}"
IMAGE_LAYER="{target}"
IMAGE_VCS_REV="$rev"
Expand Down
2 changes: 1 addition & 1 deletion antlir/bzl/linux/tests/test_os_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_os_release(self) -> None:
# Validate the Pretty Name has the names + a valid vcs rev
self.assertTrue(
re.match(
rf"AntlirTest\ Test\ \({rev_id_regex}\)",
rf"AntlirTest\ 9\ Test\ \({rev_id_regex}\)",
os_release["PRETTY_NAME"],
)
)
Expand Down

0 comments on commit 40da88a

Please sign in to comment.