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

OpenShift support #33

Merged
merged 4 commits into from
Jun 6, 2022
Merged

Conversation

knikolla
Copy link
Collaborator

@knikolla knikolla commented Mar 8, 2022

NOTE: This is built on top of #32, therefore includes all commits in it

  • Updated Vagrantfile to setup Microshift and openshift-acct-mgt
  • Created ci/run_functional_tests_openshift.sh to run functional tests on Microshift and openshift-acct-mgt.
  • Implemented interface for Resource Allocator.
  • Implemented functional testing for activate allocation.
  • Implemented add_openshift_resource command and OpenShift resource type.

Future improvements: quotas, renaming attributes to be more generic

Closes #46

@knikolla knikolla force-pushed the feature/openshift branch 3 times, most recently from 101a900 to 9d7a5bb Compare March 9, 2022 10:48
@knikolla knikolla changed the base branch from main to fix/cmd April 12, 2022 17:23
@knikolla knikolla changed the base branch from fix/cmd to main April 12, 2022 17:23
name='OpenStack', description='OpenStack Cloud')
name='OpenStack', description='OpenStack Cloud'
)
resource_models.ResourceType.objects.get_or_create(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would break these commands into register_openstack_attributes and register_openshift_attributes. Its not so clear that you would have to run this command in order to create an openshift resource.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. I renamed the command to register_cloud_attributes

Copy link
Contributor

@ljmcgann ljmcgann left a comment

Choose a reason for hiding this comment

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

Looks mostly good. Some comments:

The assign_role_on_user call in activate_allocation in tasks.py needs to be removed in order for the workflow to finish. add_user_to_allocation already makes this call and the duplicate PUT request always returns 400. This doesn't seem to stop the workflow from working however.

Expiring an allocation and reactivating an allocation doesn't trigger any calls to the acct-mgt service.

@knikolla knikolla changed the title [WIP] OpenShift support OpenShift support May 19, 2022
@knikolla knikolla marked this pull request as ready for review May 19, 2022 18:43
@knikolla knikolla force-pushed the feature/openshift branch 2 times, most recently from 4e9b29e to c4f4edf Compare May 19, 2022 18:48
- Updated Vagrantfile to setup Microshift and openshift-acct-mgt
- Created ci/run_functional_tests_openshift.sh to run functional tests
  on Microshift and openshift-acct-mgt.
- Implemented interface for Resource Allocator.
- Implemented first functional test.
- Implemented add_openshift_resource command and OpenShift resource type.
- Implemented functional testing in OpenShift CI
@knikolla knikolla force-pushed the feature/openshift branch 2 times, most recently from 1603f11 to 1bf5aa6 Compare May 19, 2022 19:01
This checks if deletion of a project works.
Also removes unnecessary cd which didn't work on Github actions.
@knikolla knikolla force-pushed the feature/openshift branch 2 times, most recently from ff7f830 to 19d84fc Compare May 19, 2022 19:18
@knikolla
Copy link
Collaborator Author

knikolla commented Jun 1, 2022

@larsks @jtriley @naved001 could I please get a review on this?

ci/microshift.sh Outdated

sudo docker run -d --name registry --network host registry:2

sleep 30
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we replace this with an active check of some sort? E.g., polling microshift for a successful response?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most probably. Docker registries are REST APIs, so polling for a 200 OK might just work. For polling Microshift, rather than the registry, I'm not sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be sufficient just to wait for a successful reply from the equivalent of kubectl get ns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll give it a try. Thanks!

git clone https://github.com/cci-moc/openshift-acct-mgt.git ~/openshift-acct-mgt
cd ~/openshift-acct-mgt
sudo docker build . -t "localhost:5000/cci-moc/openshift-acct-mgt:latest"
sudo docker push "localhost:5000/cci-moc/openshift-acct-mgt:latest"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be pinned to a particular version? Otherwise changes in openshift-acct-mgr could cause CI on this repository to break. Ideally we'd simply use a tagged image from a hosted repository (docker/quay/ghcr/etc), but even if we can't do that pinning to a particular commit or tag might be a good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. I'd rather not, since the two systems are likely to be deployed separately, and this forces us to not break compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my concern, in case I wasn't clear:

In the current state, because we're pulling straight from the main branch of openshift-acct-mgt, we could end up with failing CI here just because openshift-acct-mgt is broken. By pinning to a specific known-good version we avoid that problem.

This way we're testing the code in this repository, rather than also testing the code in a dependent repository.

Does that change your mind at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My mind was already changed, I was just being lazy. Ideally we would have a release process for openshift-acct-mgt and pin to a release that already has a published docker container rather than build. For now it should be enough to pin to a commit hash. I'll revise.

if username and password:
session.auth = HTTPBasicAuth(username, password)
if os.environ.get('FUNCTIONAL_TESTS', '') == 'True':
session.verify = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have an environment variable corresponding directly to session.verify (like OPENSHIFT_{var_name}_VERIFY)? I can see situation in which people might want to run this code not during test, but also without valid certificates in place.

The variable could either be a boolean value, or a path to a certificate bundle:

verify = os.getenv(f'OPENSHIFT_{var_name}_VERIFY','true')
if verify:
  ssl.verify = (verify.lower() == 'true') if verify.lower() in ['true', 'false'] else verify

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. I'll incorporate this.

return response.json()
if response.status_code == 404:
raise NotFound(f"{response.status_code}: {response.text}")
elif 'does not exist' in response.text or 'not found' in response.text:
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 sad that this is necessary :)

@@ -2,6 +2,10 @@
AllocationAttributeType)


def env_safe_name(name):
return name.replace(' ', '_').replace('-', '_').upper()
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we ever see other punctuation in names? That is, should this use re.replace instead and just replace all non-ascii-letters-and-digits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I hope we don't see complex resource names, but eventually it might make sense to have more robust conversions. For now I'd rather keep it like this and I opened issue #48

@joachimweyl
Copy link

@knikolla it looks like all of the comments are being worked on or already resolved. What are the next steps?

- Removed unnecessary sleep timers
- Added 'OPENSHIFT_{var_name}_VERIFY' switch for tls verification
- Pinned openshift-acct-mgt to current version
@knikolla knikolla merged commit 667f4de into nerc-project:main Jun 6, 2022
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.

[ColdFront/OpenShift] Implement integration testing
4 participants