/srv/irclogs.ubuntu.com/2020/02/12/#cloud-init.txt

=== hggdh is now known as hggdh-msft
otuboDo we ever check the kernel version inside cloud-init? I'm trying to grep for an example but can't find it.09:21
otuboLong story short, on my (already closed) PR[0] I recently found out that the fallocate on XFS bug is hit only on kernels < 4.18 (reference: man 8 swapon).09:23
otuboSo I'd like to introduce a condition ` and util.system_info()['release'] >= '4.18'' to the if statement to cloudinit/config/cc_mounts.py:25209:26
otuboCouldn't find any trace of packaging.version.parse for that matter, though. Not sure if cloud-init already does this kind of version comparisons in the code base.09:26
otubo[0] https://github.com/canonical/cloud-init/pull/7009:27
meenaotubo: what would packaging.version.parse contain? do we already produce a system_info()['release']?10:07
otubomeena: packaging.version.parse contains parsers for standard versions systems, we could do things like version.parser(util.system_info()['release']) > version.parse("4.18") for example10:09
otubomeena: yes we already have util.system_info()['release'] in place10:09
meenaotubo: cut it down to only have a max of one `.` and then compare them like floats :P10:10
meenaI think i did that somewhere in puppet code… and… i'm not proud of it, but not ashamed of it either :P10:10
otubo:-D if it works, it works10:11
meena>>> float(str.join('.', os.uname()[2].split('.')[0:2]))10:23
meena4.1510:23
meenathis is ugly, and not safe.10:23
otubomeena: my dear god11:27
meenaotubo: i'm sure there's a less worse way to do this11:35
meenaotubo: https://regex101.com/r/6XkWS3/211:54
meenarather, /3. no one should have negative versions >_>11:56
meenaand /4 more performant without those flags.11:57
meenanow with tests, https://regex101.com/r/6XkWS3/5/tests — that website is wonderful 😅12:06
anankewonder if the sample test I added now shows up for others12:14
anankenah, looks like it would have to be forked12:15
otubomeena: OMG! That's helpful. Thanks! :-)13:10
DanyChi, question - running "cloud-init clean --log --seed" will that be enough for cloud-init to run again the "modules-final/config-scripts" if i'm cloning from this VM ?14:05
DanyCor do i need to delete "/run/cloud-init/" dir too to erase any state which might make cloud-init think is not a "first time boot" ?14:06
meenaDanyC: i'd think that's what `clean` does. though i don't know what --seed does14:10
DanyCmeena: thanks14:12
Odd_Blokeotubo: So a danger with matching on kernel versions is that "4.18" on one distro can be very different to "4.18" on others.  However, in this case, I think the two cases we need to worry about are: (a) a version older than 4.18 which has support/fixes backported, and (b) a version that claims to be (at least) 4.18 but doesn't have the support/fixes.  I feel like we can safely dismiss (b), because that15:22
Odd_Blokeseems likely to be a kernel bug/regression.  For (a), I think the worst case is that we use dd when we could have used fallocate, which isn't a very bad case at all.15:22
=== cpaelzer__ is now known as cpaelzer
Odd_Blokemeena: I don't think you can compare kernel versions as floats, because kernel version 4.18 > kernel version 4.4 but 4.18 < 4.4.15:30
meenaOdd_Bloke: wat15:32
meenaOdd_Bloke: aah, shite.15:32
Odd_Bloke:)15:32
rharperthe cheaty way is to break major minor into ints15:32
Odd_BlokeYeah, (4, 18) > (4, 4).15:32
* rharper may have cheated a few times15:32
meenayeah, that way you can compare all dots? (4, 18, 1)15:33
meenawhooaaaah.15:33
meenarharper: that's so cool15:34
Odd_BlokeIt's barely even cheating, that's why `sys.version_info` is a tuple, so you can do things like `sys.version_info > (3, 3)` for Python version checks.15:34
meenaTIL15:34
meenawonder if that works in ruby, too15:34
meenacuz i'm having to teach a developer here what Semver is…15:35
meenaor, all developers.?15:35
Odd_BlokeIt's probably sufficient for kernel major/minor/patch, but it falls over if your versioning has prereleases or postreleases (like apt packages do).15:35
rharperit just gets strange with extra parts, 4.15.0-72-generic15:35
meenarharper: LA LA LA LAAAAA15:35
Odd_BlokeI don't know what you're talking about meena, we just happen to rev major versions on January 1st every year. ;)15:36
rharper=)15:36
meenaOdd_Bloke: that's 💯 % valid15:36
meenahttp://sentimentalversioning.org/15:41
Odd_BlokeI can only aspire to have an idea as good as using pi for version numbers.15:46

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!