Browse Source

Separate out adding and deleting repair scripts

Currently, any change in the repair cfg is considered as a new
react script being registered. To change that add a _get_repairs
function, and form a list of audits to create/nuke.

Change-Id: I5c039f0fee3ef79e864493ace9cde366dc87a381
Pranesh Pandurangan 4 years ago
parent
commit
d0e9ace151
1 changed files with 19 additions and 3 deletions
  1. 19
    3
      entropy/engine.py

+ 19
- 3
entropy/engine.py View File

@@ -118,7 +118,8 @@ class Engine(object):
118 118
             self.futures.append(self._serializer)
119 119
 
120 120
         # Start react scripts.
121
-        self.futures.extend(self.start_react_scripts())
121
+        self.futures.extend(self.start_react_scripts(
122
+            self._get_react_scripts()))
122 123
 
123 124
         scheduler = self.executor.submit(self.schedule)
124 125
         self.futures.append(scheduler)
@@ -236,7 +237,19 @@ class Engine(object):
236 237
 
237 238
     def repair_modified(self):
238 239
         LOG.info('Repair configuration changed')
239
-        self.futures.extend(self.start_react_scripts())
240
+        repairs = self._get_react_scripts()
241
+        new_repairs = {}
242
+        repairs_to_delete = []
243
+        for repair in repairs:
244
+            if repair not in self.running_repairs:
245
+                new_repairs[repair] = repairs[repair]
246
+        if self.running_repairs:
247
+            for repair in self.running_repairs:
248
+                if repair not in repairs:
249
+                    repairs_to_delete.append(repair)
250
+        LOG.info('Will add new repairs: %s', new_repairs)
251
+        LOG.info('Will nuke repairs: %s', repairs_to_delete)
252
+        self.futures.extend(self.start_react_scripts(new_repairs))
240 253
 
241 254
     def start_watchdog(self):
242 255
         LOG.debug('Watchdog mapping is: ', self._watchdog_event_fn)
@@ -269,8 +282,11 @@ class Engine(object):
269 282
             LOG.exception("Could not run all audits in %s at %s",
270 283
                           audit_list, execution_time)
271 284
 
272
-    def start_react_scripts(self):
285
+    def _get_react_scripts(self):
273 286
         repairs = self._backend_driver.get_repairs()
287
+        return repairs
288
+
289
+    def start_react_scripts(self, repairs):
274 290
         futures = []
275 291
         if repairs:
276 292
             for script in repairs:

Loading…
Cancel
Save