Skip to content

Cleanup ext storage CRUD code, introduce storage config id - #11884

Merged
PVince81 merged 9 commits into
masterfrom
ext-appframework
Mar 20, 2015
Merged

PVince81 merged 9 commits into
masterfrom
ext-appframework

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Tried to make the external storage app code more meaningful.

But I hit against hard blocks like this: https://github.com/owncloud/core/blob/master/apps/files_external/js/settings.js#L136
Calling "removeMountPoint.php" for EVERY user ?

Also the lack of "id" makes it impossible to continue.
Will try and introduce a proper id in a separate PR first...

Comment thread apps/files_external/appinfo/app.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please kill the usage of classpath here? we should really rely on the class loader - THX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe another time, I need to focus on the essential 😄

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Also the lack of "id" makes it impossible to continue.

using an 'id' is key to build up any future api - we need to introduce this everywhere ... some day ..

@PVince81

PVince81 commented Nov 3, 2014

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 don't bother reviewing this. I won't continue working on this until a proper storage id is introduced.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

don't bother reviewing this. I won't continue working on this until a proper storage id is introduced.

no worries - I'm already done 🙈

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@PVince81 I need these changes in order to get direct download implemented where I need to add additional routes - #12854

Can we get this into a mergable state - at least regarding the appframework part? THX

@PVince81

Copy link
Copy Markdown
Contributor Author

Not possible until we have the storage id: #12793

Unless I simply remove every route I added. What you need is probably just the container ?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Unless I simply remove every route I added. What you need is probably just the container ?

ok - thx - I'll add my controller and related pieces to my pr - we need to sync your code later then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can do the automatic DI for that nowadays. – Either take a look at our docs (it's somewhere documented there) or ping me in IRC ;-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

=> We can even get rid of that file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, automatic DI. I completely forgot that (spent too much time away from the app framework lately...)

@PVince81

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 some app framework pieces are available on master, in case you're still interested.

I'll continue this PR with the focus on mountpoint management (add/update/delete) based on the new storage_id setting that was introduced in 8.0. This would be to fix: #14058 (prerequisite for storage options)

@PVince81

Copy link
Copy Markdown
Contributor Author

Just done a major cleanup of the JS side part.

Tasks

  • write service class to load/save mount points
  • wire service class to OC_MountConfig for reading/saving the config to file (something to refactor in a future PR)
  • fix/finish update spinner
  • add hidden "priority" field to make sure we keep existing values
  • figure out how to trigger hooks from StoragesService
  • properly generate/return storage id
  • fix personal mount case
  • should we return "isPersonal" in the response ? (should it really be part of the storage model or use separate endpoints for system and personal mount points ?)
  • add storage specific options like thumbnail (backend)
  • add storage specific options like thumbnail (frontend/UI) in an extra dropdown => Mount options GUI for external storage #14925

Unit tests

  • write JS unit tests
  • unit tests for StoragesService (check if config can be loaded/saved properly after changes)
  • fix unit tests (failing with out of memory error locally)

Regression Testing

System mount
  • Add new storage (storage must receive id)
  • Update storage
  • Delete storage
  • Adding/removing users/groups
  • Case "applicable for all"
  • Renaming mount point
  • Validation (excluding backend options validation)
  • Mountpoint conflicts
  • Loading/deletion spinner
  • Test with LDAP user (to make sure the user/group id is still correct)
  • What with exotinc configurations ?
  • Hook test: etag must change on config change / add /delete
Personal mount
  • Add new storage (storage must receive id)
  • Update storage
  • Delete storage
  • Renaming mount point
  • Validation (excluding backend options validation)
  • Mountpoint conflicts
  • Loading/deletion spinner
  • Hook test: etag must change on config change / add /delete

@PVince81 PVince81 changed the title [WIP] Ext storage app framework + proper REST [WIP] Cleanup ext storage CRUD code to work with the new storage_id Feb 11, 2015
@PVince81

Copy link
Copy Markdown
Contributor Author

It's already looking good 😄
But there is still some work to be done.

Comment thread apps/files_external/appinfo/routes.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@LukasReschke @DeepDiver1975 @icewind1991 do you think we should use separate endpoints for "system-wide" mounts and "personal" mounts ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd be in favour of that if it does not lead to too much duplication as we then can do the security checks via annotations and don't have to do those ugly "is user is admin then this otherwise that" stuff :)

@PVince81

Copy link
Copy Markdown
Contributor Author

BAD NEWS: due to the flexibility we offered before like putting value like "/somedir/$user/" in config fields, this would cause a single config entry to produce multiple entries in the "oc_storages" table.
This means that we cannot use the "storage_id" as a unique id for the mount point config 😡

It looks like we'll need to introduce yet another id, call it "external_storage_config_id" (or shorter) which would match every entry visible in the config in the admin pageWeb UI.
Obviously even with that approach the "mount.json" file will still have multiple entries, but those entries would all have "external_storage_config_id". In the future we can have that in the database.

@PVince81

Copy link
Copy Markdown
Contributor Author

