Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63982

Calling wrong aws ec2 endpoint when provision a worker node, if region is AWS China

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Fixed but Unreleased (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      I'm trying to setup a worker node in AWS China (cn-northwest-1), when the master node is in Singapore (ap-southeast-1)

      The cloud configuration can't list the china regions so I setup the EC2 endpoint

      Alternate EC2 Endpoint: https://ec2.cn-northwest-1.amazonaws.com.cn

      then list all the regions correctly (both, cn-north and cn-northwest).

      But then I try to create a new agent, the java code try to call a different endpoint: `ec2.cn-northwest-1.amazonaws.com`

      it's calling `amazonaws.com`. and not  `amazonaws.com.cn`, it seems it recreates the domain to make the call and not using the endpoint I set.

       

       
      Oct 19, 2020 8:45:24 AM WARNING hudson.init.impl.InstallUncaughtExceptionHandler handleException
      Caught unhandled exception with ID b3d3c176-438e-4e94-95e4-0542941b3f72
      java.net.UnknownHostException: ec2.cn-northwest-1.amazonaws.com
       at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:797)
       at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505)
       at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364)
       at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298)
       at com.amazonaws.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:27)
       at com.amazonaws.http.DelegatingDnsResolver.resolve(DelegatingDnsResolver.java:38)
       at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
       at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
       at jdk.internal.reflect.GeneratedMethodAccessor408.invoke(Unknown Source)
       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
       at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
       at com.amazonaws.http.conn.$Proxy77.connect(Unknown Source)
       at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
       at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
       at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
       at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
       at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
       at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
       at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1330)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)
      Caused: com.amazonaws.SdkClientException: Unable to execute HTTP request: ec2.cn-northwest-1.amazonaws.com
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1207)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1153)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
       at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
       at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
       at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
       at com.amazonaws.services.ec2.AmazonEC2Client.doInvoke(AmazonEC2Client.java:26040)
       at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:26007)
       at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:25996)
       at com.amazonaws.services.ec2.AmazonEC2Client.executeDescribeInstances(AmazonEC2Client.java:12329)
       at com.amazonaws.services.ec2.AmazonEC2Client.describeInstances(AmazonEC2Client.java:12300)
       at hudson.plugins.ec2.EC2Cloud.countCurrentEC2Slaves(EC2Cloud.java:470)
       at hudson.plugins.ec2.EC2Cloud.getPossibleNewSlavesCount(EC2Cloud.java:653)
       at hudson.plugins.ec2.EC2Cloud.getNewOrExistingAvailableSlave(EC2Cloud.java:671)
       at hudson.plugins.ec2.EC2Cloud.doProvision(EC2Cloud.java:427)
       at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
       at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
       at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
       at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
       at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
       at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
       at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
       at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:536)
       at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
       at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
       at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
       at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:281)
       at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
       at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
       at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
       at org.kohsuke.stapler.Stapler.invoke(Stapler.java:694)
       at org.kohsuke.stapler.Stapler.service(Stapler.java:240)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
       at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
       at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
       at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:129)
       at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
       at jenkins.security.ResourceDomainFilter.doFilter(ResourceDomainFilter.java:76)
       at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
       at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:153)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
       at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
       at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
       at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
       at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
       at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:51)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:36)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
       at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
       at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
       at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
       at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1369)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
       at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
       at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
       at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
       at org.eclipse.jetty.server.Server.handle(Server.java:501)
       at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
       at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
       at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
       at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:272)
       at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
       at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
       at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
       at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
       at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
       at java.base/java.lang.Thread.run(Thread.java:834)
      

      Let me know if you need more information.

        Attachments

          Issue Links

            Activity

            Hide
            miguelexaleap Miguel Acevedo added a comment -

            Could be this part of the code the problem?

            /src/main/java/hudson/plugins/ec2/AmazonEC2Cloud.java

            public static URL getEc2EndpointUrl(String region) {
                try {
                    return new URL("https://ec2." + region + "." + AWS_URL_HOST + "/");
                } catch (MalformedURLException e) {
                    throw new Error(e); // Impossible
                }
            }
            
            Show
            miguelexaleap Miguel Acevedo added a comment - Could be this part of the code the problem? /src/main/java/hudson/plugins/ec2/AmazonEC2Cloud.java public static URL getEc2EndpointUrl( String region) { try { return new URL( "https: //ec2." + region + "." + AWS_URL_HOST + "/" ); } catch (MalformedURLException e) { throw new Error(e); // Impossible } }
            Hide
            openglx Felipe . added a comment -

            A PR has been rased to fix this particular situation: https://github.com/jenkinsci/ec2-plugin/pull/531

             

            Show
            openglx Felipe . added a comment - A PR has been rased to fix this particular situation: https://github.com/jenkinsci/ec2-plugin/pull/531  

              People

              Assignee:
              bluersw Sun WeiSheng
              Reporter:
              miguelexaleap Miguel Acevedo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: