GoogleCloudPlatform / compute-image-packages

Packages for Google Compute Engine Linux images.
https://cloud.google.com/compute/docs/images
Apache License 2.0
372 stars 213 forks source link

Several scripts failing at boot on FreeBSD caused by wrong syslog socket in hardcoded config #731

Closed rhclayto closed 5 years ago

rhclayto commented 5 years ago

These compute image packages are failing on boot on FreeBSD 11.2, Python 2.7, google-compute-engine version 2.8.6: google_instance_setup, google_clock_skew_daemon, google_accounts_daemon. Logs included below. The reason is that the logger is trying to log to a socket at /dev/log, but on FreeBSD, the syslog socket is at /var/run/log.

ln -s /var/run/log /dev/log fixes this, but does not survive a reboot. For now I am doing this in a stratup script (or will be just after I post this, I haven't tried it yet but it should work).

Related to, but not solved by, https://github.com/GoogleCloudPlatform/compute-image-packages/issues/445 , since the FreeBSD syslog socket is in a different place than expected by the scripts. In logger.py:

if facility:
    # Create a handler for sending logs to SysLog.
    syslog_handler = logging.handlers.SysLogHandler(
        address='/dev/log', facility=facility)
    syslog_handler.setLevel(logging.INFO)
    syslog_handler.setFormatter(formatter)
    logger.addHandler(syslog_handler)
Starting google_instance_setup.
Traceback (most recent call last):
  File "/usr/local/bin/google_instance_setup", line 11, in <module>
    load_entry_point('google-compute-engine==2.8.6', 'console_scripts', 'google_instance_setup')()
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/instance_setup/instance_setup.py", line 214
, in main
    InstanceSetup(debug=bool(options.debug))
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/instance_setup/instance_setup.py", line 46,
 in __init__
    name='instance-setup', debug=self.debug, facility=facility)
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/logger.py", line 49, in Logger
    address='/dev/log', facility=facility)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 761, in __init__
    self._connect_unixsocket(address)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 804, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/local/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory
Starting google_clock_skew_daemon.
Traceback (most recent call last):
  File "/usr/local/bin/google_clock_skew_daemon", line 11, in <module>
    load_entry_point('google-compute-engine==2.8.6', 'console_scripts', 'google_clock_skew_daemon')()
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/clock_skew/clock_skew_daemon.py", line 74, 
in main
    ClockSkewDaemon(debug=bool(options.debug))
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/clock_skew/clock_skew_daemon.py", line 44, 
in __init__
    name='google-clock-skew', debug=debug, facility=facility)
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/logger.py", line 49, in Logger
    address='/dev/log', facility=facility)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 761, in __init__
    self._connect_unixsocket(address)
Traceback (most recent call last):
  File "/usr/local/bin/google_metadata_script_runner", line 11, in <module>
  File "/usr/local/lib/python2.7/logging/handlers.py", line 804, in _connect_unixsocket
    load_entry_point('google-compute-engine==2.8.6', 'console_scripts', 'google_metadata_script_runner')()
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/metadata_scripts/script_manager.py", line 1
09, in main
    self.socket.connect(address)
  File "/usr/local/lib/python2.7/socket.py", line 228, in meth
    debug=bool(options.debug))
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/metadata_scripts/script_manager.py", line 6
5, in __init__
    self.logger = logger.Logger(name=name, debug=debug, facility=facility)
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/logger.py", line 49, in Logger
    return getattr(self._sock,name)(*args)
    address='/dev/log', facility=facility)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 761, in __init__
    self._connect_unixsocket(address)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 804, in _connect_unixsocket
socket.error: [Errno 2] No such file or directory
Starting google_accounts_daemon.
Traceback (most recent call last):
  File "/usr/local/bin/google_accounts_daemon", line 11, in <module>
    load_entry_point('google-compute-engine==2.8.6', 'console_scripts', 'google_accounts_daemon')()
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/accounts/accounts_daemon.py", line 282, in 
main
    debug=bool(options.debug))
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/accounts/accounts_daemon.py", line 57, in _
_init__
    name='google-accounts', debug=debug, facility=facility)
  File "/usr/local/lib/python2.7/site-packages/google_compute_engine/logger.py", line 49, in Logger
    address='/dev/log', facility=facility)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 761, in __init__
    self._connect_unixsocket(address)
  File "/usr/local/lib/python2.7/logging/handlers.py", line 804, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/local/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory
    self.socket.connect(address)
  File "/usr/local/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory
illfelder commented 5 years ago

Merged a fix into development. Feel free to make a followup PR if that doesn't resolve the compatibility issues.