Thomas Vachuska
Committed by Gerrit Code Review

ONOS-3453 Fixed an issue with a race condition in loading/installing apps from d…

…isk in multi-cluster environments.

Fixed onos-gen-partitions.

Change-Id: Iadbb86119477b52d29a80515fc42e3d90012a216
...@@ -237,12 +237,22 @@ public class ApplicationManager ...@@ -237,12 +237,22 @@ public class ApplicationManager
237 boolean changed = false; 237 boolean changed = false;
238 for (String name : app.features()) { 238 for (String name : app.features()) {
239 Feature feature = featuresService.getFeature(name); 239 Feature feature = featuresService.getFeature(name);
240 +
241 + // If we see an attempt at activation of a non-existent feature
242 + // attempt to install the app artifacts first and then retry.
243 + // This can be triggered by a race condition between different ONOS
244 + // instances "installing" the apps from disk at their own pace.
245 + // Perhaps there is a more elegant solution to be explored in the
246 + // future.
247 + if (feature == null) {
248 + installAppArtifacts(app);
249 + feature = featuresService.getFeature(name);
250 + }
251 +
240 if (feature != null && !featuresService.isInstalled(feature)) { 252 if (feature != null && !featuresService.isInstalled(feature)) {
241 featuresService.installFeature(name); 253 featuresService.installFeature(name);
242 changed = true; 254 changed = true;
243 - } else if (feature == null && !initializing) { 255 + } else if (feature == null) {
244 - // Suppress feature-not-found reporting during startup since these
245 - // can arise naturally from the staggered cluster install.
246 log.warn("Feature {} not found", name); 256 log.warn("Feature {} not found", name);
247 } 257 }
248 } 258 }
......
...@@ -11,8 +11,7 @@ from collections import deque, OrderedDict ...@@ -11,8 +11,7 @@ from collections import deque, OrderedDict
11 import re 11 import re
12 import json 12 import json
13 import sys 13 import sys
14 -import random 14 +import hashlib
15 -import string
16 15
17 convert = lambda text: int(text) if text.isdigit() else text.lower() 16 convert = lambda text: int(text) if text.isdigit() else text.lower()
18 alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)] 17 alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
...@@ -46,7 +45,7 @@ if __name__ == '__main__': ...@@ -46,7 +45,7 @@ if __name__ == '__main__':
46 partitions = generate_permutations([v.get('id') for v in nodes], 3) 45 partitions = generate_permutations([v.get('id') for v in nodes], 3)
47 name = 0 46 name = 0
48 for node in nodes: 47 for node in nodes:
49 - name = name ^ node['ip'] 48 + name = name ^ hash(node['ip'])
50 data = { 49 data = {
51 'name': name, 50 'name': name,
52 'nodes': nodes, 51 'nodes': nodes,
......