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

Adds retry mechanism to applyNullSafe method #204

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jlcontreras
Copy link

@jlcontreras jlcontreras commented Jan 29, 2019

While using the plugin for our CI system, we have noticed that on some rare occasions it fails to resolve the URL of the GitHub repository. This problem results in the following message (in normal conditions, repos would not be empty):

[Set GitHub commit status (universal)] SUCCESS on repos [] (sha:90a0bd0) with context: context

Changes in this PR:

  • Wraps applyNullSafe with a retry mechanism with linear backoff as a solution for the problem.
  • Update mojo to version 3.0.5 for compatibility with maven 3.6.0

The full trace is this one:

Jan 20, 2019 1:31:46 PM WARNING com.cloudbees.jenkins.GitHubRepositoryName$1 applyNullSafe Failed to obtain repository com.cloudbees.jenkins.GitHubRepositoryName$1@6647d12d java.net.UnknownHostException: api.github.com: Name or service not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) at java.net.InetAddress.getAllByName0(InetAddress.java:1277) at java.net.InetAddress.getAllByName(InetAddress.java:1193) at java.net.InetAddress.getAllByName(InetAddress.java:1127) at com.squareup.okhttp.Dns$1.lookup(Dns.java:39) at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175) at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141) at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83) at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174) at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126) at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95) at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281) at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224) at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:450) at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:399) at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:527) at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25) at org.kohsuke.github.Requester.parse(Requester.java:615) Caused: org.kohsuke.github.HttpException: Server returned HTTP response code: -1, message: 'null' for URL: https://api.github.com/repos/apache/incubator-mxnet at org.kohsuke.github.Requester.parse(Requester.java:646) at org.kohsuke.github.Requester.parse(Requester.java:607) at org.kohsuke.github.Requester._to(Requester.java:285) at org.kohsuke.github.Requester.to(Requester.java:247) at org.kohsuke.github.GitHub.getRepository(GitHub.java:475) at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:227) at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:223) at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18) at com.google.common.collect.Iterators$8.next(Iterators.java:812) at com.google.common.collect.Iterators$7.computeNext(Iterators.java:648) at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143) at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138) at com.google.common.collect.Iterators$5.hasNext(Iterators.java:543) at com.google.common.collect.Lists.newArrayList(Lists.java:138) at com.google.common.collect.Lists.newArrayList(Lists.java:119) at org.jenkinsci.plugins.github.util.FluentIterableWrapper.toList(FluentIterableWrapper.java:147) at org.jenkinsci.plugins.github.status.sources.ManuallyEnteredRepositorySource.repos(ManuallyEnteredRepositorySource.java:51) at org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter.perform(GitHubCommitStatusSetter.java:136) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:51) at hudson.security.ACL.impersonate(ACL.java:290) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:48) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)


This change is Reviewable

@@ -51,7 +51,7 @@
<jenkins-test-harness.version>1.625.3</jenkins-test-harness.version>
<release.skipTests>false</release.skipTests>
<maven.javadoc.skip>true</maven.javadoc.skip>
<findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
<findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version>

Choose a reason for hiding this comment

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

Should we do this in a separate PR?
Or is it necessary for the fix?

Copy link
Author

Choose a reason for hiding this comment

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

It is not necessary for this fix. I added it because I don't think it hurts, but it can be moved to a separate PR, or even not changed if there is any reason to keep it to 3.0.2.

Choose a reason for hiding this comment

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

Just about the atomicity of the commits.

LOGGER.warn("Failed to obtain repository {}", this, e);
return null;
int mtries = 0;
while (mtries < MAX_RETRIES) {

Choose a reason for hiding this comment

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

Is there some @annotation oriented retry mechanism in the project?
If so, can we use it?

Otherwise, can we look for some utility class/create one?

return gitHub.getRepository(format("%s/%s", repoName.getUserName(),
repoName.getRepositoryName()));
} catch (UnknownHostException e) {
LOGGER.warn("Failed to resolve repository {}", this, e);

Choose a reason for hiding this comment

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

Was this code covered by a unit test?
Should we raise the bar?

@KostyaSha
Copy link
Member

it fails to resolve the URL of the GitHub repository.

Sounds like you have issues with environment and it's not a plugin issue.

@lebeg
Copy link

lebeg commented Jan 31, 2019

Sounds like you have issues with environment and it's not a plugin issue.

Wouldn't a retry mechanism be beneficial in any case? Or you would suggest another place for the retries like the cache?

@KostyaSha
Copy link
Member

Probably better place in github client builder/connection itself, then it can handle any kind of errors

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

Successfully merging this pull request may close these issues.

4 participants