Fix distro fact handling for Flatcar#77635
Conversation
| if not data: | ||
| return False, flatcar_facts | ||
|
|
||
| version = re.search("VERSION=(.*)", data) |
There was a problem hiding this comment.
Maybe we could even rely more on distro and reuse _distro.version() that already provides the VERSION_ID field, or?
There was a problem hiding this comment.
I like the idea, however distro inside parse_distribution_file_Flatcar() is a string, not an instance of LinuxDistribution. The version() method on LinuxDistribution is actually already used inside get_distribution_version() which gets invoked from _guess_distribution() which in turns runs before we try processing the dist file. The dist file parsing functions are overriding any facts guessed previously, and AFAICT are supposed to be the authoritative source for distro-specific facts.
Therefore, I think it's safer to explicitly set the relevant facts inside parse_distribution_file_Flatcar() and rely on guessed facts only as a fallback.
f64753e to
f874b57
Compare
I've updated the existing test fixture. The test seems to pass, however I'm not totally sure about the |
That fixture can be generated by running |
The existence of the file /etc/flatcar/update.conf depends on bootstrap configuration typically provided by the user. For that reason this file is unsuitable for determining distro facts for Flatcar Container Linux. The distribution_release fact is meaningless in the case of Flatcar since Flatcar doesn't have named releases. The distribution_version fact, however, IS meaningful and should contain a number such as "3139.2.0". - Use /etc/os-release instead of /etc/flatcar/update.conf. - Drop the distribution_release fact. - Set the distribution_version fact. Signed-off-by: Johanan Liebermann <jliebermann@microsoft.com>
f874b57 to
91b3bfc
Compare
Thanks @sivel. The generated output has Following is the full generated fixture, for the record: {
"name": "Flatcar Container Linux by Kinvolk 3139.2.0",
"distro": {
"codename": "",
"id": "flatcar",
"name": "Flatcar Container Linux by Kinvolk",
"version": "3139.2.0",
"version_best": "3139.2.0",
"lsb_release_info": {},
"os_release_info": {
"name": "Flatcar Container Linux by Kinvolk",
"id": "flatcar",
"id_like": "coreos",
"version": "3139.2.0",
"version_id": "3139.2.0",
"build_id": "2022-04-05-1803",
"pretty_name": "Flatcar Container Linux by Kinvolk 3139.2.0 (Oklo)",
"ansi_color": "38;5;75",
"home_url": "https://flatcar-linux.org/",
"bug_report_url": "https://issues.flatcar-linux.org",
"flatcar_board": "amd64-usr",
"cpe_name": "cpe:2.3:o:flatcar-linux:flatcar_linux:3139.2.0:*:*:*:*:*:*:*"
}
},
"input": {
"/etc/os-release": "NAME=\"Flatcar Container Linux by Kinvolk\"\nID=flatcar\nID_LIKE=coreos\nVERSION=3139.2.0\nVERSION_ID=3139.2.0\nBUILD_ID=2022-04-05-1803\nPRETTY_NAME=\"Flatcar Container Linux by Kinvolk 3139.2.0 (Oklo)\"\nANSI_COLOR=\"38;5;75\"\nHOME_URL=\"https://flatcar-linux.org/\"\nBUG_REPORT_URL=\"https://issues.flatcar-linux.org\"\nFLATCAR_BOARD=\"amd64-usr\"\nCPE_NAME=\"cpe:2.3:o:flatcar-linux:flatcar_linux:3139.2.0:*:*:*:*:*:*:*\"\n",
"/etc/lsb-release": "DISTRIB_ID=\"Flatcar Container Linux by Kinvolk\"\nDISTRIB_RELEASE=3139.2.0\nDISTRIB_CODENAME=\"Oklo\"\nDISTRIB_DESCRIPTION=\"Flatcar Container Linux by Kinvolk 3139.2.0 (Oklo)\"\n",
"/usr/lib/os-release": "NAME=\"Flatcar Container Linux by Kinvolk\"\nID=flatcar\nID_LIKE=coreos\nVERSION=3139.2.0\nVERSION_ID=3139.2.0\nBUILD_ID=2022-04-05-1803\nPRETTY_NAME=\"Flatcar Container Linux by Kinvolk 3139.2.0 (Oklo)\"\nANSI_COLOR=\"38;5;75\"\nHOME_URL=\"https://flatcar-linux.org/\"\nBUG_REPORT_URL=\"https://issues.flatcar-linux.org\"\nFLATCAR_BOARD=\"amd64-usr\"\nCPE_NAME=\"cpe:2.3:o:flatcar-linux:flatcar_linux:3139.2.0:*:*:*:*:*:*:*\"\n"
},
"platform.dist": [
"flatcar",
"3139.2.0",
""
],
"result": {
"distribution": "Flatcar Container Linux by Kinvolk",
"distribution_version": "3139.2.0",
"distribution_release": "NA",
"distribution_major_version": "3139",
"os_family": "Flatcar Container Linux by Kinvolk"
},
"platform.release": "5.15.32-flatcar"
} |
- Generate the fixture using gen_distribution_version_testcase.py. - Override result.distribution and result.os_family manually as the generator script gives wrong values. - Use a recent Flatcar version. Signed-off-by: Johanan Liebermann <jliebermann@microsoft.com>
91b3bfc to
d461326
Compare
|
I've updated the fixture to be the output above, with the following manual overrides:
I hope that makes sense. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
SUMMARY
The existence of the file
/etc/flatcar/update.confdepends on bootstrap configuration typically provided by the user. For that reason this file is unsuitable for determining distro facts for Flatcar Container Linux. This PR switches to/etc/os-releaseas the file used for extracting distro facts for Flatcar.Fixes #77537.
ISSUE TYPE
COMPONENT NAME
distribution.py