连接到events.pagerduty.com:443连接超时

时间:2017-10-06 19:53:59

标签: jenkins connection-timeout post-build-event jenkins-2 pagerduty

Jenkins 2.82

詹金斯大师 - 从这台机器上,我无法访问互联网/外部世界。

Jenkins奴隶服务器,运行docker容器(用于从服务器),可以访问外部世界/互联网。

我安装了PagerDuty插件,并在作业中正确配置,以便在每次失败时以及状态恢复正常时发送通知。

当我运行这份工作时,我收到以下错误消息com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.conn.ConnectTimeoutException: Connect to events.pagerduty.com:443 [events.pagerduty.com/54.244.255.45, events.pagerduty.com/54.241.36.66, events.pagerduty.com/104.45.235.10] failed: connect timed out

0:49:44 
10:49:44 Resolving incident
10:50:14 Error while trying to resolve 
10:50:14 com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.conn.ConnectTimeoutException: Connect to events.pagerduty.com:443 [events.pagerduty.com/54.244.255.45, events.pagerduty.com/54.241.36.66, events.pagerduty.com/104.45.235.10] failed: connect timed out
10:50:14 Build step 'PagerDuty Incident Trigger' marked build as failure
10:50:14 Notifying upstream projects of job completion
10:50:14 Finished: FAILURE

我首先登录到奴隶机并试图ping event.pagerduty.com服务器旁边的IP(如上所列)并且ping工作正常。在端口443(ssh)上执行telnet也提供了有效的输出。

由于从属服务器实际上是docker容器,我进入了一个容器从属服务器并做了同样的事情(ping,telnet 443为那些  events.pagerduty.com IP,nslookup和nc / ncat等输出看起来不错。

在这里,我在docker slave容器的主机内,即我运行docker exec -it shenazi_ninza bash,我现在在容器的主机/ IP内:

root@da5ca3fef1c8:/data# hostname                                                                                                                          
da5ca3fef1c8
root@da5ca3fef1c8:/data# hostname; hostname -i                                                                                                             
da5ca3fef1c8
172.17.137.77
root@da5ca3fef1c8:/data# nslookup events.pagerduty.com                                                                                                     
Server:     17.178.6.10
Address:    17.178.6.10#53

Non-authoritative answer:
events.pagerduty.com    canonical name = events.gslb.pagerduty.com.
Name:   events.gslb.pagerduty.com
Address: 54.241.36.66
Name:   events.gslb.pagerduty.com
Address: 54.245.112.46
Name:   events.gslb.pagerduty.com
Address: 104.45.235.10

root@da5ca3fef1c8:/data# 
root@da5ca3fef1c8:/data# for s in `nslookup events.pagerduty.com|grep "Address: [0-9]"|sed "s/ //g"|cut -d':' -f2`; do echo Server: $s; telnet $s 443; done
Server: 54.245.112.46
Trying 54.245.112.46...
Connected to 54.245.112.46.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
Server: 104.45.235.10
Trying 104.45.235.10...
Connected to 104.45.235.10.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
Server: 54.241.36.66
Trying 54.241.36.66...
Connected to 54.241.36.66.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
root@da5ca3fef1c8:/data# for s in `nslookup events.pagerduty.com|grep "Address: [0-9]"|sed "s/ //g"|cut -d':' -f2`; do echo Server: $s; telnet $s 443; done
Server: 54.245.112.46
Trying 54.245.112.46...
Connected to 54.245.112.46.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
Server: 54.241.36.66
Trying 54.241.36.66...
Connected to 54.241.36.66.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
Server: 54.244.255.45
Trying 54.244.255.45...
Connected to 54.244.255.45.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
root@da5ca3fef1c8:/data# ^C
root@da5ca3fef1c8:/data# nc -v -w 1 events.pagerduty.com 443
Connection to events.pagerduty.com 443 port [tcp/https] succeeded!
root@da5ca3fef1c8:/data# 

Jenkins作业配置中的PagerDuty集成可在POST Built Actions区域下找到。

我的问题是,整个作业是不是在奴隶服务器上运行(也就是我可以访问外部世界的容器&从属服务器,我能够连接到events.pagerduty.com服务器) ?

似乎詹金斯在POST Build Data部分下运行任何东西,在主Jenkins实例上,我无法访问events.pagerduty.com(ping / telnet等)?由于我们不希望Jenkins master访问外部世界,如何解决此问题,以便在构建失败时可以收到警报?

1 个答案:

答案 0 :(得分:0)

因此,不是打开所有访问,而是添加路由以使用给定的网关/路由来仅访问events.pagerduty.com服务器

/sbin/route add -net 50.0.0.0/8 x.x.x.x dev eth0
/sbin/route add default gw x.y.z.someIP
/sbin/route add -net 50.0.0.0 netmask 255.0.0.0 gw x.y.z.ip

现在来自Jenkins大师,我能够查看/访问events.pagerduty.com服务器/它的IP。

x.y.z.ip是您必须放置的。