Amazonec2インスタンスのjenkinsで実行されるMavenビルドがあります。ビルド全体には20〜30分かかりますが、Maven Centralからアーティファクトをダウンロードできないため、ほぼすべての実行で失敗します。これはログの失敗した部分です:
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.Apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.Apache.org/maven2
Downloading: https://repo.maven.Apache.org/maven2/org/Apache/maven/plugins/maven-failsafe-plugin/2.18.1/maven-failsafe-plugin-2.18.1.pom
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (Java.net.SocketException) caught when processing request to {s}->https://repo.maven.Apache.org:443: Connection reset
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.Apache.org:443
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (Java.net.SocketException) caught when processing request to {s}->https://repo.maven.Apache.org:443: Connection reset
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.Apache.org:443
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (Java.net.SocketException) caught when processing request to {s}->https://repo.maven.Apache.org:443: Connection reset
Feb 03, 2017 3:39:00 PM org.Apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.Apache.org:443
興味深いのは、Maven Centralと独自のリポジトリから20分間ダウンロードしても問題なく実行されますが、1回おきにまったく同じダウンロードで失敗することです。これは、他のダウンロードでランダムに失敗するため、接続の問題が原因ではないと思います。
グーグルした後、Ipv4とIpv6の問題が原因である可能性があることがわかったので、ビルドでJava.net.prefetIPv4stack = trueを設定しようとしましたが、それは役に立ちませんでした。
Mvnを実行するコマンドは次のとおりです。
mvn -X -e clean deploy -U -Djava.net.preferIPv4Stack=true
また、MAVEN_OPTSとJava_OPTSの両方で-Xmxを増やしようとしましたが(mavenがすべての依存関係をRAMに保持できる必要があることをどこかで読みましたが、本当かどうかはわかりません)、成功しませんでした。
他に試すことができるアイデアはありますか?
編集:スタックトレースを追加
[ERROR] Plugin org.Apache.maven.plugins:maven-failsafe-plugin:2.18.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.Apache.maven.plugins:maven-failsafe-plugin:jar:2.18.1: Could not transfer artifact org.Apache.maven.plugins:maven-failsafe-plugin:pom:2.18.1 from/to central (https://repo.maven.Apache.org/maven2): Connection reset -> [Help 1]
org.Apache.maven.plugin.PluginResolutionException: Plugin org.Apache.maven.plugins:maven-failsafe-plugin:2.18.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.Apache.maven.plugins:maven-failsafe-plugin:jar:2.18.1
at org.Apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.Java:117)
at org.Apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.Java:179)
at org.Apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.Java:284)
at org.Apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.Java:241)
at org.Apache.maven.lifecycle.internal.DefaultLifecycleMappingDelegate.calculateLifecycleMappings(DefaultLifecycleMappingDelegate.Java:110)
at org.Apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings(DefaultLifecycleExecutionPlanCalculator.Java:266)
at org.Apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions(DefaultLifecycleExecutionPlanCalculator.Java:217)
at org.Apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.Java:127)
at org.Apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.Java:145)
at org.Apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan(BuilderCommon.Java:96)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:109)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
Caused by: org.Eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.Apache.maven.plugins:maven-failsafe-plugin:jar:2.18.1
at org.Apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.Java:282)
at org.Apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.Java:198)
at org.Eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.Java:287)
at org.Apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.Java:103)
... 27 more
Caused by: org.Eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.Apache.maven.plugins:maven-failsafe-plugin:pom:2.18.1 from/to central (https://repo.maven.Apache.org/maven2): Connection reset
at org.Eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.Java:444)
at org.Eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.Java:246)
at org.Eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.Java:223)
at org.Apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.Java:267)
... 30 more
Caused by: org.Eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.Apache.maven.plugins:maven-failsafe-plugin:pom:2.18.1 from/to central (https://repo.maven.Apache.org/maven2): Connection reset
at org.Eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.Java:43)
at org.Eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.Java:355)
at org.Eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.Java:67)
at org.Eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.Java:581)
at org.Eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.Java:249)
at org.Eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.Java:520)
at org.Eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.Java:421)
... 33 more
Caused by: org.Apache.maven.wagon.TransferFailedException: Connection reset
at org.Apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.Java:1066)
at org.Apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.Java:960)
at org.Apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.Java:116)
at org.Apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.Java:88)
at org.Apache.maven.wagon.StreamWagon.get(StreamWagon.Java:61)
at org.Eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.Java:560)
at org.Eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.Java:427)
at org.Eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.Java:404)
at org.Eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.Java:447)
at org.Eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.Java:350)
... 38 more
Caused by: Java.net.SocketException: Connection reset
at Java.net.SocketInputStream.read(SocketInputStream.Java:209)
at Java.net.SocketInputStream.read(SocketInputStream.Java:141)
at Sun.security.ssl.InputRecord.readFully(InputRecord.Java:465)
at Sun.security.ssl.InputRecord.read(InputRecord.Java:503)
at Sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.Java:973)
at Sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.Java:930)
at Sun.security.ssl.AppInputStream.read(AppInputStream.Java:105)
at org.Apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.Java:136)
at org.Apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.Java:152)
at org.Apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.Java:270)
at org.Apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.Java:140)
at org.Apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.Java:57)
at org.Apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.Java:260)
at org.Apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.Java:161)
at org.Apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.Java:153)
at org.Apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.Java:271)
at org.Apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.Java:123)
at org.Apache.http.impl.execchain.MainClientExec.execute(MainClientExec.Java:254)
at org.Apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.Java:195)
at org.Apache.http.impl.execchain.RetryExec.execute(RetryExec.Java:86)
at org.Apache.http.impl.execchain.RedirectExec.execute(RedirectExec.Java:108)
at org.Apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.Java:184)
at org.Apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.Java:82)
at org.Apache.maven.wagon.providers.http.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.Java:832)
at org.Apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.Java:983)
... 47 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.Apache.org/confluence/display/MAVEN/PluginResolutionException
AzureVMでも同様の問題が発生します。この質問もここに投稿しました: Azure上のDockerコンテナー内で実行すると、Mavenビルドのダウンロードアーティファクト接続が遅く/リセットされます
セットアップはもう少し複雑です。Mavenのビルドステップを含むDockerコンテナーを実行します。
コンテナをACIとAzureの両方で実行している場合VM-同じ問題が発生し、Mavenの中央ダウンロードがタイムアウトするか成功しましたが、速度は非常に遅くなります。
14:10:48,505 [BasicRepositoryConnector-repo.maven.Apache.org-27-0] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/regexp/regexp/1.3/regexp-1.3.jar
14:10:48,506 [BasicRepositoryConnector-repo.maven.Apache.org-27-2] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/org/Apache/maven/scm/maven-scm-provider-cvs-commons/1.7/maven-scm-provider-cvs-commons-1.7.jar
14:10:48,505 [BasicRepositoryConnector-repo.maven.Apache.org-27-1] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/org/Apache/maven/scm/maven-scm-provider-git-commons/1.7/maven-scm-provider-git-commons-1.7.jar
14:10:48,521 [BasicRepositoryConnector-repo.maven.Apache.org-27-3] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.jar
14:10:48,523 [BasicRepositoryConnector-repo.maven.Apache.org-27-4] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar
14:10:48,540 [BasicRepositoryConnector-repo.maven.Apache.org-27-0] [INFO] Downloaded from central: https://repo.maven.Apache.org/maven2/regexp/regexp/1.3/regexp-1.3.jar (25 kB at 706 kB/s)
14:10:48,540 [BasicRepositoryConnector-repo.maven.Apache.org-27-0] [INFO] Downloading from central: https://repo.maven.Apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar
14:10:48,564 [BasicRepositoryConnector-repo.maven.Apache.org-27-0] [INFO] Downloaded from central: https://repo.maven.Apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar (172 kB at 4.0 MB/s)
14:26:32,150 [BasicRepositoryConnector-repo.maven.Apache.org-27-2] [INFO] Downloaded from central: https://repo.maven.Apache.org/maven2/org/Apache/maven/scm/maven-scm-provider-cvs-commons/1.7/maven-scm-provider-cvs-commons-1.7.jar (80 kB at 84 B/s)
14:26:32,157 [BasicRepositoryConnector-repo.maven.Apache.org-27-4] [INFO] Downloaded from central: https://repo.maven.Apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar (151 kB at 159 B/s)
14:26:32,199 [BasicRepositoryConnector-repo.maven.Apache.org-27-3] [INFO] Downloaded from central: https://repo.maven.Apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.jar (744 kB at 788 B/s)
疑わしいことに注意してください:(159 B/sで151kB)、(84 B/sで80kB)、(788 B/sで744kB)正常に実行される実行の例とタイムアウトする実行の例( 1時間)-1時間近くかかる実行の例。
Mvnコマンドを変更しようとしました-最初に実行しました:mvn clean package
しかし、追加しました:mvn compile dependency:resolve
mvn dependency:resolve-plugin
mvn clean package
これらの変更は、接続が遅くなる場所を変更するだけでした-いくつかのjarをダウンロードする代わりに、.pomファイルをダウンロードするときに遅くなりました。
TL; DR
Maven3.6.1にアップグレードしてみてください。再試行動作が改善された新しいバージョンのWagonHTTPがあります。これで問題が解決しました。
背景
私たちのビルドは(ec2で)何ヶ月も問題なく動作しました。その後、ある日、接続をリセットした状態で、Mavenアーティファクト(Mavenセントラルから)のダウンロードに散発的に失敗し始めました。私たちはその底に到達することはありませんでした。たぶんec2の何かが変更されました。たぶん私たちのビルドの何かが変更されました。ダンノ。
結論として、ネットワークは信頼性が低く、Maven(より具体的にはWagon)は接続障害に対してあまり回復力がありませんでした。ありがたいことに、彼らはそれを改善したようです。
Maven 3.6.1には、構成可能な再試行動作をサポートする新しいバージョンのWagonが含まれています。デフォルトでは、再試行回数は3であるように見えますが、これで十分でした。いくつかの詳細: