lolwww / charm-cinder-oceanstor

Huawei Oceanstor Cinder backend support for a Juju/Charms deployed OpenStack
2 stars 2 forks source link

when iscsiinitiators is None, jinja2.exceptions.UndefinedError: 'None' has no attribute 'split' #7

Closed nobuto-m closed 3 years ago

nobuto-m commented 3 years ago

iscsiinitiators is None by default. We can set ''(empty string) to the config in the bundle, but it's dangerous since if we run the bundle again, then it will reset iscsiinitiators to empty even if it's set by an operator.

unit-cinder-oceanstor-0: 09:17:06 INFO unit.cinder-oceanstor/0.juju-log storage-backend:227: Invoking reactive handler: reactive/cinder_oceanstor_handlers.py:47:render_config
unit-cinder-oceanstor-0: 09:17:06 ERROR unit.cinder-oceanstor/0.juju-log storage-backend:227: Hook error:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms/reactive/__init__.py", line 74, in main
    bus.dispatch(restricted=restricted_mode)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 390, in dispatch
    _invoke(other_handlers)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 359, in _invoke
    handler.invoke()
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 181, in invoke
    self._action(*args)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/charm/reactive/cinder_oceanstor_handlers.py", line 55, in render_config
    charm.render_with_interfaces(args)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms_openstack/charm/core.py", line 994, in render_with_interfaces
    self.render_configs(
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms_openstack/charm/core.py", line 975, in render_configs
    _render(os.path.basename(conf))
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charms_openstack/charm/core.py", line 964, in _render
    charmhelpers.core.templating.render(
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/charmhelpers/core/templating.py", line 85, in render
    content = template.render(context)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/var/lib/juju/agents/unit-cinder-oceanstor-0/.venv/lib/python3.8/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "templates/cinder_huawei_conf.xml", line 24, in <module>
    {% set initiators = options.iscsiinitiators.split(';') %}
jinja2.exceptions.UndefinedError: 'None' has no attribute 'split'
nobuto-m commented 3 years ago

This can be default: ''. https://github.com/lolwww/charm-cinder-oceanstor/blob/c839af5d59239a6731aa6758667ebbbbddcaef6e/src/config.yaml#L48-L50

nobuto-m commented 3 years ago

https://git.launchpad.net/~fe-staging/+git/charm-cinder-oceanstor/commit/?id=63ec6ca8053892c1e1f16e62a184bf27d1e37e92