Browse code

Chore: make product checks non-blocking if they crash (repairs master install)

Thomas Cataldo authored on 09/10/2019 14:39:15
Showing 2 changed files
... ...
@@ -52,10 +52,12 @@ public class DbCheck extends Verticle implements BundleActivator {
52 52
 		idFactory = new IdFactory("jdbc", metricRegistry, DbCheck.class);
53 53
 
54 54
 		super.vertx.setPeriodic(1000 * 10, (id) -> {
55
-			String coreuid = Topology.get().core().uid;
56
-			check(JdbcActivator.getInstance().getDataSource(), coreuid, "directory");
57
-			JdbcActivator.getInstance().getMailboxDataSource().entrySet().forEach(e -> {
58
-				check(e.getValue(), e.getKey(), "mailbox");
55
+			Topology.getIfAvailable().ifPresent(topo -> {
56
+				String coreuid = topo.core().uid;
57
+				check(JdbcActivator.getInstance().getDataSource(), coreuid, "directory");
58
+				JdbcActivator.getInstance().getMailboxDataSource().entrySet().forEach(e -> {
59
+					check(e.getValue(), e.getKey(), "mailbox");
60
+				});
59 61
 			});
60 62
 		});
61 63
 	}
... ...
@@ -38,9 +38,13 @@ public class ProductChecks {
38 38
 
39 39
 		boolean failed = false;
40 40
 		for (IProductValidator validator : validators) {
41
-			ValidationResult result = validator.validate();
42
-			logger.info("Validator {} : Valid: {}, Message: {}", validator.getName(), result.valid, result.message);
43
-			failed |= !result.valid;
41
+			try {
42
+				ValidationResult result = validator.validate();
43
+				logger.info("Validator {} : Valid: {}, Message: {}", validator.getName(), result.valid, result.message);
44
+				failed |= !result.valid;
45
+			} catch (Exception e) {
46
+				logger.error("Check {} failed ({}), skipping it for now", validator.getName(), e.getMessage());
47
+			}
44 48
 		}
45 49
 
46 50
 		if (failed) {