diff options
author | Mike Gerdts <mike.gerdts@joyent.com> | 2018-04-23 09:29:39 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2018-04-23 09:29:39 -0400 |
commit | 4ed164592fe8cb15758cacf3cb3f8c7d5ab7c82e (patch) | |
tree | 5221b585bbeec35b46140b09f4e4396bab53503a /cloudinit | |
parent | 23479881f51bae7a3f5743ce677ed82317ea8b9f (diff) | |
download | vyos-cloud-init-4ed164592fe8cb15758cacf3cb3f8c7d5ab7c82e.tar.gz vyos-cloud-init-4ed164592fe8cb15758cacf3cb3f8c7d5ab7c82e.zip |
DataSourceSmartOS: add locking of serial device.
cloud-init and mdata-get each have their own implementation of the
SmartOS metadata protocol. If cloud-init and other services that call
mdata-get are run concurrently, crosstalk on the serial port can cause
them both to become confused.
This change makes it so that cloud-init uses the same cooperative
locking scheme that's used by mdata-get, thus preventing cross-talk
between mdata-get and cloud-init.
For testing, a VM running on a SmartOS host and pyserial are required.
If the tests are run on a platform other than SmartOS, those that use a
real serial port are skipped. pyserial remains commented in
requirements.txt because most testers will not be running atop SmartOS.
LP: #1746605
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/DataSourceSmartOS.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 0ef10035..4ea00eb1 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -23,6 +23,7 @@ import base64 import binascii import errno +import fcntl import json import os import random @@ -526,6 +527,7 @@ class JoyentMetadataSerialClient(JoyentMetadataClient): if not ser.isOpen(): raise SystemError("Unable to open %s" % self.device) self.fp = ser + fcntl.lockf(ser, fcntl.LOCK_EX) self._flush() self._negotiate() |