@cryptotaxi247 / netdata-1 / commits / 92d4a74ad

ci: handle boolean values in EOL API responses for newly released distros (#20792)

* ci: handle boolean values in EOL API responses for newly released distros * fix imports order

Ilya Mashchenko committed Aug 11, 2025 at 13:49 UTC 92d4a74ad73ea997d369214eac467806ef4ffd7c
1 file changed +47 -10
.github/scripts/platform-impending-eol.py
+47 -10
@@ -1,9 +1,9 @@
1 #!/usr/bin/env python3
2 -'''Check if a given distro is going to be EOL soon.
2 +"""Check if a given distro is going to be EOL soon.
3
4 This queries the public API of https://endoflife.date to fetch EOL dates.
5
6 - ‘soon’ is defined by LEAD_DAYS, currently 30 days.'''
6 + 'soon' is defined by LEAD_DAYS, currently 30 days."""
7
8 import datetime
9 import json
@@ -24,38 +24,75 @@ EXIT_NO_DATA = 2
24 EXIT_FAILURE = 3
25
26 try:
27 - with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
27 + with urllib.request.urlopen(f'{URL_BASE}/{DISTRO}/{RELEASE}.json') as response:
28 match response.status:
29 case 200:
30 data = json.load(response)
31 case _:
32 print(
33 - f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
34 - f'(status: { response.status }).',
33 + f'Failed to retrieve data for {DISTRO} {RELEASE} ' +
34 + f'(status: {response.status}).',
35 file=sys.stderr
36 )
37 sys.exit(EXIT_FAILURE)
38 except urllib.error.HTTPError as e:
39 match e.code:
40 case 404:
41 - print(f'No data available for { DISTRO } { RELEASE }.', file=sys.stderr)
41 + print(f'No data available for {DISTRO} {RELEASE}.', file=sys.stderr)
42 sys.exit(EXIT_NO_DATA)
43 case _:
44 print(
45 - f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
46 - f'(status: { e.code }).',
45 + f'Failed to retrieve data for {DISTRO} {RELEASE} ' +
46 + f'(status: {e.code}).',
47 file=sys.stderr
48 )
49 sys.exit(EXIT_FAILURE)
50
51 -
51 if LTS == '1' and 'extendedSupport' in data:
52 ref = 'extendedSupport'
53 else:
54 ref = 'eol'
55 LTS = False
56
58 -eol = datetime.date.fromisoformat(data[ref])
57 +# Handle boolean values for eol/extendedSupport fields
58 +eol_value = data[ref]
59 +
60 +# Check if the value is a boolean
61 +if isinstance(eol_value, bool):
62 + if ref == 'eol':
63 + if not eol_value:
64 + # False for eol means no EOL date set (still actively supported)
65 + sys.exit(EXIT_NOT_IMPENDING)
66 + else:
67 + # True for eol would mean EOL has occurred (unusual, but handle it)
68 + # Without a date, we can't determine if it's within LEAD_DAYS
69 + # Conservative approach: treat as impending
70 + print(f'{DISTRO} {RELEASE} has reached EOL (boolean true)', file=sys.stderr)
71 + sys.exit(EXIT_IMPENDING)
72 + elif ref == 'extendedSupport':
73 + if not eol_value:
74 + # False for extendedSupport when LTS was requested is unexpected
75 + print(
76 + f'Unexpected value for {DISTRO} {RELEASE} extendedSupport: false ' +
77 + '(LTS was requested but extended support is not available)',
78 + file=sys.stderr
79 + )
80 + sys.exit(EXIT_FAILURE)
81 + else:
82 + # True for extendedSupport means LTS available but date not determined
83 + # Can't calculate if impending without a date
84 + sys.exit(EXIT_NOT_IMPENDING)
85 +
86 +# If we get here, it should be a date string
87 +try:
88 + eol = datetime.date.fromisoformat(eol_value)
89 +except (ValueError, TypeError):
90 + print(
91 + f'Invalid date format for {DISTRO} {RELEASE} {ref}: {eol_value}',
92 + file=sys.stderr
93 + )
94 + sys.exit(EXIT_FAILURE)
95 +
96 offset = abs(eol - NOW)
97
98 if offset <= LEAD_DAYS: