由于读取超时,Jenkins 插件管理器无法安装/更新插件

阿提拉·奇帕克

我们的团队最近在 Jenkins 插件管理器安装/更新插件时遇到了一些问题。在我们修复了防火墙和代理规则的一些问题(我们位于公司防火墙和代理之后)之后,我们仍然无法下载一些插件文件。

一些插件文件已成功下载并安装,另一些则因以下错误而失败:

Failed to install git-client
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    at java.net.SocketInputStream.read(SocketInputStream.java:171)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1593)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3057)
    at java.net.URLConnection.getHeaderFieldLong(URLConnection.java:629)
    at java.net.URLConnection.getContentLengthLong(URLConnection.java:501)
    at java.net.URLConnection.getContentLength(URLConnection.java:485)
    at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1161)
Caused: java.net.SocketTimeoutException: Read timed out
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1177)
Caused: java.io.IOException: Failed to load http://updates.jenkins-ci.org/download/plugins/git-client/3.0.0/git-client.hpi to /var/lib/jenkins/plugins/git-client.jpi.tmp
    at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1184)
Caused: java.io.IOException: Failed to download from http://updates.jenkins-ci.org/download/plugins/git-client/3.0.0/git-client.hpi (redirected to: http://ftp-nyc.osuosl.org/pub/jenkins/plugins/git-client/3.0.0/git-client.hpi)
    at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1218)
    at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1766)
    at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2037)
    at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1740)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:112)
    at java.lang.Thread.run(Thread.java:748)

为了诊断潜在的网络问题,我尝试通过 curl 直接从托管 Jenkins 服务器的机器上下载 git-client.hpi,这是成功的:

[root@servername ~]# curl -vk -x http://proxyserver:7689 http://ftp-nyc.osuosl.org/pub/jenkins/plugins/git-client/3.0.0/git-client.hpi -o /tmp/git-client.hpi
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to proxy proxyserver port 6789 (#0)
*   Trying 10.100.50.100...
* Connected to proxyserver (10.100.50.100) port 6789(#0)
> GET http://ftp-nyc.osuosl.org/pub/jenkins/plugins/git-client/3.0.0/git-client.hpi HTTP/1.1
> User-Agent: curl/7.29.0
> Host: ftp-nyc.osuosl.org
> Accept: */*
> Proxy-Connection: Keep-Alive
>
  0     0    0     0    0     0      0      0 --:--:--  0:01:01 --:--:--     0< HTTP/1.1 200 OK
< Date: Mon, 11 Nov 2019 08:18:55 GMT
< Server: Apache
< Last-Modified: Sat, 02 Nov 2019 12:03:46 GMT
< ETag: "7dd268-5965bdfed67ce"
< Accept-Ranges: bytes
< Content-Type: application/vnd.hp-hpid
< Age: 6915
< Content-Length: 8245864
< Via: 1.1 proxyserver
<
  0 8052k    0     0    0     0      0      0 --:--:--  0:01:01 --:--:--     0{ [data not shown]
100 8052k  100 8052k    0     0   130k      0  0:01:01  0:01:01 --:--:-- 2132k
* Connection #0 to host proxyserver left intact

通过 curl 下载是成功的,虽然我注意到连接成功后,下载过程在 0% 停滞了大约一分钟。然后它突然开始,并在几秒钟内完成。

编辑这不是基础设施问题,与 INFRA-2393 无关,也与更新站点的问题相关的任何其他问题:

  • 这个读取超时是在 2019 年 10 月首次遇到的,可以在 2019 年 12 月中旬重现。基础设施问题往往比这更快解决。

  • 在 INFRA-2393 解决很久之后,我还设法在欧洲中部时间 2020-01-02 10:30 左右使用 /plugins/subversion/2.13.0/subversion.hpi 使用 60 秒读取超时设置重现了该问题。我还通过提高读取超时设置来解决这个问题,如下所述。

  • 读取超时仅发生在 Jenkins 内。在浏览器或 curl 命令中使用相同的下载链接下载受影响的文件。这是因为 Jenkins 的默认读取超时为 60 秒,而浏览器 / curl 没有。

  • 在早先对此进行诊断的同时,我们重新安排了我们的网络策略并使 Jenkins 直接访问更新站点(不使用代理)。在这种情况下,所有问题下载都有效。这表明下载停止与更新站点错误无关,而是与我们自己的代理有关。


另外,不要让我提交一份关于 Jenkins Jira 的报告。我发布这个问题和我的回答的真正原因是我对尝试使用 Jenkins Jira 寻找解决方案感到沮丧。我在那里找到的与我的问题相关的材料大致分为两类:

  • 基础设施问题可以追溯到几年前,显然是在几年前解决的。换句话说:噪音。

  • 真正的 Jenkins 问题发布了类似的症状,发布了数十/数百条评论,主要归结为 Jenkins 工作人员指出问题出在用户方面,人们应该修复他们自己的公司防火墙/代理/等。没有一个字相关超时值。换句话说:更多的噪音。

再次强调:这不是与 Jenkins 更新站点相关的问题,也不是 Jenkins 软件错误。如果它与任何事情有关,那么它与缺乏文档有关。正是 SO 旨在涵盖恕我直言的事情。

阿提拉·奇帕克

从上面要注意的重要一点是,这不是连接超时而是读取超时与下载镜像的连接已建立,但客户端在大约一分钟内未收到任何字节。(我们假设发生这种情况是因为我们的代理在将字节转发给请求下载的客户端之前分析了 git-client.hpi 的内容。)

curl 下载成功,因为命令中没有设置读取超时。Jenkins 显然使用 60 秒的默认套接字读取超时,因此在 60 秒内没有流量后,它会认为连接已死并因 SocketException 而失败。

我没有找到任何关于此的官方文档,但查看Jenkins 源代码证实了这一理论:UpdateCenter.PLUGIN_DOWNLOAD_READ_TIMEOUT常量是从属性值初始化的,如果没有,则默认为 60。

我没有找到的另一件事是 Jenkins 属性的综合文档(键名、可能的值、描述等)。

要设置的确切属性键是:hudson.model.UpdateCenter.pluginDownloadReadTimeoutSeconds

AFAIK Jenkins 没有任何 *.properties 文件,但在启动时接受属性设置作为 JVM 参数。

我通过找到jenkins选项文件解决了这个问题(如果你使用 RHEL,并从包存储库安装 Jenkins,确切的路径是:/etc/sysconfig/jenkins),并将-Dhudson.model.UpdateCenter.pluginDownloadReadTimeoutSeconds=120附加JENKINS_JAVA_OPTIONS设置的

更新:我找到了关于 Jenkins 系统属性的官方 Jenkins 文档,其中也有关于 hudson.model.UpdateCenter.pluginDownloadReadTimeoutSeconds 属性的几句话。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Jenkins插件安装

在Docker中构建Jenkins时插件无法安装

通过npm安装SKPM(Sketch插件管理器)

无法打开插件管理器Jmeter 3.3

Jmeter插件管理器无法安装插件

无法在docker上安装建议的jenkins插件

安装插件后无法在Jenkins中找到SBT

jenkins无法安装插件-docker image

更新Jenkins插件的问题

由于依赖关系而无法安装IBM Worklight插件

ADT插件更新“由于依赖性冲突,无法完成安装。”

由于超时,Jenkins无法从Gitlab克隆

SonarQube Eclipse插件3.4由于连接超时而无法访问Sonar服务器

用于Jenkins的SonarQube插件安装

JMeter:在Ubuntu的“选项”>“插件管理器”中,插件管理器不显示任何更新

由于缺少jQuery插件,Jenkins“构建管道插件”插件安装失败

无法在 Jenkins 中安装 Groovy 插件

Maven tomcat 插件 - 无法调用 Tomcat 管理器

如何确保安装了插件管理器

插件管理器屏幕不工作,无法为 jmeter 添加并行控制器插件

无法通过 Kubernetes 在 jenkins 中安装插件

无法在 Linux Mint 中安装 Jmeter 插件管理器

为什么 jenkins 无法在 docker 中安装 git 插件?

使用 Ansible 安装 Jenkins 插件

无法在 JMeter 中打开插件管理器

使用插件管理器的 REST API 和 JQ 生成全面的 Jenkins 插件清单

为 jenkins 安装建议的插件

无法在安装时从 Jenkins 服务器安装任何插件。错误:读取超时

无法在 Docker 中部署的 Jenkins 中安装插件