Browse Source

Fix errors caused by wrong rebasing

The conversion of self.ENABLED ot states.ENABLED got mixed up in
a following commit. Just a commit to repair that stuff.

Change-Id: I4ab4c6b35dc04d281f52184f035e86c15b269044
Pranesh Pandurangan 4 years ago
parent
commit
b6a1d3d1e1
2 changed files with 15 additions and 8 deletions
  1. 11
    8
      entropy/engine.py
  2. 4
    0
      entropy/exceptions.py

+ 11
- 8
entropy/engine.py View File

@@ -128,7 +128,7 @@ class Engine(object):
128 128
         self._watchdog_thread.join()
129 129
 
130 130
     def schedule(self):
131
-        while self._state == self.ENABLED:
131
+        while self._state == states.ENABLED:
132 132
             (next_time, next_jobs) = self.wait_next(self.engine_timeout)
133 133
             # NOTE(praneshp): here, call a function that will wait till next
134 134
             # time and call next_jobs,
@@ -169,12 +169,12 @@ class Engine(object):
169 169
         now = datetime.datetime.now()
170 170
         cron = croniter.croniter(schedule, now)
171 171
         next_iteration = cron.get_next(datetime.datetime)
172
-        while self._state == self.ENABLED:
172
+        while self._state == states.ENABLED:
173 173
             LOG.info('It is %s, next serializer at %s', now, next_iteration)
174 174
             pause.until(next_iteration)
175 175
             now = datetime.datetime.now()
176 176
             next_iteration = cron.get_next(datetime.datetime)
177
-            if self._state == self.ENABLED:
177
+            if self._state == states.ENABLED:
178 178
                 self.run_serializer(next_iteration, now)
179 179
 
180 180
     def run_serializer(self, next_iteration, current_time):
@@ -182,6 +182,7 @@ class Engine(object):
182 182
         audits = self._backend_driver.get_audits()
183 183
         schedules = {}
184 184
         if not audits:
185
+            LOG.info('No audits to run, returning')
185 186
             return
186 187
         try:
187 188
             for audit_name in audits:
@@ -204,13 +205,14 @@ class Engine(object):
204 205
 
205 206
             # NOTE(praneshp): Protect this operation with a state check, so in
206 207
             # case of race conditions no extra audit scripts are added.
207
-            if self._state == self.ENABLED:
208
+            if self._state == states.ENABLED:
208 209
                 self.run_queue.extend(new_additions)
209 210
             LOG.info("Run queue till %s is %s", next_iteration, self.run_queue)
210 211
             LOG.info("Repair scripts at %s: %s", next_iteration, self._repairs)
211
-        except Exception:
212
-            LOG.exception("Could not run serializer for %s at %s",
213
-                          self.name, current_time)
212
+        except Exception as e:
213
+            raise exceptions.SerializerException(
214
+                "Could not run serializer for %s at %s" %
215
+                (self.name, current_time), e)
214 216
 
215 217
     def engine_disabled(self):
216 218
         engine_config = dict(utils.load_yaml(self.engine_cfg))[self.name]
@@ -220,6 +222,7 @@ class Engine(object):
220 222
     def stop_engine(self):
221 223
         LOG.info("Stopping engine %s", self.name)
222 224
         # Set state to stop, which will stop serializers
225
+        self._state = states.DISABLED
223 226
         # Clear run queue
224 227
         LOG.info("Clearing audit run queue for %s", self.name)
225 228
         self.run_queue.clear()
@@ -243,7 +246,7 @@ class Engine(object):
243 246
         try:
244 247
             pause.until(execution_time)
245 248
             # Only proceed if engine is running, i.e in enabled state.
246
-            if self._state != self.ENABLED:
249
+            if self._state != states.ENABLED:
247 250
                 LOG.info("%s is disabled, so not running audits at %s",
248 251
                          self.name, execution_time)
249 252
                 return

+ 4
- 0
entropy/exceptions.py View File

@@ -45,3 +45,7 @@ class NoSuchEngineException(EntropyException):
45 45
 
46 46
 class NoEnginesException(EntropyException):
47 47
     """Exception raised when there are no known engines."""
48
+
49
+
50
+class SerializerException(EntropyException):
51
+    """Exception raised when the serializer fails."""

Loading…
Cancel
Save