Code review comment for ~d0ugal/maas-images:release-notifications

Revision history for this message
Lee Trager (ltrager) wrote :

I would just use the full version form(2.8.0), even if we aren't going to notify on micro versions. The backend always uses the full version. You can then validate it with a regex(\d+\.\d+\.\d+) to ensure not only is it a string but its in the right form.

Whenever reading data from a remote client and server you should assume the data is bad. It shouldn't matter to MAAS if the version is float(2.8) or str(2.8), the data is the same. Thats why people like strongly typed languages for things like this :)

MAAS should do something like this:

from provisioningserver.utils.version import get_maas_version, get_maas_version_tuple

maas_version = get_version_tuple(get_maas_version())
version_for_notification = get_version_tuple(str(version))

if version_for_notification > maas_version:
    # Show notification

This will work if version is a string or float. Using the existing version code also allows this to work for micro versions(e.g 2.9.1) as well. I did find a bug with get_version_tuple though(LP:1896826) due to the MAAS version containing an epoch now.

« Back to merge proposal