Skip to content

Implemented feature to add new attributes to existing Openshift allocations #202

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

QuanMPhm
Copy link
Contributor

@QuanMPhm QuanMPhm commented Apr 3, 2025

Closes #200. Built on top of #201. This PR consists of the last commit. validate_allocations will now check if an Openshift allocation does not have a quota value set on either the Coldfront or Openshift side. In this case, it will set the default quota value for the allocation.

Due to the complexity of Openstack quotas, this feature is only
implemented for Openshift allocations for now.

@QuanMPhm QuanMPhm requested a review from hakasapl April 23, 2025 18:40
Copy link
Contributor

@naved001 naved001 left a comment

Choose a reason for hiding this comment

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

looks like a good feature to have. Just a question inline

expected_value = self.set_default_quota_on_allocation(allocation, allocator, attr)
logger.warning(f"Added default quota for {attr} to allocation {allocation_str} to {expected_value}")

if not (current_value == expected_value):
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you have to make it an if inside of an else and move it down? why couldn't we have done this?

elif not (current_value == expected_value):
    # do the thing for this condition
elif (current_value is None and expected_value is None):
    # do the new thing of setting default quota

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Funny enough. It seems you already asked something similar to this before.

I take it that this means these if statements are very confusing, and I've added the comment block below. @naved001 Should I make an issue to refactor this in the future?

# We just checked the case where the quota value is set in the cluster 
# but not in coldfront. This is the only case the cluster value is the 
# "source of truth" for the quota value
# If the coldfront value is set, it is always the source of truth. 
# But first, we need to check if the quota value is set anywhere at all. 
# TODO (Quan): Refactor these if statements so that we can remove this comment block?

Copy link
Contributor

Choose a reason for hiding this comment

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

@QuanMPhm LMAO. yes, please add a brief comment to explain this otherwise I will, without fail, ask the same question again in a few months.

when determining what attributes an allocation should have

This is done by a function `get_expected_attributes` in `tasks.py`
to fetch the list of expected attributes
@QuanMPhm QuanMPhm force-pushed the feature/add_attr branch from 408587b to 2cdabf5 Compare May 6, 2025 20:43
…ations

`validate_allocations` will now check if an Openshift allocation
does not have a quota value set on either the Coldfront or Openshift
side. In this case, it will set the default quota value for the
allocation.

Due to the complexity of Openstack quotas, this feature is only
implemented for Openshift allocations for now.
@QuanMPhm QuanMPhm force-pushed the feature/add_attr branch from 2cdabf5 to 1f7348f Compare May 6, 2025 20:58
@QuanMPhm QuanMPhm requested a review from naved001 May 7, 2025 17:09
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.

Implement the feature to add new quota attributes to pre-existing allocations
2 participants