mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-22 15:10:22 +00:00
Add ansible-core version check to k8s lookup turbo mode (#1253)
* feat(lookup): add ansible-core version check for turbo mode in k8s lookup Add ansible-core version checking to the k8s lookup plugin to match the behavior already implemented in module_utils/ansiblemodule.py. When ENABLE_TURBO_MODE is set and ansible-core >= 2.19.0: - Emit deprecation warning for ENABLE_TURBO_MODE - Emit version warning explaining turbo mode is unsupported - Disable turbo mode and fall back to standard LookupBase This prevents confusing tracebacks when cloud.common (which declares requires_ansible '>=2.15.0,<2.19') is used on newer ansible-core versions where it is not fully compatible. Changes: - Import ansible_version and LooseVersion - Add TURBO_UNSUPPORTED_CORE = "2.19.0" constant - Check version before enabling turbo mode - Disable turbo mode and warn if version >= 2.19.0 Addresses reviewer feedback on PR #1251 to add version testing to the lookup plugin matching the module implementation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * test(lookup): add unit tests for k8s turbo mode version check Add comprehensive unit tests for the ansible-core version checking logic in the k8s lookup plugin's turbo mode handling. Tests validate that when ENABLE_TURBO_MODE is set: - Turbo mode is disabled on ansible-core >= 2.19.0 (tests 2.19.0 and 2.21.4) - Turbo mode is enabled on ansible-core < 2.19.0 (tests 2.18.0) - Appropriate deprecation and version warnings are shown - Standard LookupBase is used when turbo mode is disabled Tests also verify that when ENABLE_TURBO_MODE is not set: - No deprecation or warning messages are shown - Turbo mode remains disabled - Standard LookupBase is used Implementation follows pytest best practices: - Autouse fixture for module cleanup between tests - Parametrized tests to avoid duplication (2.19.0 and 2.21.4 share logic) - Mock assertion methods (assert_called, assert_not_called) - Module-level import of StandardLookupBase to avoid repetition Simplified and maintainable: 71 lines vs initial 139-line implementation (49% reduction through deduplication and better abstractions). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * style: format with black * fixup! test(lookup): add unit tests for k8s turbo mode version check * docs: add changelog fragment for k8s lookup turbo version check Add changelog entry documenting that the k8s lookup plugin now ignores ENABLE_TURBO_MODE on ansible-core >= 2.19.0 and falls back to standard LookupBase instead of failing with a traceback. This complements the existing deprecate-enable-turbo-mode.yml fragment which covers the module implementation, by documenting the lookup plugin fix specifically. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fixup! fixup! test(lookup): add unit tests for k8s turbo mode version check * fixup! fixup! fixup! test(lookup): add unit tests for k8s turbo mode version check --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
8a9dd54fe7
commit
c46180bb6f
@@ -0,0 +1,5 @@
|
||||
---
|
||||
bugfixes:
|
||||
- k8s lookup - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later, where the ``cloud.common`` collection is not supported.
|
||||
Fall back to the standard ``LookupBase`` instead of failing with a traceback
|
||||
(https://github.com/ansible-collections/kubernetes.core/pull/1253).
|
||||
Reference in New Issue
Block a user