-
Notifications
You must be signed in to change notification settings - Fork 189
ENT-8118: Added os_version_minor sys variable #5777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Marking this PR as stale due to inactivity; it will be closed in 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🚀 Would be nice if you could add an acceptance test. You can use os_version_major.cf as inspiration.
e9cb703
to
e57cbe7
Compare
b01c5ad
to
77e6a40
Compare
77e6a40
to
d7df578
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will have to derive os_version_minor
from somewhere else on Windows. We don't want it to be "Unknown"
on supported platforms.
d7df578
to
dcc3edc
Compare
@cf-bottom jenkins, please |
Sure, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/12226/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12226/ |
Build for Windows (no tests) |
dcc3edc
to
6001b97
Compare
That's okay, I guess. From your screenshot I would kind of expect the minor version to be 1809. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @victormlg 🚀 Only some smaller comments. Not sure what to do about Windows. Maybe $(sys.os_version_minor)
-> Unknown
is okey?
6001b97
to
57a45b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🚀 The fixes to the C code should be amended to the first commit though
@cf-bottom Jenkins with exotics please :) |
Sure, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12300/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12300/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acceptance test failed on redhat 7
FAIL (UNEXPECTED FAILURE) ./01_vars/01_basic/os_version_minor.cf
See log below
R: Version number extracted from class: centos_7_9
R: Defined classes: centos
R: Defined classes: feature_tls_1_0
R: Defined classes: GMT_Min31
R: Defined classes: ipv4_192_168
R: Defined classes: feature_copyfrom_restrict_keys
R: Defined classes: Lcycle_0
R: Defined classes: GMT_Yr2025
R: Defined classes: feature_def
R: Defined classes: Hr08_Q3
R: Defined classes: cfengine_3_27
R: Defined classes: feature_yaml
R: Defined classes: ipv4_192_168_121
R: Defined classes: June
R: Defined classes: error_mode
R: Defined classes: x86_64
R: Defined classes: warning_mode
R: Defined classes: net_iface_lo
R: Defined classes: GMT_Lcycle_0
R: Defined classes: ipv4_127_0
R: Defined classes: cfengine_3
R: Defined classes: GMT_Morning
R: Defined classes: feature_def_json_preparse
R: Defined classes: GMT_Friday
R: Defined classes: feature_host_specific_data_load
R: Defined classes: feature_host
R: Defined classes: GMT_Hr08
R: Defined classes: linux
R: Defined classes: 1_cpusocket
R: Defined classes: centos_7_x64_j2
R: Defined classes: GMT_Min30_35
R: Defined classes: redhat
R: Defined classes: DEBUG
R: Defined classes: systemd
R: Defined classes: GMT_June
R: Defined classes: compiled_on_linux_gnu
R: Defined classes: feature_host_specific_data
R: Defined classes: feature
R: Defined classes: cfengine
R: Defined classes: mac_52_54_00_0c_ef_5c
R: Defined classes: cfengine_3_27_0a_f77177768
R: Defined classes: 64_bit
R: Defined classes: linux_3_10_0_1127_el7_x86_64
R: Defined classes: notice_mode
R: Defined classes: feature_curl
R: Defined classes: feature_tls_1_3
R: Defined classes: linux_x86_64_3_10_0_1127_el7_x86_64__1_SMP_Tue_Mar_31_23_36_51_UTC_2020
R: Defined classes: feature_tls_1
R: Defined classes: agent
R: Defined classes: GMT_Day27
R: Defined classes: ipv4_192_168_121_34
R: Defined classes: 127_0_0_1
R: Defined classes: Friday
R: Defined classes: any
R: Defined classes: feature_copyfrom
R: Defined classes: feature_copyfrom_restrict
R: Defined classes: ipv4_gw_192_168_121_1
R: Defined classes: centos_7_9
R: Defined classes: centos_7
R: Defined classes: linux_x86_64_3_10_0_1127_el7_x86_64
R: Defined classes: ipv4_127_0_0_1
R: Defined classes: cfengine_3_27_0a
R: Defined classes: GMT_Hr8
R: Defined classes: net_iface_eth0
R: Defined classes: ipv4_192
R: Defined classes: feature_xml
R: Defined classes: 1_cpu
R: Defined classes: Day27
R: Defined classes: inform_mode
R: Defined classes: 192_168_121_34
R: Defined classes: linux_x86_64
R: Defined classes: Min30_35
R: Defined classes: ipv4_127_0_0
R: Defined classes: feature_def_json
R: Defined classes: feature_tls_1_1
R: Defined classes: feature_host_specific
R: Defined classes: Hr8
R: Defined classes: GMT_Q3
R: Defined classes: feature_pam
R: Defined classes: Morning
R: Defined classes: feature_tls
R: Defined classes: AUTO
R: Defined classes: community_edition
R: Defined classes: ipv4_127
R: Defined classes: Min31
R: Defined classes: Yr2025
R: Defined classes: Q3
R: Defined classes: GMT_Hr08_Q3
R: Defined classes: feature_tls_1_2
R: Defined classes: Hr08
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf Expected: 9
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf Found: Unknown
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf FAIL
@cf-bottom Jenkins with exotics please :) |
Sure, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12336/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12336/ |
a2b616f
to
728ed3c
Compare
@cf-bottom Jenkins with exotics please :) |
Alright, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12337/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12337/ |
2987a78
to
4e33700
Compare
@cf-bottom Jenkins with exotics please :) |
Sure, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12338/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12338/ |
4e33700
to
d38db29
Compare
61ad8c2
to
6a55210
Compare
@cf-bottom Jenkins with exotics please :) |
Sure, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12352/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12352/ |
6a55210
to
26986ad
Compare
Ticket: ENT-8118 Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
26986ad
to
55edd2e
Compare
@cf-bottom Jenkins with exotics please :) |
Alright, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/12356/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-12356/ |
any:: | ||
"os_class" | ||
string => nth(classesmatching("$(class_regex)"), "0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this, my first reaction is that it feels a bit too complicated and advanced, I would expect something like:
classes:
ubuntu_20_04|ubuntu_22_04|ubuntu_24_04::
"ok"
if => strcmp("$(sys.os_version_minor)", "4");
"not_ok"
if => not(strcmp("$(sys.os_version_minor)", "4"));
debian_12_11::
"ok"
if => strcmp("$(sys.os_version_minor)", "11");
"not_ok"
if => not(strcmp("$(sys.os_version_minor)", "11"));
reports:
ok.!not_ok::
"Pass";
!ok|not_ok::
"Fail";
That's much easier to read, and gives me more confidence that the test is actually working correctly. However, it will be hard, impossible even, to cover all platforms like this, especially future ones. So maybe a combination would be good? One test which is dynamic and uses regex and covers everything, and one which is stupid and simple and "bulletproof" but doesn't cover all possible platforms?
@@ -2506,6 +2608,7 @@ static int Linux_Misc_Version(EvalContext *ctx) | |||
nt_static_assert((sizeof(version)) > 255); | |||
sscanf(sp + strlen("DISTRIB_RELEASE="), "%255[^\n]", version); | |||
CanonifyNameInPlace(version); | |||
SysOSVersionMinorPutFromVersion(ctx, "", version, "source=agent, derived-from=/etc/lsb_release"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SysOSVersionMinorPutFromVersion(ctx, "", version, "source=agent, derived-from=/etc/lsb_release"); | |
SysOSVersionMinorPutFromVersion(ctx, "", version, "source=agent, derived-from-file=/etc/lsb_release"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's still failing on some platforms, AIX 7.1 at least; https://ci.cfengine.com/job/testing-pr/label=PACKAGES_ppc64_aix_71/2892/testReport/junit/._01_vars_01_basic_os_version_minor/cf/os_version_minor_cf/
No description provided.