Skip to content

ER-80651: SmartQuota notification rules configuration - #272

Open
Saksham-Nautiyal wants to merge 11 commits into
mainfrom
feature/ER-80651-smartquota-notification-rules-crud
Open

ER-80651: SmartQuota notification rules configuration#272
Saksham-Nautiyal wants to merge 11 commits into
mainfrom
feature/ER-80651-smartquota-notification-rules-crud

Conversation

@Saksham-Nautiyal

Copy link
Copy Markdown
Contributor

Summary

Implements per-quota notification rule configuration for PowerScale SmartQuotas, enabling users to define custom notification actions (alerts, emails) when quota thresholds are exceeded, denied, violated, or expired.

Features Implemented

  • CRUD Operations: Create, update, delete notification rules for individual quotas
  • Combined Creation: Create quota and notification rules in a single task
  • Check Mode Support: Preview changes without making API calls
  • Diff Mode Support: Return before/after diff for notification rule changes
  • Parameter Validation: Validate condition/threshold choices and action fields
  • Error Handling: Clear error messages for unknown rule IDs and partial failures

Additional Discovery

During integration testing on OneFS 9.15, discovered that the API requires a holdoff parameter (time in seconds before sending another notification) for notification rules with condition: "exceeded". This parameter has been added to the implementation.

Changes

  • Added quota_notification_rules parameter to smartquota module
  • Implemented SDK helper methods for notification rule CRUD operations
  • Added reconciliation logic for idempotent notification rule management
  • Integrated notification rules into module output and diff mode
  • Added holdoff parameter support (required for OneFS 9.15+)
  • Updated documentation and example playbooks
  • Added 22 new unit tests (87 total tests passing)

Test plan

  • All 87 unit tests pass
  • Integration test on PowerScale OneFS 9.15 array successful
  • Verified check_mode makes no write API calls
  • Verified diff_mode returns accurate before/after snapshots
  • Verified combined quota + notification rule creation
  • Verified parameter validation for condition/threshold/action fields
  • Verified holdoff parameter required for exceeded/hard combinations

Generated with Devin

Saksham-Nautiyal and others added 8 commits September 9, 2026 05:11
Add list/create/update/delete/delete-all helper methods on SmartQuota
for the per-quota PAPI notification-rules endpoints
(/platform/7/quota/quotas/{QuotaId}/notifications[/{NotificationId}]).

The isilon-sdk Python bindings (v9.5.0-v9.12.0) never generated typed
methods for these endpoints -- only the global
/platform/7/quota/settings/notifications endpoints were generated --
even though the raw PAPI schema (src/ansible/isilon_sdk/papi_schemas)
confirms the per-quota endpoints exist on every OneFS version 9.0-9.13.
Helpers route through quota_api_instance.api_client.call_api, the same
generic mechanism every generated SDK method uses internally, keeping
all calls within the authenticated SDK client (no raw HTTP).

Also discovered: PUT .../notifications/{NotificationId} only accepts
action fields (action_alert, action_email_owner, action_email_address,
email_template, holdoff, schedule) -- condition/threshold are
immutable after creation and require delete+recreate.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add the quota_notification_rules list parameter (id, condition,
threshold, action_alert, action_email_owner, action_email_address,
state) to the smartquota module's argument spec and DOCUMENTATION,
per ER-80651.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add reconcile_quota_notification_rules to SmartQuota, computing the
minimal create/update/delete actions to converge current notification
rules to the requested quota_notification_rules list:
- New rules (no id) are created.
- Rules with a matching id and only action-field changes are updated
  in place via PUT.
- Rules with a matching id and a condition/threshold change are
  deleted and recreated (PAPI immutability, per AC-2 update).
- Rules with state=absent and a matching id are deleted.
- An empty list deletes all existing rules for the quota.
- Exact matches and unknown ids under state=absent are no-ops.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Append the current notification_rules list to the quota details
returned by _process_final_quota_details on every state=present
invocation where the quota exists (FR-5 query requirement), whether
or not quota_notification_rules was supplied. Also update EXAMPLES
and RETURN documentation for the new parameter/field.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add _handle_notification_rules, invoked from perform_module_operation
only when quota_notification_rules is present in module params:
- Existing quota: reconciles using the already-known quota id
  (works under check_mode too, since reconcile's mutating calls
  already guard on self.module.check_mode).
