Commit 2c404217 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix the output of watcher on non-master nodes

Currently the watcher spews errors message on non-master nodes. This
cleans it up.

Reviewed-by: imsnah
parent 6dfcc47b
...@@ -88,11 +88,15 @@ class WatcherState(object): ...@@ -88,11 +88,15 @@ class WatcherState(object):
utils.LockFile(self.statefile.fileno()) utils.LockFile(self.statefile.fileno())
try: try:
self._data = serializer.Load( state_data =
if not state_data:
self._data = {}
self._data = serializer.Load(state_data)
except Exception, msg: except Exception, msg:
# Ignore errors while loading the file and treat it as empty # Ignore errors while loading the file and treat it as empty
self._data = {} self._data = {}
logging.warning(("Empty or invalid state file. Using defaults." logging.warning(("Invalid state file. Using defaults."
" Error message: %s"), msg) " Error message: %s"), msg)
if "instance" not in self._data: if "instance" not in self._data:
...@@ -440,7 +444,11 @@ def main(): ...@@ -440,7 +444,11 @@ def main():
try: try:
notepad = WatcherState() notepad = WatcherState()
try: try:
client = cli.GetClient() try:
client = cli.GetClient()
except errors.OpPrereqError:
# this is, from cli.GetClient, a not-master case
try: try:
watcher = Watcher(options, notepad) watcher = Watcher(options, notepad)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment