cloudfoundry-community / autosleep

Auto sleep service for CloudFoundry
Apache License 2.0
39 stars 21 forks source link

autosleep use of deprecated logging-endpoint, fails fetching app activity, and never stop apps #264

Closed gberche-orange closed 7 years ago

gberche-orange commented 7 years ago

We observe the following stack trace:

2016-11-10T15:37:21.75+0100 [APP/0]      OUT Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of VALUE_NUMBER_INT token
2016-11-10T15:37:21.75+0100 [APP/0]      OUT  at [Source: 404 Not Found: Requested route ('loggregator.[...]') does not exist.
2016-11-10T15:37:21.75+0100 [APP/0]      OUT ; line: 1, column: 1]
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:857)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:853)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:875)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:337)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         at org.cloudfoundry.spring.client.v2.CloudFoundryExceptionBuilder.build(CloudFoundryExceptionBuilder.java:42)
2016-11-10T15:37:21.75+0100 [APP/0]      OUT         ... 15 common frames omitted
2016-11-10T15:37:22.25+0100 [APP/0]      OUT ERROR - pool-1-thread-3 - o.c.a.w.ApplicationStopper(136) - unsuspected error
2016-11-10T15:37:22.25+0100 [APP/0]      OUT java.lang.IllegalStateException: subscriber timed out
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.access.cloudfoundry.CloudFoundryApi.waitForResult(CloudFoundryApi.java:439)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.access.cloudfoundry.CloudFoundryApi.getApplicationActivity(CloudFoundryApi.java:249)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.worker.ApplicationStopper.handleApplicationEnrolled(ApplicationStopper.java:120)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.worker.ApplicationStopper.lambda$run$1(ApplicationStopper.java:197)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.util.ApplicationLocker.executeThreadSafe(ApplicationLocker.java:47)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at org.cloudfoundry.autosleep.worker.ApplicationStopper.run(ApplicationStopper.java:190)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2016-11-10T15:37:22.25+0100 [APP/0]      OUT         at java.lang.Thread.run(Thread.java:745)

As a result, applications are never put to sleep.

This seems to come from the fact that autosleep uses the 2.0.0.M1 version of cf-java-client (see #252 ) which was using a deprecated version of the logging endpoint logging_endpoint and not the new doppler_logging_endpoint

Starting with v244,

From this release onwards, Loggregator is no longer registering it legacy logging_endpoint 
with the router. This makes the legacy endpoints on Traffic Controller unaccessible.

See related https://www.pivotaltracker.com/story/show/129384577 remove legacy endpoint from cf-release

The current cf-java-client does seem to use the new doppler endpoint, see https://github.com/cloudfoundry/cf-java-client/blob/v2.0.2.RELEASE/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/doppler/_ReactorDopplerClient.java#L80

However, it seems that upgrade to latest client #252 is still blocked on https://github.com/cloudfoundry/cf-java-client/issues/551

Alternatives:

gberche-orange commented 7 years ago

Refinining the alternatives for this issue as well as #187 :

gberche-orange commented 7 years ago

Progress is being done by the cf-java-client team to have a reliable "recentLog" support, remaining dependent issue is tracked on https://github.com/cloudfoundry/cf-java-client/issues/672