In principle this also means that we need a 1-N mapping table that maps "external_storage_config_id" to "oc_storages.numeric_id". Without this we cannot reliably delete the matching "oc_storages" entries on deletion in such situations where the "$user" field is used (#11544)

@PVince81

Copy link
Copy Markdown
Contributor Author

and as long as we don't have "mount.json" in the database, we cannot reliably generate incremental "external_storage_config_id" because concurrency could make it generate twice the same.

Unless "external_storage_config_id" is a hash of the config... ARGHH

I'll leave this task aside for now until I find new ideas that does not involve moving mount.json to the database (which is a big task, especially regarding the migration + import scripts)

@PVince81 PVince81 added this to the 8.1-next milestone Feb 11, 2015
@RobinMcCorkell
RobinMcCorkell force-pushed the ext-appframework branch 2 times, most recently from 8103da2 to 4d5bd1e Compare March 1, 2015 13:50
@RobinMcCorkell

Copy link
Copy Markdown
Contributor

Well status checking is now mostly implemented. I'm still bringing over changes from #13515, like the async ability. It current lies a bit about the storage status, since when creating the storage there is no ID available and the storage status cannot be determined. But when IDs are implemented that will clear itself up.

Also, we now have the structure available for multiple error types. So after the troubles of this PR are sorted out (I'm in favour of moving mount.json to the database, maybe for 8.2 though), we can give the user better error information.

@PVince81

PVince81 commented Mar 1, 2015

Copy link
Copy Markdown
Contributor Author

Thanks a lot @Xenopathic.

I think I wasn't done completely with the case "has no idea yet at creation time" because that's where I bumped into the issue on how to generate the storage_id, and that's when I realized that it wasn't unique/consistent... so for that part we need to sort out what to do.

For now I suggest to ignore concurrency and either use max(id) + 1 based on the existing config, or use a config based hash as a string id (like we kind of had before to detect how to group configs). This would be the temp solution until we can move to the DB.

@RobinMcCorkell

Copy link
Copy Markdown
Contributor

@PVince81 only problem with using a hash of the config as the config ID is that the hash will change any time the config changes, so there is no point to the 'update' action.

Given that we don't want to move completely to the database just yet, my vote goes for the max(id) + 1 option.

@PVince81

PVince81 commented Mar 2, 2015

Copy link
Copy Markdown
Contributor Author

Ok, thanks for your input 😄

The problem with moving with the DB is that it will take a lot of coding, but also will require migration + import script (to import mount.json into the DB), which is quite a big task.

@PVince81

PVince81 commented Mar 9, 2015

Copy link
Copy Markdown
Contributor Author

I split the controller and service into two set of classes, one for global storages and one for user storages (aka personal mounts).
Also, now it generates an id.

Personal mount part is still broken at the moment, will look into that next.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

array $mountOptions?

@LukasReschke

Copy link
Copy Markdown
Contributor

What about the index methods as well for those?

Now accessing /index.php/apps/files_external/globalstorages will simply yield a fatal PHP exception

@PVince81

Copy link
Copy Markdown
Contributor Author

I can add an index route but it won't be used by anything yet, until we port the UI too (hopefully in a future PR)

@LukasReschke

Copy link
Copy Markdown
Contributor

I can add an index route but it won't be used by anything yet, until we port the UI too (hopefully in a future PR)

Then let's not add them for now :)

Fix various PHPDoc issues in external storage app.

Added missing NoAdminRequired tag
@PVince81

Copy link
Copy Markdown
Contributor Author

Fixed the PHPdoc and added the missing NoAdminRequired tag

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@ghost

ghost commented Mar 17, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/10528/
Test PASSed.

@icewind1991

Copy link
Copy Markdown
Contributor

Looks good, basic testing works fine 👍

@PVince81

Copy link
Copy Markdown
Contributor Author

Needs a second reviewer @Xenopathic @DeepDiver1975 @LukasReschke
(I agree with the changes from @Xenopathic in this PR)

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@RobinMcCorkell

Copy link
Copy Markdown
Contributor

Eek, I forgot to pull across async status checking from #13515. That last commit implements that - very simple, the framework was already there. Please review @icewind1991 ? Thanks

@ghost

ghost commented Mar 20, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/10656/

Build result: FAILURE

[...truncated 14 lines...] > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10 > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.gitusing GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git190121534847429875.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse refs/remotes/origin/pr/11884/merge^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/pr/11884/merge^{commit} # timeout=10Checking out Revision a08e23a083d05b37a96763d062bb8711f4889a36 (refs/remotes/origin/pr/11884/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f a08e23a083d05b37a96763d062bb8711f4889a36 > git rev-list ee6a3217a047f08d3766d927c20b61fab1f3ee37 # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILURESetting status of c37913b to FAILURE with url https://ci.owncloud.org/job/pull-request-analyser-ng-simple/10656/ and message: Merged build finished.
Test FAILed.

@PVince81

Copy link
Copy Markdown
Contributor Author

Tested @Xenopathic's async check, works. This 👍 counts for the commit c37913b

Will raise a Jenkins PR...

@RobinMcCorkell

Copy link
Copy Markdown
Contributor

Likewise, I've tested (and developed on) the rest of this PR done by @PVince81, so 👍 from me. I'd suggest one more independent reviewer though. @icewind1991 already reviewed all but that last commit, so all we really need is one final review...

@RobinMcCorkell

Copy link
Copy Markdown
Contributor

It'd be great to get #13641 merged at the same time, so that we get full support for downed storages.

@icewind1991

Copy link
Copy Markdown
Contributor

👍 for the async check

PVince81 pushed a commit that referenced this pull request Mar 20, 2015
Cleanup ext storage CRUD code, introduce storage config id
@PVince81
PVince81 merged commit e44ab2d into master Mar 20, 2015
@PVince81
PVince81 deleted the ext-appframework branch March 20, 2015 13:17
@PVince81

Copy link
Copy Markdown
Contributor Author

Thanks a lot guys.

@RobinMcCorkell

Copy link
Copy Markdown
Contributor

Now starts the process of rebasing every other PR that so much as looks at files_external code 😆

@MorrisJobke

Copy link
Copy Markdown
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants