Skip to content

Dev/andres/master req#148

Merged
dkmstr merged 10 commits into
masterfrom
dev/andres/master-req
Nov 7, 2025
Merged

Dev/andres/master req#148
dkmstr merged 10 commits into
masterfrom
dev/andres/master-req

Conversation

@aschumann-virtualcable
Copy link
Copy Markdown
Contributor

This pull request refactors the OpenShift client code to standardize and simplify how HTTP requests are made to the OpenShift/KubeVirt APIs. It replaces direct usage of the requests library with a centralized do_request method, improving error handling and code maintainability. Additionally, it updates the VM name sanitization logic to be more robust and RFC 1123-compliant, and removes some unused or redundant methods.

The most important changes are:

HTTP Request Handling Refactor:

  • Replaced all direct requests.get, requests.post, requests.patch, and requests.delete calls in openshift/client.py with calls to a unified self.do_request method, greatly reducing duplicate code and centralizing error handling for API interactions. This affects all VM, DataVolume, and PVC operations. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

  • Improved error handling: API errors are now caught and logged with exception details, and custom exceptions like OpenshiftNotFoundError are handled where appropriate. [1] [2] [3] [4] [5] [6]

Code Cleanup and Simplification:

  • Removed unused imports (token) and redundant or unused methods such as clone_vm_instance and validate_vm_id from openshift/client.py, streamlining the codebase. [1] [2]

VM Name Sanitization:

  • Updated the sanitized_name method in provider.py to more robustly enforce RFC 1123 compliance: converts to lowercase, replaces invalid characters, collapses multiple dashes, trims leading/trailing non-alphanumeric characters, and limits the length to 63 characters.

aschumann-virtualcable and others added 10 commits October 28, 2025 15:34
…onality

- Implemented unit tests for OpenShift client, provider, publication, and service functionalities.
- Added serialization tests for user services and providers to ensure data integrity during serialization and deserialization.
- Created tests for VM lifecycle operations, including creation, deletion, and state checks.
- Enhanced test coverage for service availability and error handling scenarios.
- Introduced fixed user service tests to validate assignment and operational methods.
- Ensured all tests are structured to handle various edge cases and provide meaningful assertions.
- Updated serialization tests for OpenshiftProvider to ensure correct method behavior after serialization.
- Enhanced publication serialization tests, adding checks for autoserializable fields and marshaling.
- Reorganized service tests to group by functionality, including configuration, utility methods, availability, VM operations, and exception handling.
- Added detailed tests for VM creation, deletion, and cancellation operations in the deployment context.
- Introduced fixed user service tests to validate lifecycle and operation behaviors.
- Removed outdated user service fixed tests and consolidated relevant functionality into new structured tests.
- Added serialization tests for fixed user service to ensure data integrity during serialization and deserialization.
@github-actions github-actions Bot requested a review from dkmstr November 5, 2025 12:57
@dkmstr dkmstr merged commit c885101 into master Nov 7, 2025
8 checks passed
@dkmstr dkmstr deleted the dev/andres/master-req branch November 7, 2025 13:52
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.

3 participants