-
Notifications
You must be signed in to change notification settings - Fork 2.1k
migrate oc8 mount.json external storages to the database #28662
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
Conversation
… external stores, marked files_external to use migrations
PVince81
left a comment
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.
Looks fine so far
| public function run(IOutput $out) { | ||
|
|
||
| /** @var GlobalStoragesService $globalStoragesService */ | ||
| $globalStoragesService = \OC::$server->query('GlobalStoragesService'); |
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.
copy-pasted indents failed
| * @return array list of mount configs | ||
| */ | ||
| protected function readLegacyConfig() { | ||
| $mountConfig = new \OC_Mount_Config(); |
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.
Please use LegacyUtil instead to not re-add a dependency on this horrible class.
Most of the code was moved from OC_Mount_Config to \OC\Files\External\LegacyUtil
| $storageOptions['priority'] = $backend->getPriority(); | ||
| } | ||
| $storageConfig->setPriority($storageOptions['priority']); | ||
| if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) { |
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.
same for the constants
| if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { | ||
| $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); | ||
| } else { | ||
| $authMechanism = $backend->getLegacyAuthMechanism($storageOptions); |
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.
@PVince81 the backend doesn't have this method anymore. Why do we set the storage option to null, but throw an exception when there is no legacy auth mechanism? edit: should i un-delete this method, or can we work around this?
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.
Before we introduced the concept of "one storage can have multiple auth mechanisms", every storage could only have a single one. I think the legacy auth value was there to tell which of the multiple ones the migration should default to if none is specified. (I'm not 100% sure of this though)
If specifying null here is problematic, maybe we need to change the logic to make "null" automatically default to the only auth mechanism supported by the backend, if any.
| // but at this point we don't know the max-id, so use | ||
| // first group it by config hash | ||
| $storageOptions['mountpoint'] = $rootMountPath; | ||
| $configId = \OC_Mount_Config::makeConfigHash($storageOptions); |
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.
@PVince81 makeConfigHash doesn't exist anymore, do you know if it is important that this is actually the hashed config, or does it just has to be unique? Can't we use uniqidfor this?
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.
Bring it back and put it into LegacyUtil. It must be a hash of all config values because this is used to deduplicate configurations. Storing duplicate configs with slight variations (like "applicable" field) is the way mount.json used to work...
…roduced makeConfigHash, fixed some minor things
| $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); | ||
| } else { | ||
| $authMechanisms = $this->backendService->getAuthMechanisms(); | ||
| $authMechanism = $authMechanisms[0]; |
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.
Using the first available AuthMechanism should be fine.
PVince81
left a comment
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.
Looks better. I still have some doubt about your usage of "null" storage, but am also confused about the difference between "$storageOptions" and setAuthMechanism. Did you find out ?
| public function run(IOutput $out) { | ||
|
|
||
| /** @var GlobalStoragesService $globalStoragesService */ | ||
| $globalStoragesService = \OC::$server->query('GlobalStoragesService'); |
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.
I guess injection in constructor doesn't work in migrations ?
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.
Migration files are required by the MigrationService, so we can't use the DI for them. Making them "container aware" like that should be fine. (even if container aware stinks)
|
|
||
| /** @var GlobalStoragesService $globalStoragesService */ | ||
| $globalStoragesService = \OC::$server->query('GlobalStoragesService'); | ||
| $legacyStoragesService = new LegacyStoragesService(\OC::$server->getStoragesBackendService()); |
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.
above you query by string name and here by direct method, consistency would be nice (injection even better)
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.
I do not want to add the LegacyStorageService to the DI container, just so others don't get the idea to use it 😛
| </types> | ||
| <ocsid>166048</ocsid> | ||
|
|
||
| <use-migrations>true</use-migrations> |
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.
you likely also need to increase the app version to trigger the migrations?
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.
Yeah, forgot about that.
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.
But for anyone who actually needs this migration, the version would already bump. (oc8 update).
| } else { | ||
| $authMechanisms = $this->backendService->getAuthMechanisms(); | ||
| $authMechanism = $authMechanisms[0]; | ||
| $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
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.
wouldn't this make it use the "null" authentication mechanism ?
shouldn't this be replaced to the value of $authMechanism or its alias ?
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.
This is about what the old code was like, just that it gets another $authMechanism here. I really don't know what the idea behind the old code was.
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.
if it works fine then ok
|
No, i did not find out more regarding the |
|
Test matrix:
Steps:
|
|
Tested updating from 8.2.11 with GDrive, SFTP, SFTP + RSA key and different "applicable" values to stable10 daily + this PR: the conversion of the configs worked. |
PVince81
left a comment
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.
👍
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
This is a follow-up to #28655. This migrates storages defined in
data/mount.jsonto the database.Related Issue
#28655
How Has This Been Tested?
Has been tested manually with the limited storage options i had (local mount).
Types of changes
Checklist: