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

UknownHostException when node hostname is not 'localhost' #19

Closed
sw00 opened this issue Mar 11, 2014 · 5 comments

Comments

Projects
None yet
4 participants
@sw00
Copy link

commented Mar 11, 2014

Steps to reproduce

  1. Install go-agent on node: dpkg -i go-agent-13.4.1-18342.deb
  2. Edit /etc/default/go-agent to point it to go-server instance.
  3. Change node hostname to anything other than "localhost": hostname go-agent
  4. Restart go-agent: /etc/init.d/go-agent restart

Expected result

Go agent process starts and registers itself on go-server.

Actual result

Go agent is not registered on go-server.

cat /var/log/go-agent-stderr.log gives the following output.

    Exception in thread "main" java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:622)
            at com.simontuffs.onejar.Boot.run(Boot.java:306)
            at com.simontuffs.onejar.Boot.main(Boot.java:159)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agentController' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
            at com.thoughtworks.cruise.agent.AgentMain.main(AgentMain.java:26)
            ... 6 more
    Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
            ... 20 more
    Caused by: java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:43)
            at com.thoughtworks.cruise.agent.AgentController.<init>(AgentController.java:49)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
            ... 22 more
    Caused by: java.net.UnknownHostException: goAgent: goAgent
            at java.net.InetAddress.getLocalHost(InetAddress.java:1461)
            at com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:41)
            ... 28 more
    Exception in thread "main" java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:622)
            at com.simontuffs.onejar.Boot.run(Boot.java:306)
            at com.simontuffs.onejar.Boot.main(Boot.java:159)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agentController' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
            at com.thoughtworks.cruise.agent.AgentMain.main(AgentMain.java:26)
            ... 6 more
    Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
            ... 20 more
    Caused by: java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
            at com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:43)
            at com.thoughtworks.cruise.agent.AgentController.<init>(AgentController.java:49)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
            ... 22 more
    Caused by: java.net.UnknownHostException: goAgent: goAgent
            at java.net.InetAddress.getLocalHost(InetAddress.java:1461)
            at com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:41)
            ... 28 more
@bsharanya

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2014

Hi Sett,

Is the hostname "go-agent" valid? Can you ping "go-agent" from the command
line and check the output? The hostname that the Agent looks for needs to
be a fully qualified domain name.

But, I agree that this should not be a fatal error and should not bring
down the agent. If the hostname is not valid, may be it should say "Unknown
Agent Hostname", but still bring up the agent? Thoughts?

Regards,
Sharanya

On Tue, Mar 11, 2014 at 11:16 PM, Sett notifications@github.com wrote:

Steps to reproduce

Install go-agent on node: dpkg -i go-agent-13.4.1-18342.deb
2.

Edit /etc/default/go-agent to point it to go-server instance.
3.

Change node hostname to anything other than "localhost": hostname
go-agent
4.

Restart go-agent: /etc/init.d/go-agent restart

Expected result

Go agent process starts and registers itself on go-server.
Actual result

Go agent is not registered on go-server.

cat /var/log/go-agent-stderr.log gives the following output.

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.simontuffs.onejar.Boot.run(Boot.java:306)
at com.simontuffs.onejar.Boot.main(Boot.java:159)

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'agentController' defined in class path resource
[applicationContext.xml]: Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor
threw exception; nested exception is java.lang.RuntimeException:
java.net.UnknownHostException: goAgent: goAgent
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.thoughtworks.cruise.agent.AgentMain.main(AgentMain.java:26)
... 6 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [com.thoughtworks.cruise.agent.AgentController]:
Constructor threw exception; nested exception is
java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 20 more
Caused by: java.lang.RuntimeException: java.net.UnknownHostException:
goAgent: goAgent
at
com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:43)
at com.thoughtworks.cruise.agent.AgentController.(AgentController.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 22 more
Caused by: java.net.UnknownHostException: goAgent: goAgent
at java.net.InetAddress.getLocalHost(InetAddress.java:1461)
at
com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:41)
... 28 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.simontuffs.onejar.Boot.run(Boot.java:306)
at com.simontuffs.onejar.Boot.main(Boot.java:159)
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'agentController' defined in class path resource
[applicationContext.xml]: Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.thoughtworks.cruise.agent.AgentController]: Constructor
threw exception; nested exception is java.lang.RuntimeException:
java.net.UnknownHostException: goAgent: goAgent
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.thoughtworks.cruise.agent.AgentMain.main(AgentMain.java:26)
... 6 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [com.thoughtworks.cruise.agent.AgentController]:
Constructor threw exception; nested exception is
java.lang.RuntimeException: java.net.UnknownHostException: goAgent: goAgent
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 20 more
Caused by: java.lang.RuntimeException: java.net.UnknownHostException:
goAgent: goAgent
at
com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:43)
at com.thoughtworks.cruise.agent.AgentController.(AgentController.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 22 more
Caused by: java.net.UnknownHostException: goAgent: goAgent
at java.net.InetAddress.getLocalHost(InetAddress.java:1461)
at
com.thoughtworks.cruise.util.SystemUtil.getLocalhostName(SystemUtil.java:41)
... 28 more

Reply to this email directly or view it on GitHubhttps://github.com//issues/19
.

@arvindsv

This comment has been minimized.

Copy link
Member

commented Mar 13, 2014

I agree. It shouldn't be a fatal error.

@sw00

This comment has been minimized.

Copy link
Author

commented Mar 13, 2014

This may not be an issue with Go. The linux hostname go-agent command I typed doesn't seem to change the /etc/hostname file at all nor does it add an entry to /etc/hosts so ping go-agent will not resolve.

That said however, not being able to resolve a hostname should not be a fatal error.

@arvindsv

This comment has been minimized.

Copy link
Member

commented Mar 13, 2014

I've changed this behavior. It uses a random name (like "unknown-host-1"), if the hostname is not valid.

@arikagoyal arikagoyal added bug labels Mar 13, 2014

@arikagoyal

This comment has been minimized.

Copy link
Contributor

commented Mar 19, 2014

Works on 24ac72b11eb03a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.