Pure-Storage-Ansible / FlashArray-Collection

Ansible Collection for Pure Storage FlashArray
GNU General Public License v3.0
19 stars 21 forks source link

purefa_policy doesn't update existing snapshot policies #568

Closed dbuenoparedes closed 1 month ago

dbuenoparedes commented 1 month ago

Describe the bug When creating new snapshot policies the module works fine, it creates it with the specified settings. Although when updating an existing policy's values it doesn't do anything, seems that it doesn't check current frequency nor retention (every / keep_for) values and just checks if the policy exists with the given name.

To Reproduce Steps to reproduce the behavior:

  1. Create a snapshot policy, example:
    - name: Define snapshot policies
    purestorage.flasharray.purefa_policy:
    name: "snap-daily"
    policy: snapshot
    snap_client_name: "daily"
    snap_every: 1440
    snap_keep_for: 10080
    fa_url: "{{ fa_url }}"
    api_token: "{{ api_token }}"
  2. Change the value of snap_keep_for from 10080 to 20160 (1 week to 2 weeks), run the same task, I get the following output:
    TASK [purestorage : Define snapshot policies] **********************************************************************************************************************************************************************************
    Tuesday 21 May 2024  16:37:40 -0400 (0:00:00.527)       0:00:10.686 *********** 
    ok: [us1pure01] => (item={'name': 'snap-daily', 'frequency': 1440, 'retention': 20160, 'client_name': 'daily'})
  3. The policy doesn't change the retention time. The only way to force this is to delete the policy and then run the task to re-create it with the correct/updated values.

Expected behavior Scheduled policy module should update existing schedule policy's configuration.

Desktop (please complete the following information):

Additional context I haven't tried changing other values nor other policies (like quota), not sure if they could also be affected by this.

sdodsley commented 1 month ago

This is by design, although you are not deleting the policy, just the rule within the policy. When you create a policy you then apply the first rule to the policy. You cannot change the parameters of a rule, you must add a new rule. What you are trying to do is add a new rule with the same snapshot interval (snap_every) but with a different retention (snap_keep_for) period. This is not allowed under Purity rules - the snapshot interval must be unique for each rule in the same policy. We could probably add a warning though

sdodsley commented 1 month ago

I have enhanced the idempotency for snapshot policy rules with #569

dbuenoparedes commented 1 month ago

Thanks @sdodsley, my bad on mixing the terms of snapshot policies and rules within the policies, as you pointed out I was trying to modify an rule defined inside a snapshot policy. Actually each snapshot policy can have multiple rules inside of it.

I wasn't aware of that limitation/enforcement from the Purity side. You're 100% correct, I checked CLI and UI and I can't make changes to existing rules, only delete them or create new ones.

Thanks for proactively enhancing the idempotency.

No further action needed.