Skip to content
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

[WIP] allow configuring multiple object store backends #35523

Closed
wants to merge 2 commits into from

Conversation

icewind1991
Copy link
Member

@icewind1991 icewind1991 commented Nov 30, 2022

🚧

Allow configuring multiple object store backends to allow further load balancing and easier migration.

By default everything is put in the "default" bucket, objects for the root storage are put in the "root" bucket if it exists ("default" if it doesn't), the backend for users can be set with a user preference option (occ user:setting <user> homeobjectstore objectstore <config key>).

Existing objectstore and objectstore_multibucket configurations are handled transparently.

Migration example

Migrating users to a new s3 server could be done with the following steps:

  • copy the "default" configuration to a new "old" configuration
  • set the objectstore config key for all existing users to "old"
  • change the "default" configuration to the new s3 server

all new users will now be stored on the new s3 server, existing users can now be migrated one-by-one with minimal downtime

  • copy over the objects for a single user to the new s3 server
  • update the objectstore config key for the user

example configuration:

[
  'objectstore' => [
    'default' => [
      'class' => 'OC\\Files\\ObjectStore\\S3',
      'arguments' => [
        'multibucket' => true,
        'bucket' => 'nextcloud-',
        'hostname' => 'objectstore2',
        ...
      ],
    ],
    'old' => [
      'class' => 'OC\\Files\\ObjectStore\\S3',
      'arguments' => [
        'bucket' => 'nextcloud',
        'hostname' => 'objectstore1',
        ...
      ],
    ],
    'root' => [
      'class' => 'OC\\Files\\ObjectStore\\S3',
      'arguments' => [
        'bucket' => 'nextcloud-root',
        'hostname' => 'objectstore1',
        ...
      ],
    ],
  ],
]

For a use case where all objects in the root storage is put in "objectstore1/nextcloud-root", users created before the objectstore migration have the "homeobjectstore.objectstore" config option set to "old" and have their objects stored in "objectstore1/nextcloud" which all users created afterwards have their objects stored in the "objectstore2/nextcloud-XX" buckets.

todo

  • command to move users from "default" to ""
    • create "" objectstore configuration as a copy from "default"
    • for all users who are currently using "default" set the objectstore config key to ""
    • if the root storage is using "default", copy the "default" configuration to "root"
  • command to migrate users to a different config
  • command to list users by configuration

@icewind1991 icewind1991 added the 2. developing Work in progress label Nov 30, 2022
@icewind1991 icewind1991 force-pushed the multi-object-store branch 3 times, most recently from e4a26d7 to f4440c7 Compare December 1, 2022 14:05
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
}
}

private function getObjectStoreConfig(): ?array {

Check failure

Code scanning / Psalm

InvalidReturnType

The declared return type 'array<array-key, mixed>|null' for OC\Files\ObjectStore\PrimaryObjectStoreConfig::getObjectStoreConfig is incorrect, got 'ArrayAccess|array{default: array{default: mixed}|mixed|null}'
$this->validateObjectStoreConfig($config);
}

return $objectStore;

Check failure

Code scanning / Psalm

InvalidReturnStatement

The inferred type 'ArrayAccess|array{default: array{default: mixed}|mixed}' does not match the declared return type 'array<array-key, mixed>|null' for OC\Files\ObjectStore\PrimaryObjectStoreConfig::getObjectStoreConfig
@blizzz blizzz added this to the Nextcloud 29 milestone Nov 23, 2023
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
@skjnldsv skjnldsv deleted the multi-object-store branch August 30, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants