Skip to content
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

Add kernel eof info check #808

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion hotsos/core/plugins/kernel/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
import os
import re
from functools import cached_property
from datetime import datetime

from hotsos.core.host_helpers.cli import CLIHelper
from hotsos.core import host_helpers, plugintools
from hotsos.core.config import HotSOSConfig
from hotsos.core.log import log
from hotsos.core.plugins.kernel.config import KernelConfig
from hotsos.core.plugins.system import SystemBase


# NOTE(dosaboy): when updating this, refer to the kernel supported versions
# page: https://ubuntu.com/about/release-cycle#ubuntu-kernel-release-cycle
KERNEL_EOL_INFO = {
'5.19':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page includes the kernel EOL info for 6.5, but 5.19 is now absent (IDK if it was ever present).

Also, I found the distro-info-data Debian package which includes this CSV file with all the ubuntu release lifecycle information. Still, it does not include the supported kernels for each release -- might be useful for checking the release itself's EOL status.

{'22.04.5': datetime(2027, 4, 30),
'20.04.0': datetime(2025, 4, 30)},
'5.13':
{'21.10': datetime(2022, 6, 30),
'20.04.4': datetime(2022, 6, 30)},
'5.11':
{'21.04': datetime(2022, 1, 30),
'20.04.3': datetime(2022, 1, 30)},
'5.8':
{'20.10': datetime(2021, 6, 30),
'20.04.2': datetime(2021, 6, 30),
'18.04.5': datetime(2028, 4, 30),
'20.04.1': datetime(2030, 4, 30),
'20.04.0': datetime(2030, 4, 30)},
'4.15':
{'16.04.5': datetime(2021, 4, 30),
'18.04.1': datetime(2023, 4, 30),
'18.04.0': datetime(2023, 4, 30)},
'4.4':
{'16.04.1': datetime(2021, 4, 30),
'16.04.0': datetime(2021, 4, 30),
'14.04.5': datetime(2019, 4, 30)},
'3.13':
{'14.04.1': datetime(2019, 4, 30),
'14.04.1': datetime(2019, 4, 30)},
}


class KernelBase(object):
Expand All @@ -18,7 +54,38 @@ def version(self):
if ret:
return ret[1]

return ""
return ''

@cached_property
def days_to_eol(self):
if self.version == '':
log.warning("kernel version could not be determined.")
return

ret = re.match('(\d{1,2}.\d{1,2}).\d{1,2}\S+', self.version)
if not ret:
log.warning("unable to determine eol info for kernel "
"version '%s' - could not extract version",
self.version)
return

eol = KERNEL_EOL_INFO.get(ret.group(1))
if eol is None:
log.warning("unable to determine eol info for kernel "
"version '%s' (%s)", self.version, ret.group(1))
return

os_version = SystemBase().os_version
eol = eol.get(os_version)
if eol is None:
log.warning("unable to determine eol info for kernel "
"version '%s' and os version '%s'", self.version,
os_version)
return

today = datetime.utcfromtimestamp(int(CLIHelper().date()))
delta = (eol - today).days
return delta

@cached_property
def isolcpus_enabled(self):
Expand Down
9 changes: 9 additions & 0 deletions hotsos/core/plugins/system/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def os_release_name(self):
if ret:
return "ubuntu {}".format(ret[1])

@cached_property
def os_version(self):
data_source = os.path.join(HotSOSConfig.data_root, "etc/lsb-release")
if os.path.exists(data_source):
for line in open(data_source).read().split():
ret = re.compile(r"^DISTRIB_RELEASE=(.+)").match(line)
if ret:
return ret[1]

@cached_property
def virtualisation_type(self):
"""
Expand Down
16 changes: 16 additions & 0 deletions hotsos/defs/scenarios/kernel/eol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
checks:
is_eol:
property:
path: hotsos.core.plugins.kernel.KernelBase.days_to_eol
ops: [[le, 0]]
conclusions:
is-eol:
decision: is_eol
raises:
type: KernelWarning
message: >-
This node is running a kernel version that is End of Life (release={version})
which means it has limited support and is likely not receiving updates
anymore. Please consider upgrading to a newer release.
format-dict:
version: hotsos.core.plugins.kernel.KernelBase.version
12 changes: 12 additions & 0 deletions hotsos/defs/tests/scenarios/kernel/eol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
data-root:
files:
sos_commands/kernel/uname_-a: |
Linux compute4 4.15.0-97-generic #110-Ubuntu SMP Thu Jan 13 18:22:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
copy-from-original:
- etc/lsb-release
raised-issues:
KernelWarning: >-
This node is running a kernel version that is End of Life
(version=3.4.0) which means it has limited support and is
likely not receiving updates anymore. Please consider upgrading
to a newer release.
Loading