Skip to content

Conversation

@Srinath0916
Copy link
Contributor

When organization configuration variables are updated, VPN cache wasn't being invalidated automatically. This caused VPNs to use stale config data leading to connectivity issues.

Added signal handler to detect context changes in OrganizationConfigSettings and trigger cache invalidation for all VPNs in that organization. Also added comprehensive tests to ensure the functionality works correctly.

Fixes #1098

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1098.

Description of Changes

  • Added organization_config_settings_change_handler in handlers.py to detect when OrganizationConfigSettings context field changes
  • Added invalidate_organization_vpn_cache Celery task in tasks.py to invalidate VPN cache for all VPNs in the affected organization
  • Connected the signal handler to OrganizationConfigSettings post_save signal in apps.py
  • Added comprehensive test suite in test_organization_vpn_cache.py covering signal handling, task execution, and edge cases

The implementation ensures VPN cache is automatically invalidated whenever organization configuration variables change, preventing stale configuration issues.

Screenshot

Not applicable - this is a backend functionality change with no UI components.

@Srinath0916 Srinath0916 force-pushed the feature/vpn-cache-invalidation-1098 branch 10 times, most recently from fb709ba to 954e35c Compare December 15, 2025 23:52
@coveralls
Copy link

Coverage Status

coverage: 98.384% (-0.2%) from 98.607%
when pulling 954e35c on Srinath0916:feature/vpn-cache-invalidation-1098
into aa2561f on openwisp:master.

@Srinath0916 Srinath0916 force-pushed the feature/vpn-cache-invalidation-1098 branch 3 times, most recently from 497fd5a to 3342a52 Compare December 16, 2025 00:40
…nge openwisp#1098

Implemented automatic VPN cache invalidation when OrganizationConfigSettings
context changes to prevent stale VPN configurations and connectivity issues.

Changes:
- Added signal handler to detect OrganizationConfigSettings context changes
- Added Celery task to invalidate VPN cache for all VPNs in organization
- Connected post_save signal to trigger cache invalidation automatically
- Uses string import to avoid circular import issues
- Ensures VPNs always use latest configuration variables

This resolves the issue where VPN cache was not automatically invalidated
when organization configuration variables changed, causing inconsistency
and connectivity problems.

Fixes openwisp#1098
@Srinath0916 Srinath0916 force-pushed the feature/vpn-cache-invalidation-1098 branch from 3342a52 to 7e365af Compare December 16, 2025 00:47
@Srinath0916
Copy link
Contributor Author

Srinath0916 commented Dec 16, 2025

Hi @pandafy,

I've been working on implementing the VPN cache invalidation for issue #1098 and spent most of the night trying to get it working, but I'm running into a really strange CI problem.

I have the implementation ready - signal handler to detect OrganizationConfigSettings context changes, Celery task to invalidate VPN cache, and proper signal connections. The logic is straightforward and follows the same patterns as existing handlers in the codebase.

But I keep hitting this geckodriver error (visible in the checks above) that seems completely unrelated to my changes. The weird thing is that it happens with ANY modification I make - even just adding TODO comments or copying the exact pattern from working handlers like vpn_server_change_handler.

I tried many different approaches throughout the night to get past this CI error. You can see all my attempts in the issue page - I know it looks messy with all those commits, but I was just trying everything I could think of. Every single approach fails with the same geckodriver error, even when the code changes are minimal.

My other PR (#1173) passes all CI checks fine, so I don't think it's an account or general setup issue. This seems specific to this particular feature.

Could you help me understand what might be causing this? Is there something about VPN-related code that triggers different test suites? Or maybe there's a specific approach you'd recommend for this type of cache invalidation?

I really want to get this working and contribute to OpenWISP properly. The implementation is ready, just need to figure out this CI puzzle.

Sorry for all the iteration - I was just determined to get past this error!

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.

[feature] Invalidate VPN cache when Organization Configuration variable changes

2 participants