← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~gholms/cloud-init/nodevconsole into lp:cloud-init

 

Garrett Holmstrom has proposed merging lp:~gholms/cloud-init/nodevconsole into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1228434 in cloud-init: "multi_log can fail when /dev/console is missing"
  https://bugs.launchpad.net/cloud-init/+bug/1228434

For more details, see:
https://code.launchpad.net/~gholms/cloud-init/nodevconsole/+merge/186897

The multi_log function writes directly to /dev/console, which causes utter failure if things happen to be running in a container that doesn't have that device.  This commit sends console-bound output to stdout and lets init take care of getting that to the console.  The upstart jobs are already configured with "console output", so we need only switch the systemd services to "journal+console".
-- 
https://code.launchpad.net/~gholms/cloud-init/nodevconsole/+merge/186897
Your team cloud init development team is requested to review the proposed merge of lp:~gholms/cloud-init/nodevconsole into lp:cloud-init.
=== modified file 'cloudinit/util.py'
--- cloudinit/util.py	2013-09-11 12:30:35 +0000
+++ cloudinit/util.py	2013-09-20 23:44:58 +0000
@@ -360,11 +360,11 @@
     if stderr:
         sys.stderr.write(text)
     if console:
-        # Don't use the write_file since
-        # this might be 'sensitive' info (not debug worthy?)
-        with open('/dev/console', 'wb') as wfh:
-            wfh.write(text)
-            wfh.flush()
+        # Some containers lack /dev/console, so we send output to
+        # stdout and configure upstart with "console output" and
+        # systemd with "journal+console" and let them take care of
+        # getting output to the console.
+        print text
     if log:
         if text[-1] == "\n":
             log.log(log_level, text[:-1])

=== modified file 'systemd/cloud-config.service'
--- systemd/cloud-config.service	2012-08-03 21:40:42 +0000
+++ systemd/cloud-config.service	2013-09-20 23:44:58 +0000
@@ -11,7 +11,7 @@
 TimeoutSec=0
 
 # Output needs to appear in instance console output
-StandardOutput=tty
+StandardOutput=journal+console
 
 [Install]
 WantedBy=multi-user.target

=== modified file 'systemd/cloud-final.service'
--- systemd/cloud-final.service	2012-08-03 21:40:42 +0000
+++ systemd/cloud-final.service	2013-09-20 23:44:58 +0000
@@ -11,7 +11,7 @@
 TimeoutSec=0
 
 # Output needs to appear in instance console output
-StandardOutput=tty
+StandardOutput=journal+console
 
 [Install]
 WantedBy=multi-user.target

=== modified file 'systemd/cloud-init-local.service'
--- systemd/cloud-init-local.service	2012-08-03 21:40:42 +0000
+++ systemd/cloud-init-local.service	2013-09-20 23:44:58 +0000
@@ -10,7 +10,7 @@
 TimeoutSec=0
 
 # Output needs to appear in instance console output
-StandardOutput=tty
+StandardOutput=journal+console
 
 [Install]
 WantedBy=multi-user.target

=== modified file 'systemd/cloud-init.service'
--- systemd/cloud-init.service	2012-08-03 21:40:42 +0000
+++ systemd/cloud-init.service	2013-09-20 23:44:58 +0000
@@ -11,7 +11,7 @@
 TimeoutSec=0
 
 # Output needs to appear in instance console output
-StandardOutput=tty
+StandardOutput=journal+console
 
 [Install]
 WantedBy=multi-user.target


Follow ups