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

ahosmanMSFTHey rharper and blackboxsw I just saw your message. Was at a team event all day yesterday.17:39
rharpernp17:39
ahosmanMSFT@rharper: I see you got a PR up, looking at it now17:39
rharpergreat17:39
ahosmanMSFTHow did testing go?17:40
rharperall seems well on the branch I proposed17:40
rharperi can run things the way you do, as well as using a --deb, etc17:40
ahosmanMSFToh so images launch?17:41
rharperI think the two core issues were the missing start() in the image.py and using vm_name vs. image_id17:41
rharperyes17:41
ahosmanMSFTNice, two birds with one stone. I suppose that permanently fixes the ssh issue?17:42
rharperI believe so17:42
ahosmanMSFTI 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:50
rharperahosmanMSFT: 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:51
ahosmanMSFTGreat, that's what I was thinking. Is preserve instance passed as a boolean?17:55
ahosmanMSFTAlso @rharper, approved the PR is another reviewer needed17:57
rharperahosmanMSFT: yes, boolean, and yes blackboxsw or Odd_Bloke will need to review as well17:58
ahosmanMSFTOk @rharper looking into that now18:03
rharpernice18:07
ahosmanMSFT@rharper In stages.py preserve_instance is initialized and destroys VM if False, this doesn't account for the resource group.18:11
ahosmanMSFTHow would you like this done18:11
ahosmanMSFTI can omit the destruction of the resource group but I would have to add to stages18:11
ahosmanMSFTwhich should be generic by nature18:12
minfrinHey all, always being dragged off somewhere after answering the question.18:57
minfrinI 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:57
minfrinThis doesn't appear to be enough:18:58
minfrinfs_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
blackboxswminfrin: can you paste somewhere with fomatting? can't quite grok that.18:58
blackboxswhttps://paste.ubuntu.com would work18:59
blackboxswI'm assuming that's part of #cloud-config18:59
blackboxswor paste.openstack.org maybe19:00
minfrinYep, formatting a bit stuffed. Here is a paste: https://paste.ubuntu.com/p/TpjfznyJZJ/19:01
blackboxswthx, ok valid yaml.19:10
blackboxswminfrin: missing  something like a top-level swap: key maybe?19:12
blackboxswminfrin: like this maybe https://paste.ubuntu.com/p/sg7Wky7tZ9/19:13
blackboxswI'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-L46719:16
blackboxswit looks like needsswap is set True if the overall cloud-config contains a top-level "swap" key with definitions19:16
blackboxswand then swapon gets called https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_mounts.py#L510L51119:16
rharperahosmanMSFT: I'll take a look19:19
ahosmanMSFT@rharper: I actually have a fix19:19
ahosmanMSFThttps://paste.ubuntu.com/p/4KzMXmjCKS/19:20
ahosmanMSFTupdate azurecloudtest/platform.destroy19:20
ahosmanMSFTcan you add that with your fix, so we can get it merged faster19:21
rharperahosmanMSFT: I suspect we want some sort of args passed down into the Instance or Image class from stages19:21
rharperahosmanMSFT: no, we'll do this in a separate PR19:21
ahosmanMSFTok19:21
ahosmanMSFTrharper: Did that with the paste, what do you think? I can push the PR19:22
minfrin@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:23
minfrinblackboxsw: In theory this line should be enough to trigger a swapon?19:25
minfrin- [ /dev/xvdg, none, swap, sw, 0, 0 ]19:25
* minfrin tries https://paste.ubuntu.com/p/sg7Wky7tZ9/19:30
ahosmanMSFT@rharper: https://github.com/canonical/cloud-init/compare/master...AOhassan:azurecitestsupdate?expand=119:36
minfrinblackboxsw: Configured as per the paste, the mkswap fails as per the paste: https://paste.ubuntu.com/p/6pBDvzsST8/19:55
minfrinIt looks like despite no maxsize being passed, cloud-init passes the empty string:19:56
minfrinCommand: ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap', '']19:56
minfrinThat then fails, as expected:19:56
rharperahosmanMSFT: 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 setting19:56
minfrinStderr: mkswap: invalid block count argument: ''19:56
minfrinblaackboxsw: Looks like with maxsize passed, we're still passed the empty string.20:30
blackboxswinteresting minfrin, could be a bug there. trying to see if we had an integration tests covering this20:34
blackboxswhrm nope20:34
blackboxswminfrin: have an updated #cloud-config snippet you could paste20:35
blackboxsw?20:35
rharperblackboxsw: 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:  entry20:38
rharperin 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 location20:39
blackboxswrharper: 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-L2820:41
minfrinI've raised this as a bug here: https://bugs.launchpad.net/cloud-init/+bug/186241720:41
ubot5Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Undecided,New]20:41
blackboxswthanks for the bug minfrin, we can respond there.20:41
minfrinPassing the empty string as the "size" parameter definitely looks odd.20:42
rharperblackboxsw: 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
rharperas I mentioned, it's non-portable with image capture;  that doesn't mean cloudinit can't support mkswap on devices;20:43
minfrinWhat confused me was examples that showed swap disks being created, but not examples where mkswap was included.20:47
rharperminfrin: which example?20:49
blackboxswminfrin: also in your bug, I see you specified  mount_default_fields: [ None, None, "auto", "defaults", "0", "2" ]20:50
blackboxswI think proper yaml should be none instead of None. otherwise it is treated as the string "None"20:50
blackboxswinstead of python's None20:51
blackboxswnot sure if that affects things or not20:51
blackboxswsorry I mean null in yaml20:53
blackboxswexample of what I mean https://paste.ubuntu.com/p/4M7nFWWBnQ/20:53
blackboxswthough I realize that cloud-config is documented in cloud-init's rtd page. we must have a mapping that sets that appropriately20:56
minfrinrharper: this is what I worked from: https://cloudinit.readthedocs.io/en/latest/topics/examples.html#adjust-mount-points-mounted?21:00
blackboxswfunny also that those docs there say: # complete.  This must be an array, and must have 7 fields.21:01
blackboxswyet the docs provide a list of 6 items21:01
rharperthe comments field21:01
rharperminfrin: thanks21:01
blackboxsweven in code     defvals = [None, None, "auto", def_mnt_opts, "0", "2"]   6 items. I'll propose a tiny doc fix for that aspect now21:02
rharperhrm, somethings strange, as the fs_setup config for swap shouldn't have the trailing '' ;  I  see it21:06
rharperit'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
rharperwhich is appended to the cmd and fails21:07
blackboxswrharper: but it checks             if force_flag: before trying to append ''21:09
rharperright21:09
blackboxswso I think it rejects that21:09
rharperjust saw that21:09
rharperso... how did it get the extra '' ?21:09
* blackboxsw was wondering about fs_opts being non-zero21:09
rharperI have a unittest that does not fail21:09
rharperfs_cfg.get('extra_opts', [])21:09
blackboxswbut I can't see where extra_opts comes from21:09
blackboxswyeah21:09
rharperyeah, this is very strange21:09
blackboxswminfrin: 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:10
blackboxswminfrin: actually if possible. please attach the tarfile of 'cloud-init collect-logs' to your bug https://bugs.launchpad.net/cloud-init/+bug/186241721:11
ubot5Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Undecided,New]21:11
blackboxswthen we can check it out21:11
blackboxswohh well I guess that's reported anyway in Command: ['/sbin/mkswap', '/dev/xvdg', '-L', 'swap', '']21:13
rharperblackboxsw: well, I'd like to confirm the while log and the user-data that was provided ...21:13
rharperI'm just not seeing how we can get an extra element in the code path21:13
blackboxswyeah in either case the logs would help21:13
blackboxswyeah same21:13
minfrinI 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#L26421:22
minfrinThis is the version we are using:21:23
minfrinii  cloud-init                        19.4-33-gbb4131a2-0ubuntu1~18.04.1  all          Init scripts for cloud instances21:23
blackboxswminfrin: and here: https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_disk_setup.py#L97121:23
blackboxswthat gets constructed becauase mkfs.swap utiltiy doesn't exist21:24
rharperim testing the supplied config in openstack instanc enow21:24
blackboxswthis is the module where  the problem lies21:24
blackboxswcc_disk_setup.py somehow21:24
rharpercc_disk_setup21:24
blackboxswyeah somewhere in https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_disk_setup.py#L984-L99621:25
blackboxswwhere we are getting another '' injected21:25
rharper2020-02-07 21:25:08,540 - cc_disk_setup.py[WARNING]: Force flag for swap is unknown.21:25
rharper2020-02-07 21:25:08,541 - cc_disk_setup.py[DEBUG]: Creating file system swap on /dev/vdc21:25
rharper2020-02-07 21:25:08,541 - cc_disk_setup.py[DEBUG]:      Using cmd: ['/sbin/mkswap', '/dev/vdc', '-L', 'swap']21:25
rharper2020-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
rharper2020-02-07 21:25:08,627 - util.py[DEBUG]: Creating fs for /dev/vdc took 0.103 seconds21:25
minfrinI updated https://bugs.launchpad.net/cloud-init/+bug/1862417 with the full log.21:27
ubot5Ubuntu bug 1862417 in cloud-init "cloud-init: Attempt to mkswap on a partition fails: invalid block count argument: ''" [Medium,Incomplete]21:27
blackboxswthanks minfrin21:27
blackboxswand success on rharper's side.21:27
blackboxswhrm21:27
rharperminfrin: at a min, the swap: config needs to go21:28
rharperit writes a file on top of the block device; which messes things up21:28
minfrinRemoving the swap section still shows the mkswap with the extra empty string at the end.21:31
rharperyeah, that's the part I don't get21:31
rharperso somethings disconnected between what you're running/user-data and cloud-init code21:31
minfrinGithub's search is not that great, I stumbled on this PR: https://github.com/canonical/cloud-init/pull/14321:34
minfrinLooks like a fix about a month ago.21:34
rharperbut you show 19.4-3321:35
rharperwhich has the fix21:36
rharperbut maybe, you don't have that version ?21:36
rharperwhich would explain the failure21:36
minfrinThe machine I'm working on uses cloud-init to update itself, it might only have the fix after the updates.21:37
rharperah, interesting21:37
rharpercat /etc/cloud/build.info21:37
rharperthat'll give us a point in time for which version you have21:37
rharperand I suspect you're right, the top of your cloud-init.log will the original version21:38
minfrinbuild_name: serverserial: 2019051421:38
minfrinDefinitely way older than the PR.21:38
rharperyep21:38
minfrinI suspect the fix in our case is to use the latest image of Ubuntu from end Jan 2020.21:39
rharperyep21:39
rharperand drop the swap: section;21:39
rharperotherwise, things look good on my recent images with similar cloud-config21:39
rharperhttps://paste.ubuntu.com/p/y8JBCrfK9K/21:43
Odd_Blokerharper: Is this the force flag issue that was fixed recently?22:00
Odd_BlokeOh, I was scrolled up.22:00
rharperOdd_Bloke: indeed it was22:00
Odd_Bloke< rharper> Yes.22:00
Odd_Bloke:)22:01
rharperminfrin: found the PR and we confirmed the image in use was out of date22:01
rharperand we can have a PR to update the lookup_flags to add the -f22:01
rharperfor fstype swap22:01
minfrinThanks for the help getting to the bottom of this, I appreciate it.22:06
rharperminfrin: yw22:16
minfrinManaged to confirm - very latest Ubuntu Bionix image is fixed:22:29
minfrin2020-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 command22:29
minfrin['/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 seconds22:29
rharperminfrin: nice!22:31
rharperhttps://github.com/canonical/cloud-init/pull/20722:32
rharperI put that up for the warning22:32

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