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.

src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
src/coldfront_plugin_cloud/openshift.py Outdated Show resolved Hide resolved
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
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
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
4 participants