Skip to content

Commit

Permalink
fix(periodic): config for maxage/maxsize to prevent recording upload …
Browse files Browse the repository at this point in the history
…timeouts due to large filesize (#96)

* add configs for periodic maxage and maxsize

* null out field on state transition

* split between dedicated thread and worker pool

* cleanup/refactor

* fixup! cleanup/refactor

Signed-off-by: Andrew Azores <aazores@redhat.com>

* fix typo

* log periodic settings

---------

Signed-off-by: Andrew Azores <aazores@redhat.com>
  • Loading branch information
andrewazores authored Apr 18, 2023
1 parent eaa8653 commit d6daade
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 118 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ and how it advertises itself to a Cryostat server instance. Required properties
- [ ] `cryostat.agent.harvester.upload.timeout-ms` [`long`]: the duration in milliseconds to wait for HTTP upload requests to the Cryostat server to complete and respond. Default `30000`.
- [ ] `cryostat.agent.harvester.exit.max-age-ms` [`long`]: the JFR `maxage` setting, specified in milliseconds, to apply to recording data uploaded to the Cryostat server when the JVM this Agent instance is attached to exits. This ensures that tail-end data is captured between the last periodic push and the application exit. Exit uploads only occur when the application receives `SIGINT`/`SIGTERM` from the operating system or container platform.
- [ ] `cryostat.agent.harvester.exit.max-size-b` [`long`]: the JFR `maxsize` setting, specified in bytes, to apply to exit uploads as described above.
- [ ] `cryostat.agent.harvester.max-age-ms` [`long`]: the JFR `maxage` setting, specified in milliseconds, to apply to periodic uploads during the application lifecycle. Defaults to `0`, which is interpreted as 1.5x the harvester period (`cryostat.agent.harvester.period-ms`).
- [ ] `cryostat.agent.harvester.max-size-b` [`long`]: the JFR `maxsize` setting, specified in bytes, to apply to periodic uploads during the application lifecycle. Defaults to `0`, which means `unlimited`.

These properties can be set by JVM system properties or by environment variables. For example, the property
`cryostat.agent.baseuri` can be set using `-Dcryostat.agent.baseuri=https://mycryostat.example.com:1234/` or
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/io/cryostat/agent/ConfigModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public abstract class ConfigModule {
"cryostat.agent.harvester.exit.max-age-ms";
public static final String CRYOSTAT_AGENT_HARVESTER_EXIT_MAX_SIZE_B =
"cryostat.agent.harvester.exit.max-size-b";
public static final String CRYOSTAT_AGENT_HARVESTER_MAX_AGE_MS =
"cryostat.agent.harvester.max-age-ms";
public static final String CRYOSTAT_AGENT_HARVESTER_MAX_SIZE_B =
"cryostat.agent.harvester.max-size-b";

@Provides
@Singleton
Expand Down Expand Up @@ -264,17 +268,31 @@ public static long provideCryostatAgentHarvesterUploadTimeoutMs(SmallRyeConfig c
@Provides
@Singleton
@Named(CRYOSTAT_AGENT_HARVESTER_EXIT_MAX_AGE_MS)
public static long provideCryostatAgentHarvesterMaxAge(SmallRyeConfig config) {
public static long provideCryostatAgentHarvesterExitMaxAge(SmallRyeConfig config) {
return config.getValue(CRYOSTAT_AGENT_HARVESTER_EXIT_MAX_AGE_MS, long.class);
}

@Provides
@Singleton
@Named(CRYOSTAT_AGENT_HARVESTER_EXIT_MAX_SIZE_B)
public static long provideCryostatAgentHarvesterMaxSize(SmallRyeConfig config) {
public static long provideCryostatAgentHarvesterExitMaxSize(SmallRyeConfig config) {
return config.getValue(CRYOSTAT_AGENT_HARVESTER_EXIT_MAX_SIZE_B, long.class);
}

@Provides
@Singleton
@Named(CRYOSTAT_AGENT_HARVESTER_MAX_AGE_MS)
public static long provideCryostatAgentHarvesterMaxAge(SmallRyeConfig config) {
return config.getValue(CRYOSTAT_AGENT_HARVESTER_MAX_AGE_MS, long.class);
}

@Provides
@Singleton
@Named(CRYOSTAT_AGENT_HARVESTER_MAX_SIZE_B)
public static long provideCryostatAgentHarvesterMaxSize(SmallRyeConfig config) {
return config.getValue(CRYOSTAT_AGENT_HARVESTER_MAX_SIZE_B, long.class);
}

@Provides
@Singleton
@Named(CRYOSTAT_AGENT_EXIT_SIGNALS)
Expand Down
Loading

0 comments on commit d6daade

Please sign in to comment.