-
Notifications
You must be signed in to change notification settings - Fork 117
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
Extract mirroring implementation from the server module #836
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #836 +/- ##
============================================
+ Coverage 65.50% 65.61% +0.11%
- Complexity 3328 3350 +22
============================================
Files 356 358 +2
Lines 13962 13908 -54
Branches 1499 1494 -5
============================================
- Hits 9146 9126 -20
+ Misses 3964 3932 -32
+ Partials 852 850 -2
☔ 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.
I'm not sure if it makes sense to move DefaultMetaRepository
out of :server
. How about introducing some SPI so :mirror
can register itself as a handler for a certain set of URI schemes?
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.
That's a good suggestion. Addressed.
@Type(value = SingleMirrorConfig.class, name = "single"), | ||
@Type(value = MultipleMirrorConfig.class, name = "multiple") | ||
}) | ||
@JsonSubTypes(@Type(value = SingleMirrorConfig.class, name = "single")) | ||
private abstract static class MirrorConfig { |
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.
Will combine MirrorConfig
and SingleMirrorConfig
together after @ikhoon's work for mirroring UI is done.
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.
Combine them in this PR instead of waiting for @ikhoon's work. 😉
import com.linecorp.centraldogma.server.mirror.MirrorContext; | ||
import com.linecorp.centraldogma.server.mirror.MirrorProvider; | ||
|
||
public final class DefaultMirrorProvider implements MirrorProvider { |
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.
GitMirrorProvider
?
|
||
//noinspection EnhancedSwitchMigration | ||
switch (scheme) { | ||
case SCHEME_DOGMA: { |
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.
Could you file an issue about moving this back into the main server
module and add a TODO comment that has the issue URL? This scheme doesn't belong to server-mirror-git
.
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.
Added CentralDogmaMirrorProvider
and moved it back to the server
module. 😅
metaRepo.commit(Revision.HEAD, 0, Author.SYSTEM, "", | ||
Change.ofJsonUpsert( | ||
PATH_MIRRORS, | ||
"[{" + | ||
" \"enabled\": true," + | ||
" \"type\": \"single\"," + |
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.
Can we at least keep one entry with "type:": "single"
to ensure the backward compatibility?
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.
@@ -81,7 +81,7 @@ public String detail() { | |||
} | |||
|
|||
/** | |||
* Returns the {@link Markup} of the {@link #detail()}. | |||
* Returns the {@link Markup} of the {@code detail()}. |
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.
Maybe revert? This class still have #detail()
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.
Revert and make AbstractPushCommand
public
so that Javadoc is correctly rendered.
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.
👍
implementation libs.jgit.ssh.jsch | ||
// Hacky way to use different jGit versions depending on the test Java version. | ||
// We will use jgit6 after we drop the support for Java 8 client. | ||
if (project.ext.testJavaVersion >= 11) { |
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.
Sorry for the late review.
It is weird to change the target dependency which will be added to the POM file depending on testJavaVersion
.
project.ext.targetJavaVersion
should be a better choice.
If we want to test with jgit6, we can raise minimumJavaVersion
to 11 or higher versions.
https://github.com/line/armeria/pull/4812/files#diff-79a2782078afe306b9bc1be1e6e5b3d1d94f9ef585741688c4d05bd4243569f5R4
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 use project.ext.targetJavaVersion
, can we use jgit5 for testing the client
module with testJavaVersion
8?
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.
Yes, it works.
# Use JGit 5 for testing.
~/src/centraldogma/client main* ⇣⇡
❯ gw clean :client:java-armeria:test -PtestJavaVersion=11
❯ ag "JGit version"
java-armeria/build/test-results/test/TEST-com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogmaTest.xml
57:2023-08-23 20:20:39.660 [INFO ](c.l.c.s.i.s.r.g.GitRepository) [repository-worker-6-1] JGit version: 5.13.0.202109080827-r
java-armeria/build/reports/tests/test/classes/com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogmaTest.html
146:2023-08-23 20:20:39.660 [INFO ](c.l.c.s.i.s.r.g.GitRepository) [repository-worker-6-1] JGit version: 5.13.0.202109080827-r
# Use JGit 6 for testing
❯ gw clean :client:java-armeria:test -PtestJavaVersion=11 -PminimumJavaVersion=11
❯ ag "JGit version"
java-armeria/build/test-results/test/TEST-com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogmaTest.xml
57:2023-08-23 20:20:08.281 [INFO ](c.l.c.s.i.s.r.g.GitRepository) [repository-worker-6-1] JGit version: 6.6.0.202305301015-r
java-armeria/build/reports/tests/test/classes/com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogmaTest.html
146:2023-08-23 20:20:08.281 [INFO ](c.l.c.s.i.s.r.g.GitRepository) [repository-worker-6-1] JGit version: 6.6.0.202305301015-r
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.
By the way, I thought, an info message for the current JGit version would be useful.
static {
InputStream is = null;
try {
is = SystemReader.class.getClassLoader().getResourceAsStream("META-INF/maven/org.eclipse.jgit/org.eclipse.jgit/pom.properties");
final Properties props = new Properties();
props.load(is);
final Object jgitVersion = props.get("version");
if (jgitVersion != null) {
logger.info("Using JGit: {}", jgitVersion);
}
} catch (IOException e) {
logger.debug("Failed to read JGit version", e);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
}
Let me send a PR for that.
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.
Yes, it works.
Does it work when we specify -PtestJavaVersion=8
? 🤔
Could you also share how did you implement the build.gradle
?
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.
Anyway, it's too late so let's keep discussing tomorrow. 😉
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.
We don’t need to set an extra properties since we publish the server module with JGit 5.
JGit 6 will be chosen only mininumJavaVersion is higher than 11.
When packing a tarball, JGit 5 is excluded and JGit 6 is added instead.
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.
Ah ha, now I understand. Well actually, publishing the server module with JGit 6 was my intention but I guess I was wrong because users would still need the server module for testing. Let me make a change, then. Thanks!
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.
The change is pushed: 5118422
PTAL. 🙇
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.
It looks 👍!
Motivation:
Previously, the server module was using jgit5 and jgit6 libraries together. It's because jgit6 requires JDK 11 as a minimum, so we needed jgit5 for JDK 8 client.
However, that might cause a dependency conflict problem such as #835. If we extract jgit6 specific API and implementations to a new module, we can avoid this problem.
Modifications:
MirrorProvider
interface that creates aMirror
.MirrorProvider
s are discovered via SPI.server-mirror-git
and addedGitMirrorProvider
.javaTestVersion
is greater or equal to 11.javaTestVersion
is 8.type
property, which was useless, in the mirroring configuration is now removed.server-git6
module.Result: