Refactor to allow resource-agnostic validation#248
Refactor to allow resource-agnostic validation#248QuanMPhm wants to merge 1 commit intonerc-project:mainfrom
Conversation
knikolla
left a comment
There was a problem hiding this comment.
This is a good start, but not going as far as I would like in terms of making it "resource-agnostic", as you still have a lot of if resource_name in OPENSHIFT|OPENSTACK.
Try thinking about a way to push those resource-specific functions inside the respective allocators and creating a new function in the base Allocator that serves as the abstraction.
See my comment about validate project exist.
src/coldfront_plugin_cloud/management/commands/validate_allocations.py
Outdated
Show resolved
Hide resolved
|
Note-to-self: The branch name for the original solution (before time of this comment) is |
9153d7b to
a86da68
Compare
40883e2 to
129234b
Compare
|
@knikolla I've cleaned house on |
|
@QuanMPhm can you resolve conflicts (and update to new quota system if necessary). I would like to have this be part of next month's update. |
129234b to
a0ba80d
Compare
|
@knikolla I have resolved all conflicts. This is ready to review |
| current_value = quota.get(quota_key, None) | ||
| current_value = parse_quota_value(current_value, attr) | ||
|
|
||
| self.check_and_apply_quota_attr( |
There was a problem hiding this comment.
Is this going to trigger a delete and set quota for each quota attribute that is out of date?
There was a problem hiding this comment.
Yes. The check_and_apply_quota_attr() (defined in base.py) will have the same quota validation logic as the current validate_allocation command. Out-of-date quotas will trigger a call to set_quota, which deletes and sets the quotas
There was a problem hiding this comment.
Yes, but in this implementation the call to set quota is made for each allocation attribute, rather than setting a flag for failed_validation which calls set_quota once at the end and setting all the quotas and avoiding unnecessary deletions and recreations.
There was a problem hiding this comment.
Ah yes. I noticed that inefficiency too with the validation code. I'll refactor that
There was a problem hiding this comment.
@knikolla the quota validation function has been refactored
|
I did a quick first pass, I like this approach much more. Will do a second pass early tomorrow morning. |
Quota validation will now behave the same for both resource types. OpenStack's particular use of default quotas is reflected in a new test in `openstack/test_allocation.py` OpenStack integration code is slightly changed to better handle missing object storage quotas Much of the validation logic has been pushed into `base.py`, `openshift.py`, and `openstack.py`
a0ba80d to
a22bf80
Compare
Closes #239. This PR consists of the last commit. Built on top of #245. More details in the commit message.
@knikolla @jtriley I have a small bug in how error handling is done when the object storage quota is missing. Just want to confirm that my change is desirable.