-
Notifications
You must be signed in to change notification settings - Fork 114
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
Introduce new mirroring and credential settings format and REST API #880
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #880 +/- ##
============================================
+ Coverage 66.86% 70.60% +3.74%
- Complexity 3529 3748 +219
============================================
Files 370 375 +5
Lines 14531 14917 +386
Branches 1563 1597 +34
============================================
+ Hits 9716 10532 +816
+ Misses 3936 3436 -500
- Partials 879 949 +70 ☔ View full report in Codecov by Sentry. |
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 great all in all. 👍 👍 👍
server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/AbstractMirror.java
Show resolved
Hide resolved
...va/com/linecorp/centraldogma/server/internal/mirror/MirroringAndCredentialServiceV1Test.java
Outdated
Show resolved
Hide resolved
...va/com/linecorp/centraldogma/server/internal/mirror/MirroringAndCredentialServiceV1Test.java
Outdated
Show resolved
Hide resolved
...va/com/linecorp/centraldogma/server/internal/mirror/MirroringAndCredentialServiceV1Test.java
Outdated
Show resolved
Hide resolved
...va/com/linecorp/centraldogma/server/internal/mirror/MirroringAndCredentialServiceV1Test.java
Outdated
Show resolved
Hide resolved
...java/com/linecorp/centraldogma/server/internal/storage/repository/DefaultMetaRepository.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/linecorp/centraldogma/server/internal/storage/repository/RepositoryUri.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/linecorp/centraldogma/server/internal/storage/repository/RepositoryUri.java
Outdated
Show resolved
Hide resolved
...a/com/linecorp/centraldogma/server/internal/mirror/credential/PublicKeyMirrorCredential.java
Outdated
Show resolved
Hide resolved
...a/com/linecorp/centraldogma/server/internal/mirror/credential/PublicKeyMirrorCredential.java
Outdated
Show resolved
Hide resolved
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 didn't get a chance to look at the services, but overall looks nice. Left some questions 🙇
common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/AddOperation.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/AddOperation.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/linecorp/centraldogma/server/internal/mirror/MirroringMigrationService.java
Outdated
Show resolved
Hide resolved
final JsonNode credentialId = mirror.get("credentialId"); | ||
if (credentialId != null) { |
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 I have no idea how to prevent JSON upsert operation. We may need to stop replication just before rolling updates.
Instead of the current approach of updating from a Leader directly, would it be possible to issue a custom command (i.e. MigrateMirrorCommand
) ?
If we take a write lock while migrating, I guess there will be minimal issues regarding inconsistency.
...rc/main/java/com/linecorp/centraldogma/server/internal/mirror/MirroringMigrationService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/linecorp/centraldogma/server/internal/api/MirroringServiceV1.java
Outdated
Show resolved
Hide resolved
Motivation: While mirroring migration job is implemeted line#880, read-only mode is necessary to safely migrate the legacy `mirrors.json` and `credentials.json` the HEAD revision. As the current read-only mode rejects all commands, the migration job is also unable to push commits. A new command type is required to rejects only users requests but allows administrative cases. I propose to introduce two new command types for the smooth migration job. Modifications: - Add `UpdateServerStatusCommand` so as to toggle the read-only mode for the cluster. - Add `ForcePush` so as to wrap a push `Command` to be executed even in the read-only mode. Result: `UpdateServerStatusCommand` and `ForcePush` have been added as new commands to update the cluster status and forcibly push commits in the read-only mode.
Motivation: While mirroring migration job is implemeted #880, read-only mode is necessary to safely migrate the legacy `mirrors.json` and `credentials.json` the HEAD revision. As the current read-only mode rejects all commands, the migration job is also unable to push commits. A new command type is required to rejects only users requests but allows administrative cases. I propose to introduce two new command types for the smooth migration job. Modifications: - Add `UpdateServerStatusCommand` so as to toggle the read-only mode for the cluster. - Add `ForcePush` so as to wrap a push `Command` to be executed even in the read-only mode. Result: `UpdateServerStatusCommand` and `ForcePush` have been added as new commands to update the cluster status and forcibly push commits in the read-only mode.
I found a bug in updating server's status during rolling restart. Let me send a separate PR to handle it first. |
I will proceed with this PR after #921 is merged. |
Motivation:
The ID for mirroring and credential configurations is optional, so I found it difficult to safely update a configuration with REST API. If a user updates a file manually on UI or commit API, the REST API may update a wrong configuration without a unique ID.
@trustin suggested changing the directory layout to store a configuration to a file with a unique ID. #838 (review)
This PR has three major changes:
.bak
suffix. e,g.mirrors.json
->mirrors.json.bak
,credentials.json
->credentials.json.bak
.Modifications:
MirroringMigrationService
that is executed when a server starts and scan all/mirrors.json
and/credentials.json
in the meta repo of projects and migrate them to the new format.mirror-<projectName>-<localRepo>-<shortWord>
credential-<projectName>-<shortWord>
short_wordlist.txt
is used as the word database.Mirror
and related classes to haveid
,enabled
as required fields.CredentailServiceV1
andMirrorServiceV1
to serve REST API for CRU.DefaultMetaRepository
.RepositoryUri
to represent a repository-specific URI such as a Git repository URL.MirrorDto
to serialize a mirroring configuration.Mirror
represents a mirroring task, soMirror
is not suitable for serialization.MirrorCredential
is used as is instead of creating a new DTO.Result: