Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

docker-agent should return a non zero value when java exception returned or policy wrong #3

Open
llecaroz opened this issue Jun 2, 2017 · 1 comment

Comments

@llecaroz
Copy link
Contributor

llecaroz commented Jun 2, 2017

Hi,

Today the docker-agent returns 0 every time as exit code. This is a little bit annoying because the caller cannot detect when an error was generated by the docker agent:

  • java exception
  • or errors (not green status) detected during policies checking or other checks.

Maybe something like this could be done:

  • 0=OK (everything is green)
  • 1=WARNING (some checks contain yellow/orange warnings)
  • 2=Some checks are red
  • -1= java exception ? file access, networking when connecting to the whitesource server or other

Thx in advance a lot to take into consideration this proposal
Best regards
Louis

@llecaroz
Copy link
Contributor Author

Hi
Just checked with the latest version & as some exceptions are catched in some deeper methods & not thrown upper, the error code is still 0 & cannot be managed in a clean way

[INFO] Using proxy: proxy:8080
[INFO] Checking policies
[ERROR] Failed to send request to WhiteSource server: errno: 111 (Connection refused), error: Connection refused (local port 60712 to address 10.97.25.202, remote port 8080 to address 147.204.6.136 (proxy))
org.whitesource.agent.client.WssServiceException: errno: 111 (Connection refused), error: Connection refused (local port 60712 to address 10.97.25.202, remote port 8080 to address 147.204.6.136 (proxy))
at org.whitesource.agent.client.WssServiceClientImpl.service(WssServiceClientImpl.java:240) ~[docker-agent.jar:na]
at org.whitesource.agent.client.WssServiceClientImpl.checkPolicyCompliance(WssServiceClientImpl.java:151) ~[docker-agent.jar:na]
at org.whitesource.agent.client.WhitesourceService.checkPolicyCompliance(WhitesourceService.java:164) ~[docker-agent.jar:na]
at org.whitesource.agent.CommandLineAgent.checkPolicies(CommandLineAgent.java:156) [docker-agent.jar:na]
at org.whitesource.agent.CommandLineAgent.sendRequest(CommandLineAgent.java:112) [docker-agent.jar:na]
at org.whitesource.agent.CommandLineAgent.sendRequest(CommandLineAgent.java:79) [docker-agent.jar:na]
at org.whitesource.docker.Main.main(Main.java:68) [docker-agent.jar:na]
Caused by: java.net.ConnectException: errno: 111 (Connection refused), error: Connection refused (local port 60712 to address 10.97.25.202, remote port 8080 to address 147.204.6.136 (proxy))
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_92]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_92]
at java.net.Socket.connect(Socket.java:591) ~[na:1.8.0_92]
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117) ~[docker-agent.jar:na]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177) ~[docker-agent.jar:na]
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304) ~[docker-agent.jar:na]
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611) ~[docker-agent.jar:na]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446) ~[docker-agent.jar:na]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882) ~[docker-agent.jar:na]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) ~[docker-agent.jar:na]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220) ~[docker-agent.jar:na]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) ~[docker-agent.jar:na]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139) ~[docker-agent.jar:na]
at org.whitesource.agent.client.WssServiceClientImpl.service(WssServiceClientImpl.java:218) ~[docker-agent.jar:na]
... 6 common frames omitted
[Pipeline] echo
Scanning returned value: 0

Thx in advance
Best regards
Louis

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant