iriusrisk / GoCD-EC2-Elastic-Agent-Plugin

Plugin for GoCD server that will spin up and shut down EC2 instances as its agent workers on demand
Apache License 2.0
12 stars 12 forks source link

Plugin starting instances but not being able to use them #9

Closed rafaelberto97 closed 4 years ago

rafaelberto97 commented 4 years ago

Hello,

I’m having some trouble using the plugin. I’ve made all configurations based on the README but when I run the desired pipeline the instance is created on AWS (and it appears in the Status Report of the elastic agents configuration). It also is shown in the Agents screen as active. But in the pipeline I get some error and the plugin starts to create a new machine every 2 minutes (It doesn’t terminate the previous one, even if the config says that only 1 elastic agent is allowed). The console logs are:

[go] Received request to create an instance for Test/3/test/1/test at ** [go] Successfully created new instance ***** in subnet-**** [go] Could not create instance in any provided subnet! [go] Failed while creating instance: null [go] Received request to create an instance for Test/3/test/1/test at 2020-04-30 19:19:19 +00:00 [go] Successfully created new instance **** in subnet-**** [go] Could not create instance in any provided subnet! [go] Failed while creating instance: null

In this case 2 instances were created.

I have some go-server logs that may help: go-server.log WARN [Thread-80] PluginSettingsMetadataLoader:63 - Failed to fetch plugin settings metadata for plugin cd.go.authentication.ldap. Maybe the plugin does not implement plugin settings and view? WARN [Thread-80] PluginSettingsMetadataLoader:64 - Plugin: cd.go.authentication.ldap - Metadata load info: [{extension='authorization', configuration='null', view='null', error='The plugin sent a response that could not be understood by Go. Plugin returned with code '500' and the following response: 'This is an invalid request type :go.plugin-settings.get-configuration''}] WARN [Thread-80] PluginSettingsMetadataLoader:65 - Not all plugins are required to implement the request above. This error may be safe to ignore. INFO [WrapperJarAppMain] CachedGoConfig:223 - About to notify config listeners INFO [WrapperJarAppMain] CachedGoConfig:231 - Finished notifying all listeners WARN [Thread-80] PluginSettingsMetadataLoader:63 - Failed to fetch plugin settings metadata for plugin yum. Maybe the plugin does not implement plugin settings and view? WARN [Thread-80] PluginSettingsMetadataLoader:64 - Plugin: yum - Metadata load info: [{extension='package-repository', configuration='null', view='null', error='The plugin sent a response that could not be understood by Go. Plugin returned with code '400' and the following response: 'Invalid request name go.plugin-settings.get-configuration''}] WARN [Thread-80] PluginSettingsMetadataLoader:65 - Not all plugins are required to implement the request above. This error may be safe to ignore.

ERROR [161@MessageListener for CreateAgentListener] JMSMessageListenerAdapter:88 - Exception thrown in message handling by listener com.thoughtworks.go.server.messaging.elasticagents.CreateAgentListener@46315a2a java.lang.RuntimeException: java.lang.NullPointerException at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:214) at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.doOn(FelixGoPluginOSGiFramework.java:164) at com.thoughtworks.go.plugin.infra.DefaultPluginManager.submitTo(DefaultPluginManager.java:131) at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:49) at com.thoughtworks.go.plugin.access.elastic.v5.ElasticAgentExtensionV5.createAgent(ElasticAgentExtensionV5.java:142) at com.thoughtworks.go.plugin.access.elastic.ElasticAgentExtension.createAgent(ElasticAgentExtension.java:60) at com.thoughtworks.go.plugin.access.elastic.ElasticAgentPluginRegistry.createAgent(ElasticAgentPluginRegistry.java:43) at com.thoughtworks.go.server.messaging.elasticagents.CreateAgentListener.onMessage(CreateAgentListener.java:32) at com.thoughtworks.go.server.messaging.elasticagents.CreateAgentListener.onMessage(CreateAgentListener.java:22) at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:84) at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:64) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.lang.NullPointerException at com.continuumsecurity.elasticagent.ec2.Ec2Plugin.handle(Ec2Plugin.java:138) at com.thoughtworks.go.plugin.infra.DefaultPluginManager.lambda$submitTo$0(DefaultPluginManager.java:134) at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:208) ... 11 common frames omitted Caused by: java.lang.NullPointerException: null at com.continuumsecurity.elasticagent.ec2.Ec2AgentInstances.register(Ec2AgentInstances.java:320) at com.continuumsecurity.elasticagent.ec2.Ec2AgentInstances.create(Ec2AgentInstances.java:65) at com.continuumsecurity.elasticagent.ec2.Ec2AgentInstances.create(Ec2AgentInstances.java:41) at com.continuumsecurity.elasticagent.ec2.executors.CreateAgentRequestExecutor.execute(CreateAgentRequestExecutor.java:55) at com.continuumsecurity.elasticagent.ec2.Ec2Plugin.handle(Ec2Plugin.java:77) ... 13 common frames omitted

plugin-com.continuumsecurity.elasticagent.ec2.log

INFO [qtp1682476860-38] Ec2Plugin:72 - [status-report] Generating status report INFO [qtp1682476860-38] Ec2Plugin:72 - Status report 3 instances WARN [167@MessageListener for ServerPingListener] Ec2Plugin:97 - [Server Ping] Was expecting an instance ***, but it was missing! WARN [167@MessageListener for ServerPingListener] Ec2Plugin:97 - [Server Ping] Was expecting an instance ***, but it was missing! WARN [167@MessageListener for ServerPingListener] Ec2Plugin:97 - [Server Ping] Was expecting an instance ***, but it was missing!

The only change I’ve done was (like suggested on https://github.com/continuumsecurity/GoCD-EC2-Elastic-Agent-Plugin/issues/8) change the user data sed command to "sed -i -E \"s#h[^ <]*://[^ <]*:[^ <]*/go#http://[host]:[port]/go#g\" /usr/share/go-agent/wrapper-config/wrapper-properties.conf\n" +

Can you help me with this problem?

pgAdmin commented 4 years ago

You should have atleast 2 subnets in configuration.

rafaelberto97 commented 4 years ago

That worked! Thank you!