/srv/irclogs.ubuntu.com/2017/11/28/#cloud-init.txt

exarrHi all. Please prepare for some n00b questions.11:59
=== shardy is now known as shardy_afk
exarrSo, I am planning to use openstack with rhel 6.9 and need to learn about cloud-init a bit. But the docs seem to go from "here's a file structure" straight into a here's a load of config.12:00
exarrSo, for an ice-breaker here, how can I set the /etc/hostname from the metadata passed form openstack?12:01
exarrI believe this is a built-in function12:02
exarrnvm, I'm gonna youtube and stop pestering you guys :-)12:04
=== shardy_afk is now known as shardy
smoserbug 173493916:59
ubot5bug 1734939 in cloud-init (Ubuntu) "#include fails silently." [High,Confirmed] https://launchpad.net/bugs/173493916:59
smosersigh16:59
blackboxswhrm did I break that? checking the bug16:59
smoserblackboxsw: no17:08
smoseryou did not.17:08
smoserno idea how long its been broken :-(17:08
rharpersmoser: isn't that bionic no-dns issue? did you try that on xenial instead ?17:23
rharperah, this is a reporting of the failure17:24
smoserrharper: yeah, it is that issue. and will become harder to reproduce if that were fixed :)17:39
smoser(probably we can use 404)17:39
smoserblackboxsw: what am i missing at https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/33351317:39
blackboxswsmoser: was just looking that over. I'm not sure what the prob is.   The new subcommand is 'cloud-init status' not systemctl status17:40
blackboxswI didn't wire that into systemctl cmd entrypoints17:40
blackboxswmaybe it's just a disconnect about what we really want for 'cloud-init status' I was expecting scripts could call into our cli to 'cloud-init status --wait'  if their services needed to hold until cloud-init was done.17:42
blackboxswsmoser: should we instead wire that subcommand into systemctl status so that custom params can be provided?17:43
smoserblackboxsw: i must not have been clear.18:05
smoseryou are using the presense of systemctl binary to indicate "this is systemd"18:05
smoserat least i think18:05
blackboxswsmoser: we mentioned in comment "moving distro.uses_systemd" where should that live? It seems specific to distro-related attributes and be hesitant to further bloat cloudinit.util18:17
blackboxswmaybe it could just be a separate public function in cloudinit.distro instead of a class attribute of Distro18:18
blackboxswcloudinit.distro.__init__18:18
blackboxswthough cloud.distro.uses_systemd() method is called from cc_mounts, ntp, fan and rsyslog modules (as well as rhel/opensuse distros). So, we'd have to explicitly import the public function there and use that instead  (or have Distro.uses_systemd be a wrapper that just calls the separate function uses_systemd).18:22
blackboxswmaybe I'll just do that. I'm in hangout if you want to chat through other options18:22
smoserjoining18:25
blackboxswI could be swayed to moving uses_systemd it to cloudinit.util too. We'll have to take a pass extracting functions out of cloudinit.util anyway at some point to make it more modular and focused18:25
rharpersmoser: surely urllib returns something on DNS resolution failure vs. 40418:29
smoserrharper: right. but shoudl also fail and exit failure on 40418:32
smoserand that is easier to create a test for18:32
smoserthan to break dns18:32
rharperfor sure18:32
rharperI see, you were referring to how to reproduce/test18:32
paulmeyHi all, what's the process for adding features to a datasource?19:38
paulmeyAzure is adding a feature where they are going to keep VM's 'warm' and hold it at boot till a customer needs it...19:39
paulmeyhere's the MP with the code they have been working on https://code.launchpad.net/~dojordan/cloud-init/+git/cloud-init/+merge/334341/+index?ss=119:42
paulmeydo we need an LP bug?19:42
smoserpaulmey: you dont strictly need a bug, but for a feature like that i guess i'd like one. gives a place to "hold"19:48
smoseri'm not bent on it, but its not like it is hard to file a bug either.19:48
paulmeyok, you want a bug... 😉19:56
paulmeyhttps://bugs.launchpad.net/cloud-init/+bug/173499120:02
ubot5Launchpad bug 1734991 in cloud-init "cloud-init doesn't yet support azure vm preprovisioning" [Undecided,New]20:02
blackboxswhrm smoser rharper systemctl status cloud-init.target isn't conclusive. Even when cloud-init is pending (but runcmd is camping on a sleep)20:22
blackboxswthen ActiveState remains 'inactive' and is-enabled remains 'static' until the magical moment when cloud-init is done and transitions to 'enabled'20:22
blackboxswor 'active'20:22
blackboxswI'm looking for another mechanism to detemine 'cloud-init is pending in systemd'20:23
blackboxswit really feels like cloud-init's  manipulation of systemd's $gen_d/${target_name}.wants/${CLOUD_TARGET_NAME} link is our best source of knowing if cloud-init really is going to run20:26
blackboxswor systemctl list-dependencies20:27
blackboxswfeels like systemctl list-dependencies | grep cloud-init.target is probably the best bet20:33
blackboxswas tracking details of the link file names would be fragile if that link path changes in future releases.20:33
rharperblackboxsw: you can query the list of jobs to see if it's pending20:43
rharperI didn't think we needed that state though20:43
rharperthe tri state was (disabled, never going to run), (enabled and is pending), (enabled is done)20:43
rharperis there something missing there?20:43
blackboxswrharper: yeah double checking today on xenial.... we have is-enabled returns 'static' if cloud-init.target is active,  and if it is disabled via kernel cmdline or /etc/cloud/cloud-init.disabled20:45
blackboxswso I can't inspect disabled if we've disabled our systemd generator via /etc/cloud/cloud-init.disabled or kernel cmdline20:46
blackboxsws/inspect/introspec/20:46
rharperI didn't think that was the case20:46
* rharper reads the unit file states again20:46
blackboxswI tried adding a #cloud-config\nruncmd: ['sleep 60']  and I also don't get to see an enabled status untl     http://pastebin.ubuntu.com/26066805/20:48
blackboxswuntil cloud-init.target completes20:49
rharperstatic == off (never going to run)20:49
blackboxswon a system currenty in runcmd final stage http://pastebin.ubuntu.com/26066812/20:49
rharperon xenial the default is (it runs less it's told not to)20:49
rharperie, ds-identify is report-only20:50
blackboxswstatic is on a system where cloud-init is enabled20:50
smoserblackboxsw: https://hastebin.com/raw/qetelayimi20:50
smoserthat is what i put together to collect info.20:50
smoseri ran it for xenial, but yeah, didnt see anything that said "expected to be run"20:50
rharper"static"The unit file is not enabled, and has no provisions for enabling in the "[Install]" unit file section.20:51
blackboxswrharper: then I guess systemd is lying or how cloud-init links or doesn't link the wants file is breaking systemd?20:51
rharpernot following20:51
rharpercloud-init.target gets dynamically installed20:52
rharperso, an at-rest system is going to say static20:52
rharperearly, we generator run, and on xenial, the default is to enable unless we disable via file or cmdline20:52
blackboxswour cloud-init generator only dynamically links for wants file if we don't have /etc/cloud/cloud-init.disabled or the cloud-init=disabled in the kernel cmdline20:52
rharpercorrect20:52
rharperbut you can't run status before the generator runs20:53
rharpera cloud-init user cannot20:53
blackboxswbut systemd is-enabled must be checking something else, because it doesn't report 'enabled' on a system that has those links20:53
rharperit enabled"Enabled via .wants/, .requires/ or Alias= symlinks (permanently in /etc/systemd/system/, or transiently in /run/systemd/system/).20:53
rharperso, once generator adds it to a .wants20:53
rharperthen it will show enabled (that's post generator)20:54
rharperthat means cloud-init status should show *pending* until you have a file that indicates cloud-init is done (result.json)20:54
rharperdisabled;  or pending -> done20:54
blackboxswrharper: here's a system that has already run all of cloud-init note is-enabled still shows 'static'20:54
blackboxswhttp://pastebin.ubuntu.com/26066859/20:54
rharperand you have a result.json ?20:54
blackboxswyeah with no errors20:55
rharperthe output of systemctl isn only relevant when we don't know20:55
rharperwe only need to know, disabled (never going to run, this is 'static') or we have a result file ; if not those cases, then pending20:55
rharperrecall, that is-enabled refers to the *unit* file20:56
rharpernot the active job20:56
rharpersystemd builds a tree of units, for each unit, it spawns a job20:56
rharperthe job runs and is removed from the job queue20:56
smoserwell, cloud-init remain Active when they're done.20:59
rharperthe units, yes20:59
rharperbut really the status command is meant to refer to the runtime element, (ie, the systemd job)20:59
smoserwe're interestd in asking systemd "are you expecting to reach the cloud-init target." thats what we need to know.21:00
smoserwe're not using status now.21:00
smoserwe're using show.21:00
smoserif you're suggesting we look at the unit instead of a target, i dont know if that would hcange anything or not.21:00
rharpera target is just a special unit AFAIK21:01
rharpereven if we ignore the jobs;  I think we have enough, given the result file an disabled; if we're not disabled and we don't have a result file, then we're pending21:02
blackboxswI'm still lacking how we determine that we are disabled. as I don't see anything from systemd cli that properly reports whether we are disabled21:03
smoserright.21:03
smoserthere is nothing there.21:03
smoserits obnoxious21:03
rharperstatic means disabled21:03
blackboxswwe can determine ourselves by looking at cloud-init.disabled OR kernel cmdline21:04
blackboxswstatic also means enabled21:04
blackboxswand not yet run21:04
rharperno it does not21:04
rharperwell, yes, but you can't ask that21:04
rharperbefore the generator runs21:04
smoserstatic does not mean disabled21:04
blackboxswrharper: even after generator runs21:04
blackboxswI still see 'static'21:04
smoserright.21:04
rharperwell, modulo bugs21:05
rharpersystemd says that once it's added to a .wants it's enabled (or enabled-runtime)21:05
rharperso, maybe we have bug in xenial systemd w.r.t state21:05
rharpernotice in artful/bionic21:05
rharperit says enabled-runtime21:05
rharperwhich is the correct answer21:06
rharperin xenial21:06
blackboxswright, artful/bionic look sane. <= zesty behave differently21:06
rharperhttps://www.freedesktop.org/software/systemd/man/systemctl.html#21:06
rharperwell, they have newer systemd21:06
rharperthe man page is pretty clear on this21:06
rharper"enabled"Enabled via .wants/, .requires/ or Alias= symlinks (permanently in /etc/systemd/system/, or transiently in /run/systemd/system/).21:07
rharperso, it should be 'static'; then when generator runs, if enabled, it will transition to enabled (or enabled-runtime) due to a symlnk in /run/systemd/system/multi.user.target.wants/cloud-init.target21:07
rharperI don;t think I'm misreading that man page21:07
smoserthe results differ.21:08
rharperaka, bug in xenial systemd's systemctl status ; are you referring to something else?21:10
rharpers/status/is-enabled21:10
blackboxswhttp://pastebin.ubuntu.com/26066998/21:11
blackboxswreferring to a bug in is-enabled21:11
blackboxswthe above is on zesty21:11
blackboxswrunning in an enabled world first, then disabled 2nd21:11
rharpernot the units, the target21:12
rharperwe only put cloud-init.target in .wants in /run21:12
blackboxswI ran against cloud-init, cloud-init.target and cloud-init.service21:12
rharperso querying the unit files (cloud-init-local , cloud-init, cloud-config, cloud-final) isn't helpful21:13
rharperblackboxsw: right, but do target only on artful/bionic21:13
rharperdoes it not report enabled-* vs. static ?21:13
blackboxswrharper: right we are good on artful ++ http://pastebin.ubuntu.com/26067021/21:14
blackboxswjust broken on xenial & zesty (from our point of view)21:14
rharperok, so we file a bug21:15
rharperso we can get proper is-enabled status for cloud-init.target21:15
rharperI don't think any other trickery is going to help w.r.t systemd commands21:15
* rharper relocates21:15
blackboxswsmoser/rharper: Ok so, systemctl list-dependencies does give us an idea about 'pending' cloud-init wants target, and 'systemctl is-enabled' works on artful and above.    But,  filing a bug aside, it's probably just best for us to only look at the /etc/cloud/cloud-init.disabled file and kernel cmdline for determining if we are disabled for the time being, if not disabled... assume pending until result.json21:19
blackboxswexists right?21:19
blackboxswthe other gap in that logic (checking disabled file or cmdline) is ds-identify disabling us21:21
blackboxswmaybe the 'fix' is for ds-dentify to precipitate a /etc/cloud/cloud-init.disabled file with 'disabled by ds-identify' content.21:21
blackboxswthen we've covered that gap without relying on older systemd tooling which doesn't currently work21:22
smoserblackboxsw: writing something. almost done.21:24
smoserhttp://paste.ubuntu.com/26067095/21:26
smoserblackboxsw: ^21:30
smoserbasically, forget about asking systemd. it seems useless to me21:30
blackboxswreading21:30
blackboxswyeah agreed on systemd21:30
blackboxswnot enough info there yet (but we'll file a bug)21:31
blackboxswahh didn't realize the ds-identify writes an enabled file21:31
blackboxswok so yeah we can look for presence of (disabled file or kernel cmdline disable) or absence of /run/cloud-init/enabled21:34
blackboxswthat makes sense (and works today)21:34
blackboxswok, smoser I'm not going to move around the uses_systemd function/method then as we don't need it21:35
smoserwell, blackboxsw when not running on systemd21:39
blackboxswsmoser why does that matter?21:40
blackboxswas sysvinit is always on?21:40
blackboxswbecause there is no generator?21:40
smoserright21:40
blackboxswroger21:40
smoserthe generator writes /run/cloud-init/enabled21:40
blackboxswahh right times two21:40
blackboxswok keeping uses_systemd :/21:41
smoseron systemd we get that benefit. -- easy and complete knowledge of "disabled".21:41
blackboxswhahah21:41
smoserwell, assuming we do not run before the generator21:41
smoserbut i'm willing to acept that for now.21:41
rharperwe can check whether the cloud-init generator has run via the /run/cloud-init dir presence21:46
rharperthat can catch the inb4-cloud-init-generator case21:46
blackboxswsure ds-identify creates that dir if it doesn't exist21:50
smoserrharper: well, but the generator creates that21:50
smoserno?21:50
rharperyes21:50
rharperso, if the dir doesn't exist21:50
blackboxswI see it in ds-identify21:51
rharperthen it hasn't run21:51
rharperthat's for the case of testing status before the generator runs21:51
rharperif we wanted to support status that early, we could say something like (too early) or whatever21:51
rharperask-later21:51
blackboxswlooks like both generator and ds-identify try to create that dir if !present21:51
smoseroh. well we can't determine what the status is anyway then.  we can know we're in that state i guess.21:51
rharperright, similar to systemd-analyze saying 'boot not finished yet'21:52
rharpernot particulary helpful but it is some sort of non-answer-answer21:52
rharperI'm perfectly fine with not handling the case as that's super early21:53
smoserin my tests with my script above, we're in at "1.0" seconds per lxc's /proc/uptime.21:55
smoserand it exists already.21:55
smoserthere isnt a *lot* of opportunity to run 'cloud-init wait' earlier than that21:55
smoserie:21:55
smoser lxc start name;  lxc exec name -- cloud-init wait21:55
blackboxswfinally wrapped it up and overhauled cloud-init status to use cloudinit.helpers.Paths object https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/33351323:56

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