Add option to disable event log
Add option to allow users switch off event logs manually if there are some errors with it's work Partially implements blueprint event-log Change-Id: Ic298c308dcbcb3fbb96a16ce1a069930e774b0cf
This commit is contained in:
parent
c0cc1fe808
commit
6c7cd93983
@ -444,6 +444,9 @@
|
|||||||
# trust for Swift object access. (list value)
|
# trust for Swift object access. (list value)
|
||||||
#proxy_user_role_names = Member
|
#proxy_user_role_names = Member
|
||||||
|
|
||||||
|
# Disables event log feature. (boolean value)
|
||||||
|
#disable_event_log = false
|
||||||
|
|
||||||
|
|
||||||
[cinder]
|
[cinder]
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ def list_opts():
|
|||||||
from sahara.service.edp import job_utils
|
from sahara.service.edp import job_utils
|
||||||
from sahara.service import periodic
|
from sahara.service import periodic
|
||||||
from sahara.service import volumes
|
from sahara.service import volumes
|
||||||
|
from sahara.utils import cluster_progress_ops as cpo
|
||||||
from sahara.utils.openstack import heat
|
from sahara.utils.openstack import heat
|
||||||
from sahara.utils.openstack import neutron
|
from sahara.utils.openstack import neutron
|
||||||
from sahara.utils.openstack import nova
|
from sahara.utils.openstack import nova
|
||||||
@ -148,7 +149,8 @@ def list_opts():
|
|||||||
job_utils.opts,
|
job_utils.opts,
|
||||||
periodic.periodic_opts,
|
periodic.periodic_opts,
|
||||||
volumes.opts,
|
volumes.opts,
|
||||||
proxy.opts)),
|
proxy.opts,
|
||||||
|
cpo.event_log_opts)),
|
||||||
(api.conductor_group.name,
|
(api.conductor_group.name,
|
||||||
itertools.chain(api.conductor_opts)),
|
itertools.chain(api.conductor_opts)),
|
||||||
(cinder.cinder_group.name,
|
(cinder.cinder_group.name,
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sahara import conductor
|
from sahara import conductor
|
||||||
@ -26,6 +27,7 @@ class FakeInstance(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.id = uuid.uuid4()
|
self.id = uuid.uuid4()
|
||||||
self.name = uuid.uuid4()
|
self.name = uuid.uuid4()
|
||||||
|
self.cluster_id = uuid.uuid4()
|
||||||
|
|
||||||
|
|
||||||
class ClusterProgressOpsTest(base.SaharaWithDbTestCase):
|
class ClusterProgressOpsTest(base.SaharaWithDbTestCase):
|
||||||
@ -158,3 +160,23 @@ class ClusterProgressOpsTest(base.SaharaWithDbTestCase):
|
|||||||
None, instance.id, instance.name, None)
|
None, instance.id, instance.name, None)
|
||||||
with context.InstanceInfoManager(info):
|
with context.InstanceInfoManager(info):
|
||||||
tg.spawn("make_checks", self._make_checks, info)
|
tg.spawn("make_checks", self._make_checks, info)
|
||||||
|
|
||||||
|
@cpo.event_wrapper(True)
|
||||||
|
def _do_nothing(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@mock.patch('sahara.utils.cluster_progress_ops._find_in_args')
|
||||||
|
@mock.patch('sahara.utils.general.check_cluster_exists')
|
||||||
|
def test_event_wrapper(self, p_check_cluster_exists, p_find):
|
||||||
|
self.override_config("disable_event_log", True)
|
||||||
|
self._do_nothing()
|
||||||
|
|
||||||
|
self.assertEqual(0, p_find.call_count)
|
||||||
|
|
||||||
|
self.override_config("disable_event_log", False)
|
||||||
|
p_find.return_value = FakeInstance()
|
||||||
|
p_check_cluster_exists.return_value = False
|
||||||
|
self._do_nothing()
|
||||||
|
|
||||||
|
self.assertEqual(1, p_find.call_count)
|
||||||
|
self.assertEqual(1, p_check_cluster_exists.call_count)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
@ -25,6 +26,16 @@ from sahara import context
|
|||||||
from sahara.utils import general as g
|
from sahara.utils import general as g
|
||||||
|
|
||||||
conductor = c.API
|
conductor = c.API
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
event_log_opts = [
|
||||||
|
cfg.BoolOpt('disable_event_log',
|
||||||
|
default=False,
|
||||||
|
help="Disables event log feature.")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
CONF.register_opts(event_log_opts)
|
||||||
|
|
||||||
|
|
||||||
def add_successful_event(instance):
|
def add_successful_event(instance):
|
||||||
@ -56,7 +67,7 @@ def add_fail_event(instance, exception):
|
|||||||
|
|
||||||
|
|
||||||
def add_provisioning_step(cluster_id, step_name, total):
|
def add_provisioning_step(cluster_id, step_name, total):
|
||||||
if not g.check_cluster_exists(cluster_id):
|
if CONF.disable_event_log or not g.check_cluster_exists(cluster_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
update_provisioning_steps(cluster_id)
|
update_provisioning_steps(cluster_id)
|
||||||
@ -69,7 +80,7 @@ def add_provisioning_step(cluster_id, step_name, total):
|
|||||||
|
|
||||||
|
|
||||||
def get_current_provisioning_step(cluster_id):
|
def get_current_provisioning_step(cluster_id):
|
||||||
if not g.check_cluster_exists(cluster_id):
|
if CONF.disable_event_log or not g.check_cluster_exists(cluster_id):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
update_provisioning_steps(cluster_id)
|
update_provisioning_steps(cluster_id)
|
||||||
@ -85,7 +96,7 @@ def get_current_provisioning_step(cluster_id):
|
|||||||
|
|
||||||
|
|
||||||
def update_provisioning_steps(cluster_id):
|
def update_provisioning_steps(cluster_id):
|
||||||
if not g.check_cluster_exists(cluster_id):
|
if CONF.disable_event_log or not g.check_cluster_exists(cluster_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
ctx = context.ctx()
|
ctx = context.ctx()
|
||||||
@ -127,7 +138,7 @@ def update_provisioning_steps(cluster_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_cluster_events(cluster_id, provision_step=None):
|
def get_cluster_events(cluster_id, provision_step=None):
|
||||||
if not g.check_cluster_exists(cluster_id):
|
if CONF.disable_event_log or not g.check_cluster_exists(cluster_id):
|
||||||
return []
|
return []
|
||||||
update_provisioning_steps(cluster_id)
|
update_provisioning_steps(cluster_id)
|
||||||
if provision_step:
|
if provision_step:
|
||||||
@ -161,6 +172,8 @@ def event_wrapper(mark_successful_on_exit, **spec):
|
|||||||
def decorator(func):
|
def decorator(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def handler(*args, **kwargs):
|
def handler(*args, **kwargs):
|
||||||
|
if CONF.disable_event_log:
|
||||||
|
return func(*args, **kwargs)
|
||||||
step_name = spec.get('step', None)
|
step_name = spec.get('step', None)
|
||||||
instance = _find_in_args(spec, *args, **kwargs)
|
instance = _find_in_args(spec, *args, **kwargs)
|
||||||
cluster_id = instance.cluster_id
|
cluster_id = instance.cluster_id
|
||||||
|
Loading…
Reference in New Issue
Block a user