-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[stable29] multi-instance object store tweaks #57141
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
Draft
leftybournes
wants to merge
5
commits into
stable29-backports
Choose a base branch
from
leftybournes/fix/stable29-backports
base: stable29-backports
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−114
Draft
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8089fab
feat(objectstore): get multibucket mappings for all users with --all
leftybournes c295cfc
feat: add move command
leftybournes 263a212
refactor: remove rename command
leftybournes 32cb3bb
chore: run cs fixer
leftybournes fc30176
feat: add pre-migrate command
leftybournes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Files\Command\Object\Multi; | ||
|
|
||
| use OC\Core\Command\Base; | ||
| use OC\Files\ObjectStore\PrimaryObjectStoreConfig; | ||
| use OCP\IConfig; | ||
| use OCP\IUserManager; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| class Move extends Base { | ||
| public function __construct( | ||
| private PrimaryObjectStoreConfig $objectStoreConfig, | ||
| private IUserManager $userManager, | ||
| private IConfig $config, | ||
| ) { | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| protected function configure(): void { | ||
| parent::configure(); | ||
| $this | ||
| ->setName('files:object:multi:move') | ||
| ->setDescription('Migrate user to specified object-store') | ||
| ->addOption('object-store', 'b', InputOption::VALUE_REQUIRED, 'The name of the object store') | ||
| ->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'The user to migrate') | ||
| ->addOption('all', 'a', InputOption::VALUE_NONE, 'Move all users to specified object-store') | ||
| ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Run command without commiting any changes'); | ||
| } | ||
|
|
||
| public function execute(InputInterface $input, OutputInterface $output): int { | ||
| $objectStore = $input->getOption('object-store'); | ||
| if (!$objectStore) { | ||
| $output->writeln('Please specify the object store'); | ||
| } | ||
|
|
||
| $configs = $this->objectStoreConfig->getObjectStoreConfigs(); | ||
| if (!isset($configs[$objectStore])) { | ||
| $output->writeln('<error>Unknown object store configuration: ' . $objectStore . '</error>'); | ||
| return 1; | ||
| } | ||
|
|
||
| if ($input->getOption('all')) { | ||
| $users = $this->userManager->getSeenUsers(); | ||
| } elseif ($userId = $input->getOption('user')) { | ||
| $user = $this->userManager->get($userId); | ||
| if (!$user) { | ||
| $output->writeln('<error>User ' . $userId . ' not found</error>'); | ||
| return 1; | ||
| } | ||
| $users = new \ArrayIterator([$user]); | ||
| } else { | ||
| $output->writeln('<comment>Please specify a user id with --user or --all for all users</comment>'); | ||
| return 1; | ||
| } | ||
|
|
||
| $count = 0; | ||
| foreach ($users as $user) { | ||
| if (!$input->getOption('dry-run')) { | ||
| $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'objectstore', $objectStore); | ||
| } | ||
| $count++; | ||
| } | ||
| $output->writeln('Moved <info>' . $count . '</info> users to ' . $objectStore . ' object store'); | ||
|
|
||
| return 0; | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we go with this version of the move command, I think it makes sense to validate that the target object store is valid for the user.
We could get the fileid for one of the user's files (if the user has at least one file) and check if an object with the matching urn exists it the target object store.
Without any checks the command would risk being a big footgun.