-
Notifications
You must be signed in to change notification settings - Fork 138
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
Set Meta.base_manager_name
on 'storageadmin.Disk' #2666
#2667
Set Meta.base_manager_name
on 'storageadmin.Disk' #2666
#2667
Conversation
@FroggyFlox Thanks for looking into this one.
From the comments (mine from some time ago now) it's more to be able to easily list attached disks only. I.e.:
At the time we had very little capability re disk tracking (state etc): so I added this as a custom manager so we could ask for only attached disks easily. And it would, in turn, auto filter out all disks with our 'tell' (added a little while before hand) of detached status: that of a rename to "detached-<random_uuid_here>". So it was simply a convenience call to be used in for example: rockstor-core/src/rockstor/storageadmin/views/command.py Lines 86 to 87 in b4128ad
In comparison to the long-winded, non-centralised way of doing the same: outside the model as it were, we have a remaining legacy way of doing the same that still existing here: rockstor-core/src/rockstor/storageadmin/views/pool.py Lines 529 to 533 in b4128ad
More uses of the manager are: rockstor-core/src/rockstor/storageadmin/views/command.py Lines 106 to 107 in b4128ad
Similarly we can likewise reference starting from the share thus: rockstor-core/src/rockstor/storageadmin/views/command.py Lines 163 to 164 in b4128ad
So, in summary, the manager allows for an easy way to return attached disks, and it 'keys' from the name we give disks when they are detached: which is "detached-random_here".
Not sure is that helps, but if this attached custom manager (query) method was dis-functional we could still tell if a disk was detached due to it's name. But we could no longer effectively use the Pool's disk_set (a special Django build-in relational filter magic) for Disks belonging to that Pool) via the custom manager here and get a list (from the pool's perspective) of attached disks that belong to it (the Pool). I have not yet looked more closely at if your test method shows this: but just wanted to point out that this manager is used from the perspective of the Pool, via the built-in disk_set qualifier. I think this is why I used "use_for_related_fields". A doc entry from the (Django) time this was added: Correctly or not as it goes. However to date this approach seems to have worked as expected. And from a quick look the modification proposed here may pertain to the entire model, yet we have the following in-play also: rockstor-core/src/rockstor/storageadmin/models/disk.py Lines 86 to 88 in b4128ad
So I'm not entirely sure if your proposal is transitioning (to newer Django) a prior definition that was not actually required, or out of place but without subsequent issue (until not :) ) or we can instead just drop the "use_for_related_fields" definition. After all we are only after a custom manager that can be used from the Pool's perspective. And we have maintainer access to the default manager via the Objects qualifier. A little reading does suggest we did need this "use_for_related_fields" when it was the default manager, which it looks to be for us (first listed in last code snippet) but that we also enable plain Objects access. If we can prove that our pool.disk_set.attached() still works, and that we can also retrieve all disks via Objects then I think we are good here. My apologies for not focusing on the test required, but I also wanted to raise questions on if I had done the correct thing initially here: but without known consequence until now. |
Build a 5.0.3-2667 rpm:
Where the first two ERRORS are our initial pool mount attempt. It is here assumed that the object filter is returning the detached disks as expected.
Re: rockstor-core/src/rockstor/storageadmin/views/command.py Lines 80 to 92 in b4128ad
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FroggyFlox I'm still a little unsure here if we've done the right thing, but I've now duplicated your existing test, as per my last comment, and I think we are good here.
Thanks for seeing to this, much appreciated. And for clearing the way further on the associated Milestone.
We are still fairly early in our current testing and it's important that we get to the associated milestone so I'll merge this so we can move on. Functionally it looks to be a continuation, given the indicated code on boot-up.
Update our Django dependency. It is generally recommended to only update Django from one LTS to the next: 2.2 LTS is our next-in-line. Includes a prior overlooked migration intended for this Django update. See:GitHub rockstor#2666 rockstor#2667
Update our Django dependency. It is generally recommended to only update Django from one LTS to the next: 2.2 LTS is our next-in-line. ## Includes - A prior overlooked migration intended to prepare for this Django update. See:GitHub rockstor#2666 rockstor#2667 - Replace deprecated multi_db with databases 'property': "RemovedInDjango31Warning: TestCase.multi_db is deprecated." Which ended up breaking one of our unit tests. And so was included in this update. N.B. there remains some Django update warnings but these are to be addressed in future dedicated issues/commits.
Fixes #2666
@phillxnet, @Hooverdan96: it is ready for review but I'm leaving the PR as draft because I'm still not 100% I tested correctly; see below for more details.
This pull request simply applies the changes requested by the warning detailed in #2666.
Functional testing
@phillxnet, this area is your expertise, I believe, so the following testing may not be the most relevant/best.
If I'm correct, this model manager is used to list a disk as detached. I thus tested that as follows:
use_for_related_fields
is deprecated in Django 2.0 #2666 anymore.Unit testing