- Freshly created quota (not check_mode): re-resolves the new quota's
  id via get_quota_details before reconciling.
- Freshly created quota under check_mode: id is not yet known, so
  reconciliation is skipped for this invocation (combined
  create+notify-under-check_mode is validation-story AC-9 scope).
- quota_notification_rules omitted entirely: no-op, preserving
  existing playbook behavior (NFR-1).

Full test_smartquota.py suite: 48 passed, same 15 pre-existing
failures as baseline main (confirmed via git stash).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fixed two root causes of order-dependent test failures:

1. get_smartquota_args was a shared mutable class-level dict.
   Tests calling .update() leaked stale keys (user_name, group_name,
   provider_type, etc.) into subsequent tests. Added autouse fixture
   to deepcopy the base args dict before each test.

2. utils.isi_sdk is a single shared MagicMock across all tests.
   Its auto-cached child mocks (e.g., quota_api_instance.create_quota_quota)
   leaked mutations across tests in this file. Added autouse fixture
   to reset isi_sdk before each test, scoped to TestSmartQuota only.

These fixes are isolated to test_smartquota.py and do not affect
the shared powerscale_unit_base.py or other test modules.

All 63 smartquota tests now pass (down from 15 failures).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…te hardening for smartquota notification rules

Implements ER-80651-smartquota-notification-rules-validation (Phases 1-5):

- FR-10/FR-11: Validate quota_notification_rules before any API call.
  Enum choices for condition/threshold are enforced by Ansible's
  argument_spec; action-field presence (at least one of action_alert,
  action_email_owner, action_email_address) is now validated explicitly
  via _validate_notification_rules(), called at the top of
  perform_module_operation().
- FR-12: reconcile_quota_notification_rules() now fails with a
  descriptive error when an update or delete references a rule id that
  does not exist for the quota, instead of silently creating a new rule
  (update case) or no-op'ing (delete case).
- FR-8: check_mode support already existed at the individual
  create/update/delete method level; added reconcile-level tests
  proving no write API call is made under check_mode for
  create/update/delete/delete-all scenarios.
- FR-9: reconcile_quota_notification_rules() accepts an optional
  diff_dict, populated with 'before'/'after' notification-rule state.
  perform_module_operation() wires this into self.result['diff'] when
  self.module._diff is set, following the before/after diff convention
  used elsewhere in this collection (see job.py).
- FR-13: _handle_quota_creation() now tracks whether the quota was
  created in this invocation (_quota_just_created); if notification-rule
  creation subsequently fails, the error message explicitly states the
  quota was created successfully but its rules were not.
- Updated DOCUMENTATION/RETURN/EXAMPLES in smartquota.py, regenerated
  docs/modules/smartquota.rst, and added notification-rule and
  combined-create/diff-preview example tasks to
  playbooks/modules/smartquota.yml.
- Added 21 new unit tests (test_smartquota.py); updated 1 existing test
  to reflect the new FR-12 fail-fast behavior. 86 tests pass with 92%
  statement coverage on smartquota.py.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
During integration testing on PowerScale OneFS 9.15, discovered that
the API requires a 'holdoff' parameter (time in seconds before sending
another notification) for notification rules with condition='exceeded'.
This was not in the original ER-80651 implementation.

Changes:
- Added 'holdoff' to quota_notification_rules DOCUMENTATION suboptions
- Added 'holdoff' to argument_spec (type: int)
- Added 'holdoff' to create body in create_quota_notification_rule()
- Added 'holdoff' to NOTIFICATION_ACTION_FIELDS for comparison
- Updated example playbook to include holdoff=3600
- Added unit test for holdoff parameter
- Updated existing test to include holdoff

All 87 unit tests pass. Integration test on Pulse PowerScale array
successful with holdoff parameter.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Saksham-Nautiyal and others added 3 commits September 9, 2026 14:38
- Fixed line length violations by breaking long lines
- Fixed continuation line indentation issues
- Maintained Ansible module structure (imports after documentation)
- All ansible-lint checks pass
- Python syntax validation passes

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Fixed continuation line indentation in smartquota.py
- Fixed line length in test_smartquota.py
- Added sanity ignore file for expected E402 errors
- All pep8 issues now resolved

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Replace underscore with descriptive variable name 'ignored_quota'
to comply with pylint naming conventions.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant