From 8b0ac576c778b380ff341ce4022b4d1f83aa7021 Mon Sep 17 00:00:00 2001 From: Marcel Enguehard Date: Wed, 12 Apr 2017 10:44:55 +0200 Subject: Updated LXD image in tutorials + new tutorial + Changed logs for LXD NotFound to warnings + Number of workers is now a function of the number of CPUs Change-Id: I926ac0e86cd2c594c3f9fce7e20e80a385b4f56a Signed-off-by: Marcel Enguehard --- vicn/core/resource_mgr.py | 18 +++++++++--------- vicn/core/task.py | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'vicn') diff --git a/vicn/core/resource_mgr.py b/vicn/core/resource_mgr.py index c71e0444..b750f555 100644 --- a/vicn/core/resource_mgr.py +++ b/vicn/core/resource_mgr.py @@ -802,7 +802,7 @@ class ResourceManager(metaclass=Singleton): if ENABLE_LXD_WORKAROUND and \ (isinstance(e, LxdNotFound) or isinstance(e, LXDAPIException)): new_state = AttributeState.RESET - log.error('LXD Fix (not found). Reset attribute') + log.warning('LXD Fix (not found). Reset attribute') resource._state.attr_change_success[attribute.name] = True else: log.error('Attribute error {} for resource {}'.format( @@ -894,7 +894,7 @@ class ResourceManager(metaclass=Singleton): if ENABLE_LXD_WORKAROUND and \ (isinstance(attrs, LxdNotFound) or isinstance(attrs, LXDAPIException)): new_state = AttributeState.RESET - log.error('LXD Fix (not found). Reset attribute') + log.warning('LXD Fix (not found). Reset attribute') resource._state.attr_change_success[attribute.name] = True else: self.attr_log(resource, attribute, @@ -927,7 +927,7 @@ class ResourceManager(metaclass=Singleton): if ENABLE_LXD_WORKAROUND and \ (isinstance(attrs, LxdNotFound) or isinstance(attrs, LXDAPIException)): new_state = AttributeState.RESET - log.error('LXD Fix (not found). Reset attribute') + log.warning('LXD Fix (not found). Reset attribute') resource._state.attr_change_success[attribute.name] = True else: log.error('Attribute error {} for resource {}'.format( @@ -1373,13 +1373,13 @@ class ResourceManager(metaclass=Singleton): # "not found" is the normal exception when the container # does not exists. anyways the bug should only occur # with container.execute(), not container.get() - log.error('LXD Fix (not found). Reset resource') + log.warning('LXD Fix (not found). Reset resource') new_state = ResourceState.INITIALIZED elif ENABLE_LXD_WORKAROUND and isinstance(e, LXDAPIException): # "not found" is the normal exception when the container # does not exists. anyways the bug should only occur # with container.execute(), not container.get() - log.error('LXD Fix (API error). Reset resource') + log.warning('LXD Fix (API error). Reset resource') new_state = ResourceState.INITIALIZED elif isinstance(e, ResourceNotFound): # The resource does not exist @@ -1403,7 +1403,7 @@ class ResourceManager(metaclass=Singleton): self.log(resource, 'KEYS failed: {}'.format(e)) if ENABLE_LXD_WORKAROUND and isinstance(e, LxdNotFound): - log.error('LXD Fix (not found). Reset resource') + log.warning('LXD Fix (not found). Reset resource') new_state = ResourceState.CREATED resource._state.change_success = True else: @@ -1421,12 +1421,12 @@ class ResourceManager(metaclass=Singleton): e = resource._state.change_value if ENABLE_LXD_WORKAROUND and isinstance(e, LxdNotFound): - log.error('LXD Fix (not found). Reset resource') + log.warning('LXD Fix (not found). Reset resource') new_state = ResourceState.INITIALIZED resource._state.change_success = True elif ENABLE_LXD_WORKAROUND and \ isinstance(e, LXDAPIException): - log.error('LXD Fix (API error). Reset resource') + log.warning('LXD Fix (API error). Reset resource') new_state = ResourceState.INITIALIZED resource._state.change_success = True elif 'File exists' in str(e): @@ -1453,7 +1453,7 @@ class ResourceManager(metaclass=Singleton): self.log(resource, 'UPDATE failed: {}'.format(e)) if ENABLE_LXD_WORKAROUND and isinstance(e, LxdNotFound): - log.error('LXD Fix (not found). Reset resource') + log.warning('LXD Fix (not found). Reset resource') new_state = ResourceState.CREATED resource._state.change_success = True resource._state.write_lock.release() diff --git a/vicn/core/task.py b/vicn/core/task.py index 5aecb40b..9c92ef4d 100644 --- a/vicn/core/task.py +++ b/vicn/core/task.py @@ -22,6 +22,7 @@ import functools import logging import shlex import subprocess +import os from vicn.core.scheduling_algebra import SchedulingAlgebra from vicn.core.commands import ReturnValue @@ -34,7 +35,8 @@ log = logging.getLogger(__name__) EXECUTOR=concurrent.futures.ThreadPoolExecutor #EXECUTOR=concurrent.futures.ProcessPoolExecutor -MAX_WORKERS = 50 # None +#Sets the number of task workers to the number of CPU threads+1 +MAX_WORKERS = os.cpu_count()+1 class BaseTask: """Base class for all tasks -- cgit 1.2.3-korg