ansible-collections / netapp.ontap

Ansible collection to support NetApp ONTAP configuration.
https://galaxy.ansible.com/netapp/ontap
GNU General Public License v3.0
57 stars 36 forks source link

Starting after 21.23.0, netapp.ontap.na_ontap_quotas sets the default qtree quota too even if quota_target is set. #123

Closed delentap closed 1 year ago

delentap commented 2 years ago

Summary

When using module netapp.ontap.na_ontap_quotas with the intent to for example modify the disk limit for a specific qtree, the default limit gets overwritten with that parameter too. use_rest: never provides the correct result.

Our env is a bare metal Ansible Tower on RHEL 8.5/8.6.

Component Name

netapp.ontap.na_ontap_quotas

Ansible Version

ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Jun 14 2022, 12:54:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]

ONTAP Collection Version

Collection          Version
------------------- -------
awx.awx             21.8.0
community.general   4.8.9
netapp.aws          21.7.0
netapp.cloudmanager 21.19.0
netapp.ontap        22.0.0
netapp.storagegrid  21.11.0
netapp.um_info      21.8.0

Python Env:

certifi==2022.9.14
cffi==1.15.1
charset-normalizer==2.0.12
cryptography==38.0.3
et-xmlfile==1.1.0
idna==3.4
Jinja2==3.0.3
jmespath==0.10.0
lxml==4.9.1
MarkupSafe==2.0.1
marshmallow==3.14.1
netapp-lib==2021.6.25
netapp-ontap==9.11.1.0
numpy==1.19.5
openpyxl==3.0.10
pandas==1.1.5
psutil==5.9.2
pycparser==2.21
pyodbc==4.0.34
python-dateutil==2.8.2
pytz==2022.2.1
PyYAML==6.0
requests==2.27.1
requests-toolbelt==0.9.1
six==1.16.0
urllib3==1.26.12
xlrd==2.0.1
XlsxWriter==3.0.3
xmltodict==0.13.0

ONTAP Version

n98509001::> version
NetApp Release 9.9.1P11: Tue Aug 02 19:12:28 UTC 2022

Playbook

- set_fact:
    login: &login
      hostname: "{{ credentials_ontap_hostname }}"
      username: "{{ credentials_ontap_user }}"
      password: "{{ credentials_ontap_password }}"      
      https: true
      validate_certs: no
    object_state: present

- name: Modify quota
  netapp.ontap.na_ontap_quotas:
    <<: *login
    state: "{{ object_state }}"
    activate_quota_on_change: resize
    disk_limit: "{{ (paperbag['/storage/quota/rules'].space.hard_limit | int / 1024) | int }}KB"
    qtree: "{{ paperbag['/storage/quota/rules'].qtree.name }}"
    quota_target: "{{ paperbag['/storage/quota/rules'].quota_target }}"
    type: "{{ paperbag['/storage/quota/rules'].type }}"
    volume: "{{ paperbag['/storage/quota/rules'].volume.name }}"
    vserver: "{{ paperbag['/storage/quota/rules'].svm.name }}"
    set_quota_status: "{{ paperbag['/storage/quota/rules'].set_quota_status }}"
    #use_rest: never
    use_rest: always

  when: paperbag['/storage/quota/rules'].space.hard_limit is defined

I supplied the actual parameters in the step below.

Steps to Reproduce

create random svm, here: nv985080002 vol create -vserver nv985080002 -volume f12345 -size 50G qtree create -vserver nv985080002 -volume f12345 -qtree t654321 -security-style unix -unix-permissions 2775

Depending on use_rest: auto|never, the default rule will be modified too.

Change parameters for netapp.ontap.na_ontap_quotas: { "changed": true, "invocation": { "module_args": { "hostname": "172.30.224.130", "username": "admin", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "https": true, "validate_certs": false, "state": "present", "activate_quota_on_change": "resize", "disk_limit": "23068672KB", "qtree": "", "quota_target": "/vol/f12345/t654321", "type": "tree", "volume": "f12345", "vserver": "nv985080002", "set_quota_status": true, "use_rest": "auto", "feature_flags": {}, "http_port": null, "ontapi": null, "cert_filepath": null, "key_filepath": null, "force_ontap_version": null, "policy": null, "perform_user_mapping": null, "file_limit": null, "soft_file_limit": null, "soft_disk_limit": null, "threshold": null } }, "_ansible_no_log": false }

Expected Results

It quota_target is supplied, the playbook should not change the default target for that qtree. Via Zapi, it shows the correct behavior, via REST it doesnt.

Thanks.

Actual Results

Report before the playbook:

n98509001::> quota policy rule show -vserver *2

Vserver: nv985080002       Policy: default           Volume: f12345
                                              Soft             Soft
                         User         Disk     Disk   Files    Files
Type   Target    Qtree   Mapping     Limit    Limit   Limit    Limit  Threshold
-----  --------  ------- -------  --------  -------  ------  -------  ---------
tree   ""        ""      -               -        -       -        -          -
tree   t123456   ""      -            30GB        -       -        -          -
tree   t654321   ""      -              0B        -       -        -          -
3 entries were displayed.

After the playbook ran:

n98509001::> quota policy rule show -vserver *2

Vserver: nv985080002      Policy: default           Volume: f12345

                                              Soft             Soft
                         User         Disk     Disk   Files    Files
Type   Target    Qtree   Mapping     Limit    Limit   Limit    Limit  Threshold
-----  --------  ------- -------  --------  -------  ------  -------  ---------
tree   ""        ""      -            30GB        -       -        -          -
tree   t123456   ""      -            30GB        -       -        -          -
tree   t654321   ""      -            30GB        -       -        -          -
3 entries were displayed.
lonico commented 1 year ago

DEVOPS-5696

carchi8py commented 1 year ago

This was fixed in 22.1.0 which was released last week.