dell / ansible-powerscale

PowerScale (Isilon) Ansible modules
GNU General Public License v3.0
29 stars 21 forks source link

[BUG]: "dellemc.powerscale.synciqpolicy fails with error TypeError: cannot unpack non-iterable NoneType object" #44

Open dennym opened 1 year ago

dennym commented 1 year ago

Description We are trying to manage SyncIQ-Policies using this collection but we're running into the following issue: Unless we leave out required parameters like state or provide wrong credentials on purpose (in which case we get a "normal" Ansible error, such as "incorrect username or password"), we always get the following Python error message:

Logs

Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1669116874.2854335-64-40565527781314/AnsiballZ_synciqpolicy.py\", line 107, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1669116874.2854335-64-40565527781314/AnsiballZ_synciqpolicy.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1669116874.2854335-64-40565527781314/AnsiballZ_synciqpolicy.py\", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.dellemc.powerscale.plugins.modules.synciqpolicy', init_globals=dict(_module_fqn='ansible_collections.dellemc.powerscale.plugins.modules.synciqpolicy', _modlib_path=modlib_path),
  File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code
    exec(code, run_globals)
  File \"/tmp/ansible_dellemc.powerscale.synciqpolicy_payload_vwnkij0j/ansible_dellemc.powerscale.synciqpolicy_payload.zip/ansible_collections/dellemc/powerscale/plugins/modules/synciqpolicy.py\", line 1076, in <module>
  File \"/tmp/ansible_dellemc.powerscale.synciqpolicy_payload_vwnkij0j/ansible_dellemc.powerscale.synciqpolicy_payload.zip/ansible_collections/dellemc/powerscale/plugins/modules/synciqpolicy.py\", line 1072, in main
  File \"/tmp/ansible_dellemc.powerscale.synciqpolicy_payload_vwnkij0j/ansible_dellemc.powerscale.synciqpolicy_payload.zip/ansible_collections/dellemc/powerscale/plugins/modules/synciqpolicy.py\", line 854, in perform_module_operation
TypeError: cannot unpack non-iterable NoneType object

To reproduce

  1. write a minimal playbook:
    - name: bug
    hosts: localhost
    tasks:
    - name: demo filesync policy bug
      dellemc.powerscale.synciqpolicy:
        onefs_host: "isilon.ecample.com"
        verify_ssl: false
        api_user: "****"
        api_password: "****"
        policy_name: "debug"
        state: "absent"
  2. run the playbook

System Information:

Expected behavior

The "debug" policy is either deleted if it exists or nothing is done if it doesn't. In either case, the task should succeed.

Other modules from this collection such as smb and smartquota work w/o issue on the same setup.

Are there any implicitely required parameters we are missing here?

Best

dennym commented 1 year ago

Further inspections resulted in that there was an issue on our side but the error was not meaningful.

The SyncIQ service was not activated and unfortunately the playbook and the sdk did not catch that exception and ran into the next logic step and couldn't handle the response.

This line uses the Isilon python binding sdk and assumes that it either returns no policy or a collection of policies https://github.com/dell/ansible-powerscale/blob/master/plugins/modules/synciqpolicy.py#L500

The API call happens here: https://github.com/Isilon/isilon_sdk_python/blob/a76bec4087528b16679c54f4c9e1200a590b47bd/isi_sdk_9_1_0/isi_sdk_9_1_0/api/sync_api.py#L3033

We weren't able to check the actual response there but it should have failed and be caught.

Solution would be either to somehow check if self.api_instance.get_sync_policy(name_or_id).policies works or returns an exception or isilon sdk needs to have some exception handling. I leave it open until some response but it basically is resolved.

Best

Jennifer-John commented 1 year ago

Thanks @dennym for reporting the issue. We will look into the scenario, if it can be handled by the module.

Thanks, Jennifer

kuttattz commented 1 year ago

@dennym We tried to replicate the above issue. Our setup doesn't have synciq activated as in below screenshot image

But then when we executed the create workflow for the synciq from ansible we got the below result image

This works as expected. Can you please share further information for us to replicate the issue.