Skip to content

Master fixes openshift - #43

Merged
dkmstr merged 4 commits into
masterfrom
master-fixes-openshift
Jul 27, 2026
Merged

Master fixes openshift#43
dkmstr merged 4 commits into
masterfrom
master-fixes-openshift

Conversation

@aschumann-virtualcable

Copy link
Copy Markdown
Contributor

This pull request improves the OpenShift client’s connection and token handling, enhances error management, and adds comprehensive tests to ensure reliability and correct caching behavior. The most important changes are grouped below.

OpenShift Client Improvements:

  • Added a cache_key() method to OpenshiftClient to uniquely identify connection parameters, ensuring proper cache invalidation when configuration changes.
  • Improved session and token management in connect(): sessions are now reused and tokens are refreshed only when necessary, with a fixed token validity period [1] [2].
  • Enhanced error handling in get_token() to raise specific exceptions and log errors more clearly.

Testing Enhancements:

  • Added new fixtures and mocks for client cache keys in tests/services/openshift/fixtures.py, ensuring test consistency with the new cache key logic [1] [2].
  • Introduced a new TestOpenshiftClientToken test class for offline testing of token retrieval, session reuse, and token/session invalidation logic.

Provider Integration Testing:

  • Added tests to verify that the provider and client build matching cache keys, that the cached client is reset on config changes, and that clients are recreated or reused as appropriate based on configuration changes.

These changes collectively improve the reliability, maintainability, and test coverage of the OpenShift integration.

Adds URL change detection for cached client reuse and refetch,
ensuring updated configuration is respected without stale connections.
Refines token retrieval to handle redirects and error cases more robustly,
improving authentication reliability. Updates caching keys to include
connection parameters for better cache validity. Enhances related tests to
cover new logic and edge cases.
… request

connect() built a new requests.Session and performed a full OAuth round trip on
every single API call, since do_request() reaches the session through a property
that always called it. The _access_token and _token_expiry attributes were already
declared but never used; they now hold the token for consts.TOKEN_VALIDITY (30 min).
do_request() already clears _session on a 401, so an early expiry self-heals on the
next request. The force argument now actually forces a refresh.

Also drops the global urllib3.disable_warnings(InsecureRequestWarning) call, which
silenced warnings process-wide for every other service and is no longer needed now
that get_token() honors verify_ssl.

Connection identity is now built in a single place, OpenshiftClient.cache_key(), and
mirrored by OpenshiftProvider.connection_key(). Both the cache key helpers and the
cached-client validity check use it, so they can no longer disagree: the previous
check only compared the two URLs while the cache key covered five fields.

Adds offline tests for token parsing, session/token reuse and refetch after
invalidation, and for the client/provider connection keys staying in sync.
The merge with origin/master took master's version of the OpenShift client,
provider and consts, which undid most of the session/token caching commit but
kept part of connect(), leaving code that referenced things no longer present.
connect() raised AttributeError on consts.TOKEN_VALIDITY and built the
Authorization header with a second get_token() round trip.

Restores TOKEN_VALIDITY, get_token() parsing the redirect Location with
allow_redirects=False and verify_ssl honored, the provider connection_key()
used both by the cached client check and the is_available key helper, and
initialize() clearing the cached client on config change.
@dkmstr
dkmstr merged commit 7b8bf60 into master Jul 27, 2026
4 checks passed
@aschumann-virtualcable
aschumann-virtualcable deleted the master-fixes-openshift branch July 27, 2026 14:27
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.

2 participants