dell / ansible-powerstore

Ansible Modules for Dell PowerStore
GNU General Public License v3.0
34 stars 26 forks source link

[BUG]: new filesystem did not have specified protection_policy applied #20

Closed bwdbethke closed 1 year ago

bwdbethke commented 2 years ago

Describe the bug Created a new filesystem and specified an existing protection_policy but the resulting filesystem did not have protection_policy specified.

Steps to reproduce the behavior:

  1. create snapshot rules and protection policy (this works fine. just adding here for completeness)
    
    powerstore_snapshotrules:
    - name: "snap-every-1d-keep-1w"
    interval: "One_Day"
    days_of_week:
      - Monday
      - Tuesday
      - Wednesday
      - Thursday
      - Friday
      - Saturday
      - Sunday
    desired_retention: 192 # 7+1 days in hours
    state: present

powerstore_protectionpolicies:

  1. create new filesystem providing protection_policy value

    powerstore_smb_filesystems:
    - filesystem_name: "test-fs"
    description: "SMB filesystem created by ansible"
    size: 8
    cap_unit: TB
    access_policy: NATIVE
    locking_policy: ADVISORY
    folder_rename_policy: ALL_FORBIDDEN
    protection_policy: "snap-every-1d-keep-1w"
    state: "present"
  2. See task results that say filesystem was created successfully and mentions a value in protection_policy

    changed: [san02] => (item={'filesystem_name': 'test-fs', 'description': 'SMB filesystem created by ansible', 'size': 8, 'cap_unit': 'TB', 'access_policy': 'NATIVE', 'locking_policy': 'ADVISORY', 'folder_rename_policy': 'ALL_FORBIDDEN', 'protection_policy': 'snap-every-1d-keep-1w', 'state': 'present'})
  3. Get the details of the created filesystem via ansible to see the results list "protection_policy": null

Logs 2022-11-02 12:53:23,163 filesystem.py INFO : HAS_PY4PS = True , IMPORT_ERROR = 2022-11-02 12:53:23,164 filesystem.py INFO : IS_SUPPORTED_PY4PS_VERSION = True , VERSION_ERROR = 2022-11-02 12:53:23,164 filesystem.py INFO : Got Py4ps instance for provisioning on PowerStore <PyPowerStore.powerstore_conn.PowerStoreConn object at 0x7f13c04470a0> 2022-11-02 12:53:23,164 filesystem.py INFO : Got Py4ps instance for protection on PowerStore <PyPowerStore.protection.ProtectionFunctions object at 0x7f13c03f2550> 2022-11-02 12:53:23,548 filesystem.py INFO : Getting NAS Server details nas02 2022-11-02 12:53:24,430 filesystem.py INFO : Successfully got NAS Server details NNN from powerstore array name : san02 ,global id : 0 2022-11-02 12:53:24,431 filesystem.py INFO : Getting File System Details with filesystem_id None, filesystem_name test-fs , nas_server_id NNN 2022-11-02 12:53:24,770 filesystem.py INFO : Successfully Got FileSystem Details None 2022-11-02 12:53:24,770 filesystem.py INFO : FileSystem Details: None , To Modify False 2022-11-02 12:53:24,770 filesystem.py INFO : Attempting to create filesystem name test-fs 2022-11-02 12:53:31,776 filesystem.py INFO : Successfully Created FileSystem with details : {'id': 'XXX'} 2022-11-02 12:53:31,776 filesystem.py INFO : Getting File System Details with filesystem_id XXX, filesystem_name None , nas_server_id None 2022-11-02 12:53:32,096 filesystem.py INFO : Successfully Got FileSystem Details {'id': 'XXX', 'name': 'test-fs', 'description': 'SMB filesystem created by ansible', 'parent_id': None, 'filesystem_type': 'Primary', 'size_total': 8796093022208, 'size_used': 1621098496, 'access_policy': 'Native', 'locking_policy': 'Advisory', 'folder_rename_policy': 'All_Forbidden', 'is_smb_sync_writes_enabled': False, 'is_smb_op_locks_enabled': True, 'is_smb_no_notify_enabled': False, 'is_smb_notify_on_access_enabled': False, 'is_smb_notify_on_write_enabled': False, 'smb_notify_on_change_dir_depth': 512, 'is_async_MTime_enabled': False, 'is_quota_enabled': False, 'grace_period': 604800, 'default_hard_limit': 0, 'default_soft_limit': 0, 'creation_timestamp': None, 'expiration_timestamp': None, 'last_refresh_timestamp': None, 'last_writable_timestamp': None, 'is_modified': None, 'access_type': None, 'creator_type': None, 'filesystem_type_l10n': 'Primary File system', 'access_policy_l10n': 'Native', 'locking_policy_l10n': 'Advisory', 'folder_rename_policy_l10n': 'All Renames Forbidden', 'access_type_l10n': None, 'creator_type_l10n': None, 'nas_server': {'name': 'nas02', 'id': 'NNN'}, 'protection_policy': None} 2022-11-02 12:53:32,096 filesystem.py INFO : Checking if Modify required for filesystem 2022-11-02 12:53:32,096 filesystem.py INFO : Modify Dict {}

System Information:

anupamaloke commented 2 years ago

@bwdbethke, thank you for submitting this issue. We will try reproducing it in our environment and accordingly add it to the backlog.

trisha-dell commented 1 year ago

Hello @bwdbethke, I tried the reproduce the issue using the following tasks:


As a result, the following was the output for the filesystem creation task and the get filesystem details task:

