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

Migrate Legacy Metadata Format to new Role-Based Format #1081

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Dec 30, 2024

Motivation:
In #1060, role-based authentication was introduced, changing the structure of metadata to support roles (READ, WRITE, ADMIN).

Modifications:

  • Implemented a migration plugin to convert legacy metadata into the new role-based format.

Result:

  • The legacy metadata format is migrated to new role-based format.

Motivation:
In line#1060, role-based authentication was introduced, changing the structure of metadata to support roles (READ, WRITE, ADMIN).

Modifications:
- Implemented a migration plugin to convert legacy metadata into the new role-based format.

Result:
- The legacy metadata format is migrated to new role-based format.
} catch (Exception ex) {
// No need to rollback because the migration is not committed. Just log the error.
logger.warn("Failed to migrate metadata roles of {}", name, ex);
return UnmodifiableFuture.completedFuture(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question)

  1. If a metadata is already migrated, will a RedundantChangeException be thrown?
  2. If an exception is thrown, would it be a better idea to log and continue instead of returning? Whether the metadata was migrated or not doesn't seem to affect the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a metadata is already migrated, will a RedundantChangeException be thrown?

Just the head revision is returned.

if (peeled instanceof RedundantChangeException) {
final Revision revision = ((RedundantChangeException) peeled).headRevision();
assert revision != null;
return revision;
}

If an exception is thrown, would it be a better idea to log and continue instead of returning? Whether the metadata was migrated or not doesn't seem to affect the behavior.

Yeah, we can probably do that. Let me make a change. 😉

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

👍👍

for (Project project : context.projectManager().list().values()) {
final String name = project.name();
try {
metadataService.migrateMetadata(name).join();
Copy link
Contributor

Choose a reason for hiding this comment

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

Q) The blocking code will prevent other plugins from executing. Is that intentional?

plugin -> plugin.start(arg)
.thenAccept(unused -> logger.info("Plugin started: {}", plugin))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that intentional?

That is true. This approach is inspired by the mirroring migration job:
https://github.com/line/centraldogma/pull/880/files#diff-52b26e4b2cfaf28da0494ec3a92464b4b609594aeccb0a6f3c74d49a7454cf5cR135

context.commandExecutor());
final Stopwatch stopwatch = Stopwatch.createStarted();
for (Project project : context.projectManager().list().values()) {
final String name = project.name();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a migration log for each project so we can identify the progress and investegate when something goes wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a relatively simple migration so I thought just leaving the warning log was enough. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants