Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow direct communication to Openshift API through get_federated_user #177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

QuanMPhm
Copy link
Contributor

Closes #175. As the first step towards merging the account manager into our coldfront cloud plugin, the get_federated_user function in the Openshift allocator will now (through several functions) directly call the Openshift API. Much of the functions added are copied from the moc_openshift module in the account manager.

Aside from copying some functions,
implementation of this feature also involved:

  • A new resource attribute Identity Name for the Openshift idp
  • A new unit test for the get_federated_user function
  • Changes to the CI file to enable these new unit tests

@knikolla knikolla requested a review from larsks October 30, 2024 18:10
src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
self.id_provider = resource.get_attribute(attributes.RESOURCE_IDENTITY_NAME)
self.apis = {}

self.functional_tests = os.environ.get("FUNCTIONAL_TESTS", "").lower()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am uncomfortable that the code is "aware" of whether or not it's running under test. It seems like we should either be able to inject configuration in the tests to achieve the desired behavior, or we should be mocking out functionality as appropriate if we don't want it running during tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know from looking at git blame, this design choice was made a long time ago and is present is both the openshift and openstack allocators. I open could a new issue for this unless there were strong reasons why this design choice was made. @knikolla Do you have any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hindsight, I should have called that environment variable something like INSECURE_HTTPS because that's the only thing it allows AFAIK.

@larsks do you want the env variable to be renamed to the above now or in a follow up patch? (there are other occurrences already present in the codebase in the other drivers)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knikolla A followup patch would be fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there's already a OPENSHIFT_{self.safe_resource_name}_VERIFY environment variable here, so we can rely on just that and remove the functional tests references in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The https check when making the openshift client will now only depend on OPENSHIFT_{self.safe_resource_name}_VERIFY. This lead to a small change in the CI file

src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@knikolla knikolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good, some comments.

@@ -19,6 +19,7 @@ class CloudAllocationAttribute:


RESOURCE_AUTH_URL = 'Identity Endpoint URL'
RESOURCE_IDENTITY_NAME = 'Identity Name'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for this would be OpenShift Identity Provider Name as that matches what it is referencing in an unambiguous way, while Identity Name is confusing among all the other resource attributes.

self.id_provider = resource.get_attribute(attributes.RESOURCE_IDENTITY_NAME)
self.apis = {}

self.functional_tests = os.environ.get("FUNCTIONAL_TESTS", "").lower()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there's already a OPENSHIFT_{self.safe_resource_name}_VERIFY environment variable here, so we can rely on just that and remove the functional tests references in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is not actually being picked up by the test runner and the tests are not being executed. Python requires a __init__.py file to consider directories as Python modules and it's missing here.

@QuanMPhm QuanMPhm requested a review from hakasapl November 15, 2024 19:37
@QuanMPhm QuanMPhm force-pushed the 175/merge_get_federated branch from 8839477 to 54922e7 Compare February 7, 2025 14:58
@QuanMPhm
Copy link
Contributor Author

QuanMPhm commented Feb 7, 2025

I have implemented all feedback so far. The devstack test broke because devstack release 2023.1 is no longer available. I assume this will be fixed with @knikolla 's upcoming PR

As the first step towards merging the account manager into our coldfront
cloud plugin, the `get_federated_user` function in the Openshift allocator
will now (through several functions) directly call the Openshift API.
Much of the functions added are copied from the `moc_openshift`
module in the account manager.

Aside from copying some functions,
implementation of this feature also involved:
- A new resource attribute `Identity Name` for the Openshift idp
- A new unit test for the `get_federated_user` function
- Changes to the CI file to enable these new unit tests
- A top-level logger for the Openshift allocator
- New additions to the package requirements
@QuanMPhm QuanMPhm force-pushed the 175/merge_get_federated branch from 54922e7 to 6752900 Compare February 7, 2025 15:09
@joachimweyl
Copy link

Fix merged, can we kick off the test again?

@QuanMPhm QuanMPhm requested a review from knikolla February 10, 2025 14:01
@QuanMPhm
Copy link
Contributor Author

@joachimweyl Yep, now the tests are passing

@knikolla
Copy link
Collaborator

I'll review this week, though don't want to rush this in for tomorrow's maintenance window.

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.

Allow direct communication to Openshift through get_federated_user function
5 participants