Skip to content

Commit

Permalink
Remove Heroku's Java Metrics Agent (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax authored May 24, 2024
1 parent 1ecc948 commit 13c3f24
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 333 deletions.
4 changes: 4 additions & 0 deletions buildpacks/jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Some error messages have changed so they longer suggest to open a Heroku support ticket. Instead, users are now provided with a link to create an issue on GitHub. ([#674](https://github.com/heroku/buildpacks-jvm/pull/674))

### Removed

- The buildpack no longer installs [Heroku's Java Metrics Agent](https://github.com/heroku/heroku-java-metrics-agent). It is only useful on the Heroku platform and can be installed by a dedicated buildpack in the future. ([#679](https://github.com/heroku/buildpacks-jvm/pull/679))

## [5.0.1] - 2024-05-23

### Changed
Expand Down
4 changes: 0 additions & 4 deletions buildpacks/jvm/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,5 @@ arch = "amd64"
os = "linux"
arch = "arm64"

[metadata.heroku-metrics-agent]
url = "https://repo1.maven.org/maven2/com/heroku/agent/heroku-java-metrics-agent/4.0.1/heroku-java-metrics-agent-4.0.1.jar"
sha256 = "9a718680e4a93f93a8755b20fb21cc541e5c2692acc9da27c667530f48a716db"

[metadata.release]
image = { repository = "docker.io/heroku/buildpack-jvm" }
131 changes: 0 additions & 131 deletions buildpacks/jvm/src/bin/heroku_metrics_agent_setup.rs

This file was deleted.

2 changes: 0 additions & 2 deletions buildpacks/jvm/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub(crate) const JAVA_TOOL_OPTIONS_ENV_VAR_DELIMITER: &str = " ";
pub(crate) const JAVA_TOOL_OPTIONS_ENV_VAR_NAME: &str = "JAVA_TOOL_OPTIONS";
pub(crate) const JDK_OVERLAY_DIR_NAME: &str = ".jdk_overlay";
pub(crate) const SKIP_HEROKU_JVM_METRICS_AGENT_INSTALLATION_ENV_VAR_NAME: &str =
"SKIP_HEROKU_JVM_METRICS_AGENT_INSTALLATION";
30 changes: 2 additions & 28 deletions buildpacks/jvm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::openjdk_artifact::HerokuOpenJdkVersionRequirement;
use crate::{OpenJdkArtifactRequirementParseError, OpenJdkBuildpackError, ValidateSha256Error};
use buildpacks_jvm_shared::log::{log_please_try_again, log_please_try_again_error};
use crate::{OpenJdkArtifactRequirementParseError, OpenJdkBuildpackError};
use buildpacks_jvm_shared::log::log_please_try_again_error;
use buildpacks_jvm_shared::system_properties::ReadSystemPropertiesError;
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
Expand All @@ -21,32 +21,6 @@ pub(crate) fn on_error_jvm_buildpack(error: OpenJdkBuildpackError) {
Heroku
"},
),
OpenJdkBuildpackError::MetricsAgentDownloadError(error) => log_please_try_again_error(
"Heroku Metrics Agent download failed",
"Could not download Heroku Metrics Agent.",
error,
),
OpenJdkBuildpackError::MetricsAgentSha256ValidationError(sha_256_error) => {
match sha_256_error {
ValidateSha256Error::CouldNotObtainSha256(error) =>
log_please_try_again_error(
"Heroku Metrics Agent download checksum error",
formatdoc! {"
Heroku Metrics Agent download succeeded, but an error occurred while verifying the
SHA256 checksum of the downloaded file.
"},
error
),
ValidateSha256Error::InvalidChecksum { actual, expected } =>
log_please_try_again(
"Heroku Metrics Agent download checksum error",
formatdoc! {"
Heroku Metrics Agent download succeeded, but the downloaded file's SHA256
checksum {actual} did not match the expected checksum {expected}.
", actual = actual, expected = expected },
)
}
},
OpenJdkBuildpackError::CannotCreateOpenJdkTempDir(error) => log_please_try_again_error(
"Unexpected IO error",
"Could not create temporary directory for the OpenJDK download due to an unexpected I/O error.",
Expand Down
75 changes: 0 additions & 75 deletions buildpacks/jvm/src/layers/heroku_metrics_agent.rs

This file was deleted.

1 change: 0 additions & 1 deletion buildpacks/jvm/src/layers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub(crate) mod heroku_metrics_agent;
pub(crate) mod openjdk;
pub(crate) mod runtime;
37 changes: 3 additions & 34 deletions buildpacks/jvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,26 @@ mod openjdk_artifact;
mod openjdk_version;
mod util;

use crate::constants::SKIP_HEROKU_JVM_METRICS_AGENT_INSTALLATION_ENV_VAR_NAME;
use crate::errors::on_error_jvm_buildpack;
use crate::layers::heroku_metrics_agent::HerokuMetricsAgentLayer;
use crate::layers::openjdk::OpenJdkLayer;
use crate::layers::runtime::RuntimeLayer;
use crate::openjdk_artifact::{
OpenJdkArtifactMetadata, OpenJdkArtifactRequirement, OpenJdkArtifactRequirementParseError,
};
use crate::util::{boolean_buildpack_config_env_var, ValidateSha256Error};
use buildpacks_jvm_shared::system_properties::{read_system_properties, ReadSystemPropertiesError};
pub(crate) use constants::{
JAVA_TOOL_OPTIONS_ENV_VAR_DELIMITER, JAVA_TOOL_OPTIONS_ENV_VAR_NAME, JDK_OVERLAY_DIR_NAME,
};
use inventory::artifact::{Arch, Os};
use inventory::inventory::{Inventory, ParseInventoryError};
use libcnb::build::{BuildContext, BuildResult, BuildResultBuilder};
use libcnb::buildpack_main;
use libcnb::data::build_plan::BuildPlanBuilder;
use libcnb::data::layer_name;
use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder};
use libcnb::generic::GenericPlatform;
use libcnb::generic::{GenericMetadata, GenericPlatform};
use libcnb::Buildpack;
use libcnb::{buildpack_main, Platform};
use libherokubuildpack::download::DownloadError;
use serde::{Deserialize, Serialize};
use std::env::consts;
use url as _; // Used by exec.d binary

Expand All @@ -45,8 +41,6 @@ struct OpenJdkBuildpack;
enum OpenJdkBuildpackError {
UnsupportedOpenJdkVersion(OpenJdkArtifactRequirement),
OpenJdkDownloadError(DownloadError),
MetricsAgentDownloadError(DownloadError),
MetricsAgentSha256ValidationError(ValidateSha256Error),
CannotCreateOpenJdkTempDir(std::io::Error),
CannotOpenOpenJdkTarball(std::io::Error),
CannotDecompressOpenJdkTarball(std::io::Error),
Expand All @@ -61,7 +55,7 @@ enum OpenJdkBuildpackError {

impl Buildpack for OpenJdkBuildpack {
type Platform = GenericPlatform;
type Metadata = OpenJdkBuildpackMetadata;
type Metadata = GenericMetadata;
type Error = OpenJdkBuildpackError;

fn detect(&self, context: DetectContext<Self>) -> libcnb::Result<DetectResult, Self::Error> {
Expand Down Expand Up @@ -137,19 +131,6 @@ impl Buildpack for OpenJdkBuildpack {
},
)?;

libherokubuildpack::log::log_header("Installing Heroku JVM metrics agent");

if boolean_buildpack_config_env_var(
context.platform.env(),
SKIP_HEROKU_JVM_METRICS_AGENT_INSTALLATION_ENV_VAR_NAME,
) {
libherokubuildpack::log::log_info(format!(
"Skipping agent installation, {SKIP_HEROKU_JVM_METRICS_AGENT_INSTALLATION_ENV_VAR_NAME} environment variable is set to a truthy value."
));
} else {
context.handle_layer(layer_name!("heroku_metrics_agent"), HerokuMetricsAgentLayer)?;
}

context.handle_layer(layer_name!("runtime"), RuntimeLayer)?;

BuildResultBuilder::new().build()
Expand All @@ -160,18 +141,6 @@ impl Buildpack for OpenJdkBuildpack {
}
}

#[derive(Deserialize, Debug)]
struct OpenJdkBuildpackMetadata {
#[serde(rename = "heroku-metrics-agent")]
heroku_metrics_agent: HerokuMetricsAgentMetadata,
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
struct HerokuMetricsAgentMetadata {
url: String,
sha256: String,
}

buildpack_main!(OpenJdkBuildpack);

impl From<OpenJdkBuildpackError> for libcnb::Error<OpenJdkBuildpackError> {
Expand Down
Loading

0 comments on commit 13c3f24

Please sign in to comment.