Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

kernel: Create tool to check for new LTS kernel releases #253

Merged
merged 1 commit into from
Jan 31, 2018
Merged

kernel: Create tool to check for new LTS kernel releases #253

merged 1 commit into from
Jan 31, 2018

Conversation

erick0z
Copy link

@erick0z erick0z commented Jan 20, 2018

We need to be notified when new LTS kernel releases are available to ensure we
update the guest kernel in a timely fashion.
This commit adds documentation and a script which can check the latest kernel info
and notify via email if a new LTS version is released.

Fixes #246

Signed-off-by: Erick Cardona [email protected]

@erick0z erick0z added the wip label Jan 20, 2018
Copy link

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks - This is going to be very useful! A few comments...

@@ -0,0 +1,101 @@
#!/usr/bin/env python3
#
# Copyright (c) 2017 Intel Corporation

Choose a reason for hiding this comment

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

2018?

email_recipients="root@localhost"

def get_current_lts():
lts_file=script_path + "/current_lts_kernel"

Choose a reason for hiding this comment

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

I'd be tempted to put the current LTS version in ../versions.txt so that all versions are kept in one place.

logging.info("current_lts_kernel file updated!")

def send_email(new_lts):
email_body="A new LTS version of the Linux kernel is out: " + new_lts

Choose a reason for hiding this comment

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

I'd include the current LTS kernel version too as that will allow us to have an extra "visual check" (hopefully we'll notice the "impossible scenario" where current == new for example).

Requirements:

* python3
* python dependencies (see requirements file)

Choose a reason for hiding this comment

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

Could you add a link to this file?


## `kernel_monitor/kernel_monitor.py`

This script fetch the latest kernel information and look for new LTS releases.

Choose a reason for hiding this comment

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

This script fetches the latest kernel information and looks for new LTS releases.

## `kernel_monitor/kernel_monitor.py`

This script fetch the latest kernel information and look for new LTS releases.
If a new LTS release is found, this script is able to send email to the selected

Choose a reason for hiding this comment

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

I'd make this even simpler. Something like,

If it finds a new LTS release it sends an email to the selected recipients.

$ pip install -r requirements
```

Set distro_certs variable to /etc/ssl/certs/ca-bundle.crt:

Choose a reason for hiding this comment

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

Could you add backticks around that path: /etc/ssl/certs/ca-bundle.crt.

# email config
smtp_hostname='127.0.0.1'
email_sender="[email protected]"
email_recipients="root@localhost"

Choose a reason for hiding this comment

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

How about making these command-line options?

distro_certs = "/etc/ssl/certs/ca-bundle.crt"

# Log file path
logfile="./example.log"

Choose a reason for hiding this comment

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

This could be a command-line option. Also, I'd change the default to something like kernel_monitor.log.

@jodh-intel
Copy link

@klynnrif - could you take a look at the doc changes please?

Copy link

@klynnrif klynnrif left a comment

Choose a reason for hiding this comment

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

I've suggested a few changes, and agree with the rewrites @jodh-intel made on lines 47 and 48. Thanks!


Usage:

NOTE: Supposing we have a Fedora 27 system with all requirements met and a postfix

Choose a reason for hiding this comment

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

Lines 60-61 suggested rewrite: NOTE: The following commands can be executed if you have a Fedora 27 system that meets all requirements, and a postfix server running on 127.0.0.1 or localhost.


Set distro_certs variable to /etc/ssl/certs/ca-bundle.crt:

NOTE: This path may change based on the Linux distribution you are using (see kernel_monitor.py).

Choose a reason for hiding this comment

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

NOTE: This path might change based on...

sed -i "s/distro_certs = .*/distro_certs = \"\/etc\/ssl\/certs\/ca-bundle.crt\"/" kernel_monitor.py
```

Execute the script:

Choose a reason for hiding this comment

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

Execute the following script:

$ ./kernel_monitor.py
```

This will send an email to `root@localhost` if there is a new LTS release and log

Choose a reason for hiding this comment

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

This sends an email to...

@erick0z erick0z removed the wip label Jan 22, 2018
@erick0z
Copy link
Author

erick0z commented Jan 22, 2018

@jodh-intel @klynnrif Thank you! I've addressed your comments.

For more information about the complete usage:
```
$ ./kernel_monitor.py --help
Linux Kernel LTS monitor script.

Choose a reason for hiding this comment

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

I would recommend removing the output of this command here - one day, the options will change and we'll forget to update the doc as well as the usage statement in the script itself.


NOTE: This path might change based on the Linux distribution you are using (see kernel_monitor.py).
```
sed -i "s/distro_certs = .*/distro_certs = \"\/etc\/ssl\/certs\/ca-bundle.crt\"/" kernel_monitor.py

Choose a reason for hiding this comment

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

Couple of points:

  • This line would need a $ prompt.
  • I'm really not sure we want users to modify the script itself. Could you add an option for specifying the path to the certs file to avoid this?

$ ./kernel_monitor.py
```

This sends an email to `root@localhost` if there is a new LTS release and log

Choose a reason for hiding this comment

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

I'd remove root@localhost and the logfile name here (which I think is now incorrect?) and explain that running, ./kernel_monitor.py --help will show where the emails will be sent and which logfile will be used.

# by the distro of your choice. This is needed to retrieve the xml file.
# Fedora => /etc/ssl/certs/ca-bundle.crt
# Ubuntu => /etc/ssl/certs/ca-certificates.crt
distro_certs = "/etc/ssl/certs/ca-bundle.crt"

Choose a reason for hiding this comment

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

  • This won't work for Clear Linux.
  • I think we need a CLI option to specify this path (or have it auto-detected based on distro?)

@erick0z
Copy link
Author

erick0z commented Jan 26, 2018

Hey @jodh-intel, I've now added a distro-certificates discovery functionality (good idea!). It works on Clear Linux as well 😄

@jodh-intel
Copy link

Hi @erick0z - nice.

For total paranoia, it would probably be safer to only check known locations for each distro (and ensure the file is owned by root:root and not writable). However, I think the current approach is sufficient given that it simply returns a version and we then separately attempt to download that version from a known site using curl (which already knows where to find the correct certs).

lgtm

@klynnrif - could you re-review please?

Copy link

@klynnrif klynnrif left a comment

Choose a reason for hiding this comment

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

One small change suggested unless it changes the meaning. Thanks!

$ ./kernel_monitor.py
```

This sends an email if there is a new LTS release and log the events to a file.

Choose a reason for hiding this comment

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

.....is a new LTS release and logs the events to a file.

We need to be notified when new LTS kernel releases are available to ensure we
update the guest kernel in a timely fashion.
This commit adds a documentation and a script which can check the latest kernel info
and notify via email if a new LTS version is released.

Fixes #246

Signed-off-by: Erick Cardona <[email protected]>
@erick0z
Copy link
Author

erick0z commented Jan 30, 2018

thanks! @klynnrif

@jodh-intel jodh-intel merged commit e5d4a22 into clearcontainers:master Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants