[17:39] Hey rharper and blackboxsw I just saw your message. Was at a team event all day yesterday. [17:39] np [17:39] @rharper: I see you got a PR up, looking at it now [17:39] great [17:40] How did testing go? [17:40] all seems well on the branch I proposed [17:40] i can run things the way you do, as well as using a --deb, etc [17:41] oh so images launch? [17:41] I think the two core issues were the missing start() in the image.py and using vm_name vs. image_id [17:41] yes [17:42] Nice, two birds with one stone. I suppose that permanently fixes the ssh issue? [17:42] I believe so [17:50] I was also looking into preserve instance, have you looked into that. Since I delete the resource group, the instance gets deleted when reserve instance gets invoked. I have a fix in mind to not delete the resource group, but the user would be in charge of deleting it. What do you think @rharper and @blackboxsw? [17:51] ahosmanMSFT: w.r.t preserve-instance, I do believe that's expected; it may be useful to emit the resource group name in the logging , something like "No removing resourse group %s due to --preserve-instance setting; requires manual removal" [17:55] Great, that's what I was thinking. Is preserve instance passed as a boolean? [17:57] Also @rharper, approved the PR is another reviewer needed [17:58] ahosmanMSFT: yes, boolean, and yes blackboxsw or Odd_Bloke will need to review as well [18:03] Ok @rharper looking into that now [18:07] nice [18:11] @rharper In stages.py preserve_instance is initialized and destroys VM if False, this doesn't account for the resource group. [18:11] How would you like this done [18:11] I can omit the destruction of the resource group but I would have to add to stages [18:12] which should be generic by nature [18:57] Hey all, always being dragged off somewhere after answering the question. [18:57] I am trying to find out how cloud-init can be told to mkswap and swapon a swap disk - most specifically a swap disk, not a swap file. [18:58] This doesn't appear to be enough: [18:58] fs_setup: - label: vidi device: /dev/xvde filesystem: ext4 - label: swap device: /dev/xvdg filesystem: swapmounts:- [ /dev/xvde, /var/lib/vidispine, ext4, defaults, 0, 0 ]- [ /dev/xvdg, none, swap, sw, 0, 0 ] [18:58] minfrin: can you paste somewhere with fomatting? can't quite grok that. [18:59] https://paste.ubuntu.com would work [18:59] I'm assuming that's part of #cloud-config [19:00] or paste.openstack.org maybe [19:01] Yep, formatting a bit stuffed. Here is a paste: https://paste.ubuntu.com/p/TpjfznyJZJ/ [19:10] thx, ok valid yaml. [19:12] minfrin: missing something like a top-level swap: key maybe? [19:13] minfrin: like this maybe https://paste.ubuntu.com/p/sg7Wky7tZ9/ [19:16] I'm not totally sure, just looking through the code in cloudinit/config/cc_mounts.py https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_mounts.py#L458-L467 [19:16] it looks like needsswap is set True if the overall cloud-config contains a top-level "swap" key with definitions [19:16] and then swapon gets called https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_mounts.py#L510L511 [19:19] ahosmanMSFT: I'll take a look [19:19] @rharper: I actually have a fix [19:20] https://paste.ubuntu.com/p/4KzMXmjCKS/ [19:20] update azurecloudtest/platform.destroy [19:21] can you add that with your fix, so we can get it merged faster [19:21] ahosmanMSFT: I suspect we want some sort of args passed down into the Instance or Image class from stages [19:21] ahosmanMSFT: no, we'll do this in a separate PR [19:21] ok [19:22] rharper: Did that with the paste, what do you think? I can push the PR [19:23] @blackboxsw: If I'm reading this correctly from https://github.com/canonical/cloud-init/blob/06e324ff8edb3126e5a8060757a48ceab2b1a121/cloudinit/config/cc_mounts.py#L481 - if line[2] is swap we get swapon. [19:25] blackboxsw: In theory this line should be enough to trigger a swapon? [19:25] - [ /dev/xvdg, none, swap, sw, 0, 0 ] [19:30] * minfrin tries https://paste.ubuntu.com/p/sg7Wky7tZ9/ [19:36] @rharper: https://github.com/canonical/cloud-init/compare/master...AOhassan:azurecitestsupdate?expand=1 [19:55] blackboxsw: Configured as per the paste, the mkswap fails as per the paste: https://paste.ubuntu.com/p/6pBDvzsST8/ [19:56] It looks like despite no maxsize being passed, cloud-init passes the empty string: [19:56] Command: ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap', ''] [19:56] That then fails, as expected: [19:56] ahosmanMSFT: I don't think that's goign to work, as we need the PlatformComponent instance from collect_test_data() in collect; I suspect we may want to pass the args.preserve_instance setting into the partial so the platform instance retains this setting [19:56] Stderr: mkswap: invalid block count argument: '' [20:30] blaackboxsw: Looks like with maxsize passed, we're still passed the empty string. [20:34] interesting minfrin, could be a bug there. trying to see if we had an integration tests covering this [20:34] hrm nope [20:35] minfrin: have an updated #cloud-config snippet you could paste [20:35] ? [20:38] blackboxsw: afaict, there's not way with swap: to create this against a block device, which is what it sounds like minfrin wants; I would suggest to use bootcmd: ['mkswap', '/dev/xxxx']; and then a mount: entry [20:39] in general the swapfile is more portable which is why cloud-init prefers that; if you capture an image from an instance, the configured swap goes with it; vs having to ensure you have a secondary disk always present at a specific location [20:41] rharper: minfrin while I keep making wild guesses at this :) I also noticed Odd_Bloke's cloud-config test for swap SRU test was referencing just the device name, not the full device path https://github.com/cloud-init/ubuntu-sru/blob/master/bugs/b59870ca.txt#L16-L28 [20:41] I've raised this as a bug here: https://bugs.launchpad.net/cloud-init/+bug/1862417 [20:41] Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Undecided,New] [20:41] thanks for the bug minfrin, we can respond there. [20:42] Passing the empty string as the "size" parameter definitely looks odd. [20:43] blackboxsw: well, the swap cloud-config specifies filename, but we don't specifically say it cannot be an existing block device; but the code as written isn't going to correctly mkswap on a disk or partition; and I don't think it was intended to; [20:43] as I mentioned, it's non-portable with image capture; that doesn't mean cloudinit can't support mkswap on devices; [20:47] What confused me was examples that showed swap disks being created, but not examples where mkswap was included. [20:49] minfrin: which example? [20:50] minfrin: also in your bug, I see you specified mount_default_fields: [ None, None, "auto", "defaults", "0", "2" ] [20:50] I think proper yaml should be none instead of None. otherwise it is treated as the string "None" [20:51] instead of python's None [20:51] not sure if that affects things or not [20:53] sorry I mean null in yaml [20:53] example of what I mean https://paste.ubuntu.com/p/4M7nFWWBnQ/ [20:56] though I realize that cloud-config is documented in cloud-init's rtd page. we must have a mapping that sets that appropriately [21:00] rharper: this is what I worked from: https://cloudinit.readthedocs.io/en/latest/topics/examples.html#adjust-mount-points-mounted? [21:01] funny also that those docs there say: # complete. This must be an array, and must have 7 fields. [21:01] yet the docs provide a list of 6 items [21:01] the comments field [21:01] minfrin: thanks [21:02] even in code defvals = [None, None, "auto", def_mnt_opts, "0", "2"] 6 items. I'll propose a tiny doc fix for that aspect now [21:06] hrm, somethings strange, as the fs_setup config for swap shouldn't have the trailing '' ; I see it [21:07] it's a disk, so cc_disk_setup uses lookup_force_flag and passes in the filesystem type, and swap is not one of the types, so it returns '' [21:07] which is appended to the cmd and fails [21:09] rharper: but it checks if force_flag: before trying to append '' [21:09] right [21:09] so I think it rejects that [21:09] just saw that [21:09] so... how did it get the extra '' ? [21:09] * blackboxsw was wondering about fs_opts being non-zero [21:09] I have a unittest that does not fail [21:09] fs_cfg.get('extra_opts', []) [21:09] but I can't see where extra_opts comes from [21:09] yeah [21:09] yeah, this is very strange [21:10] minfrin: do you see a log in /var/log/cloud-init.log like "Using cmd: " just after a log "Creating file system %s on %s" [21:11] minfrin: actually if possible. please attach the tarfile of 'cloud-init collect-logs' to your bug https://bugs.launchpad.net/cloud-init/+bug/1862417 [21:11] Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Undecided,New] [21:11] then we can check it out [21:13] ohh well I guess that's reported anyway in Command: ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap', ''] [21:13] blackboxsw: well, I'd like to confirm the while log and the user-data that was provided ... [21:13] I'm just not seeing how we can get an extra element in the code path [21:13] yeah in either case the logs would help [21:13] yeah same [21:22] I looked in the source, and the only reference to mkswap is here: https://github.com/canonical/cloud-init/blob/06e324ff8edb3126e5a8060757a48ceab2b1a121/cloudinit/config/cc_mounts.py#L264 [21:23] This is the version we are using: [21:23] ii cloud-init 19.4-33-gbb4131a2-0ubuntu1~18.04.1 all Init scripts for cloud instances [21:23] minfrin: and here: https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_disk_setup.py#L971 [21:24] that gets constructed becauase mkfs.swap utiltiy doesn't exist [21:24] im testing the supplied config in openstack instanc enow [21:24] this is the module where the problem lies [21:24] cc_disk_setup.py somehow [21:24] cc_disk_setup [21:25] yeah somewhere in https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_disk_setup.py#L984-L996 [21:25] where we are getting another '' injected [21:25] 2020-02-07 21:25:08,540 - cc_disk_setup.py[WARNING]: Force flag for swap is unknown. [21:25] 2020-02-07 21:25:08,541 - cc_disk_setup.py[DEBUG]: Creating file system swap on /dev/vdc [21:25] 2020-02-07 21:25:08,541 - cc_disk_setup.py[DEBUG]: Using cmd: ['/sbin/mkswap', '/dev/vdc', '-L', 'swap'] [21:25] 2020-02-07 21:25:08,541 - util.py[DEBUG]: Running command ['/sbin/mkswap', '/dev/vdc', '-L', 'swap'] with allowed return codes [0] (shell=False, capture=True) [21:25] 2020-02-07 21:25:08,627 - util.py[DEBUG]: Creating fs for /dev/vdc took 0.103 seconds [21:27] I updated https://bugs.launchpad.net/cloud-init/+bug/1862417 with the full log. [21:27] Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Medium,Incomplete] [21:27] thanks minfrin [21:27] and success on rharper's side. [21:27] hrm [21:28] minfrin: at a min, the swap: config needs to go [21:28] it writes a file on top of the block device; which messes things up [21:31] Removing the swap section still shows the mkswap with the extra empty string at the end. [21:31] yeah, that's the part I don't get [21:31] so somethings disconnected between what you're running/user-data and cloud-init code [21:34] Github's search is not that great, I stumbled on this PR: https://github.com/canonical/cloud-init/pull/143 [21:34] Looks like a fix about a month ago. [21:35] but you show 19.4-33 [21:36] which has the fix [21:36] but maybe, you don't have that version ? [21:36] which would explain the failure [21:37] The machine I'm working on uses cloud-init to update itself, it might only have the fix after the updates. [21:37] ah, interesting [21:37] cat /etc/cloud/build.info [21:37] that'll give us a point in time for which version you have [21:38] and I suspect you're right, the top of your cloud-init.log will the original version [21:38] build_name: serverserial: 20190514 [21:38] Definitely way older than the PR. [21:38] yep [21:39] I suspect the fix in our case is to use the latest image of Ubuntu from end Jan 2020. [21:39] yep [21:39] and drop the swap: section; [21:39] otherwise, things look good on my recent images with similar cloud-config [21:43] https://paste.ubuntu.com/p/y8JBCrfK9K/ [22:00] rharper: Is this the force flag issue that was fixed recently? [22:00] Oh, I was scrolled up. [22:00] Odd_Bloke: indeed it was [22:00] < rharper> Yes. [22:01] :) [22:01] minfrin: found the PR and we confirmed the image in use was out of date [22:01] and we can have a PR to update the lookup_flags to add the -f [22:01] for fstype swap [22:06] Thanks for the help getting to the bottom of this, I appreciate it. [22:16] minfrin: yw [22:29] Managed to confirm - very latest Ubuntu Bionix image is fixed: [22:29] 2020-02-07 22:21:09,266 - cc_disk_setup.py[WARNING]: Force flag for swap is unknown.2020-02-07 22:21:09,266 - cc_disk_setup.py[DEBUG]: Creating file system swap on /dev/xvdg2020-02-07 22:21:09,266 - cc_disk_setup.py[DEBUG]: Using cmd: ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap']2020-02-07 22:21:09,266 - util.py[DEBUG]: Running command [22:29] ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap'] with allowed return codes [0] (shell=False, capture=True)2020-02-07 22:21:09,290 - util.py[DEBUG]: Creating fs for /dev/xvdg took 0.058 seconds [22:31] minfrin: nice! [22:32] https://github.com/canonical/cloud-init/pull/207 [22:32] I put that up for the warning