Revision 2c404217 daemons/ganeti-watcher

b/daemons/ganeti-watcher
88 88
    utils.LockFile(self.statefile.fileno())
89 89

  
90 90
    try:
91
      self._data = serializer.Load(self.statefile.read())
91
      state_data = self.statefile.read()
92
      if not state_data:
93
        self._data = {}
94
      else:
95
        self._data = serializer.Load(state_data)
92 96
    except Exception, msg:
93 97
      # Ignore errors while loading the file and treat it as empty
94 98
      self._data = {}
95
      logging.warning(("Empty or invalid state file. Using defaults."
99
      logging.warning(("Invalid state file. Using defaults."
96 100
                       " Error message: %s"), msg)
97 101

  
98 102
    if "instance" not in self._data:
......
440 444
  try:
441 445
    notepad = WatcherState()
442 446
    try:
443
      client = cli.GetClient()
447
      try:
448
        client = cli.GetClient()
449
      except errors.OpPrereqError:
450
        # this is, from cli.GetClient, a not-master case
451
        sys.exit(constants.EXIT_SUCCESS)
444 452

  
445 453
      try:
446 454
        watcher = Watcher(options, notepad)

Also available in: Unified diff