Create a new Filesystem: "changed": true, "filesystem_details": { "access_policy": "Native", "access_policy_l10n": "Native", "access_type": null, "access_type_l10n": null, "creation_timestamp": null, "creator_type": null, "creator_type_l10n": null, "default_hard_limit": 0, "default_soft_limit": 0, "description": "SMB filesystem created by ansible", "expiration_timestamp": null, "filesystem_type": "Primary", "filesystem_type_l10n": "Primary File system", "folder_rename_policy": "All_Forbidden", "folder_rename_policy_l10n": "All Renames Forbidden", "grace_period": 604800, "id": "63a012dc-0705-7b92-bf2b-4a9b7b971437", "is_async_MTime_enabled": false, "is_modified": null, "is_quota_enabled": false, "is_smb_no_notify_enabled": false, "is_smb_notify_on_access_enabled": false, "is_smb_notify_on_write_enabled": false, "is_smb_op_locks_enabled": true, "is_smb_sync_writes_enabled": false, "last_refresh_timestamp": null, "last_writable_timestamp": null, "locking_policy": "Advisory", "locking_policy_l10n": "Advisory", "name": "test-fs", "nas_server": { "id": "6346c2ba-2089-78b4-5696-daaae8917bd2", "name": "sample-nas" }, "parent_id": null, "protection_policy": { "id": "b013b5e7-5b8b-45b2-a76c-8babb4a98198", "name": "PP1_name" }, "size_total": 8796093022208, "size_used": 1621098496, "smb_notify_on_change_dir_depth": 512, "snapshots": {}, "total_size_with_unit": "8.0 TB", "used_size_with_unit": "1.51 GB" }

**Get filesystem details**:
"changed": false,
"filesystem_details": {
    "access_policy": "Native",
    "access_policy_l10n": "Native",
    "access_type": null,
    "access_type_l10n": null,
    "creation_timestamp": null,
    "creator_type": null,
    "creator_type_l10n": null,
    "default_hard_limit": 0,
    "default_soft_limit": 0,
    "description": "SMB filesystem created by ansible",
    "expiration_timestamp": null,
    "filesystem_type": "Primary",
    "filesystem_type_l10n": "Primary File system",
    "folder_rename_policy": "All_Forbidden",
    "folder_rename_policy_l10n": "All Renames Forbidden",
    "grace_period": 604800,
    "id": "63a012dc-0705-7b92-bf2b-4a9b7b971437",
    "is_async_MTime_enabled": false,
    "is_modified": null,
    "is_quota_enabled": false,
    "is_smb_no_notify_enabled": false,
    "is_smb_notify_on_access_enabled": false,
    "is_smb_notify_on_write_enabled": false,
    "is_smb_op_locks_enabled": true,
    "is_smb_sync_writes_enabled": false,
    "last_refresh_timestamp": null,
    "last_writable_timestamp": null,
    "locking_policy": "Advisory",
    "locking_policy_l10n": "Advisory",
    "name": "test-fs",
    "nas_server": {
        "id": "6346c2ba-2089-78b4-5696-daaae8917bd2",
        "name": "sample-nas"
    },
    "parent_id": null,
    **"protection_policy": {
        "id": "b013b5e7-5b8b-45b2-a76c-8babb4a98198",
        "name": "PP1_name"**
    },
    "size_total": 8796093022208,
    "size_used": 1621098496,
    "smb_notify_on_change_dir_depth": 512,
    "snapshots": {},
    "total_size_with_unit": "8.0 TB",
    "used_size_with_unit": "1.51 GB"
}

Even the logs show the same data:
Successfully Got FileSystem Details {'id': '63a012dc-0705-7b92-bf2b-4a9b7b971437', 'name': 'test-fs', 'description': 'SMB filesystem created by ansible', 'parent_id': None, 'filesystem_type': 'Primary', 'size_total': 8796093022208, 'size_used': 1621098496, 'access_policy': 'Native', 'locking_policy': 'Advisory', 'folder_rename_policy': 'All_Forbidden', 'is_smb_sync_writes_enabled': False, 'is_smb_op_locks_enabled': True, 'is_smb_no_notify_enabled': False, 'is_smb_notify_on_access_enabled': False, 'is_smb_notify_on_write_enabled': False, 'smb_notify_on_change_dir_depth': 512, 'is_async_MTime_enabled': False, 'is_quota_enabled': False, 'grace_period': 604800, 'default_hard_limit': 0, 'default_soft_limit': 0, 'creation_timestamp': None, 'expiration_timestamp': None, 'last_refresh_timestamp': None, 'last_writable_timestamp': None, 'is_modified': None, 'access_type': None, 'creator_type': None, 'filesystem_type_l10n': 'Primary File system', 'access_policy_l10n': 'Native', 'locking_policy_l10n': 'Advisory', 'folder_rename_policy_l10n': 'All Renames Forbidden', 'access_type_l10n': None, 'creator_type_l10n': None, 'nas_server': {'name': 'sample-nas', 'id': '6346c2ba-2089-78b4-5696-daaae8917bd2'}, **'protection_policy': {'name': 'PP1_Ansible_Test_FS', 'id': '8a34ccc0-55ce-45e5-8d66-750a04ec11ea'}**}

Can you please try the operations with these playbook tasks?
Please contact us if the problem persists.
bwdbethke commented 1 year ago

sorry for the delay... never saw the email from github that the issue was updated.

I tried the example you provided and it DID create filesystem with the protection_policy defined (instead of null) as you showed. Problem must be in my code.

I compared your example with how I was calling and found the difference... I was trying protection_policy: "{{ item.protection_policy_id | default(omit) }}" so I changed it to protection_policy: "{{ item.protection_policy | default(omit) }}" which referenced it by name and it worked!!

so thanks for your example and help. This issue can be closed as user error.