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

Port health check implementation from upstream #95

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>us.springett</groupId>
<artifactId>alpine-parent</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -93,7 +93,6 @@
<lib.kafka-junit.version>3.3.0</lib.kafka-junit.version>
<lib.kafka-streams.version>3.4.0</lib.kafka-streams.version>
<lib.lucene.version>8.11.2</lib.lucene.version>
<lib.microprofile-health-api.version>3.1</lib.microprofile-health-api.version>
<lib.packageurl.version>1.4.1</lib.packageurl.version>
<lib.pebble.version>3.2.0</lib.pebble.version>
<lib.protobuf-java.version>3.22.2</lib.protobuf-java.version>
Expand Down Expand Up @@ -156,17 +155,6 @@
<artifactId>alpine-server</artifactId>
<version>${lib.alpine.version}</version>
</dependency>
<!-- DataNucleus -->
<dependency>
<!--
Temporarily forcing a newer version that what Alpine ships with.
We need https://github.com/datanucleus/datanucleus-rdbms/issues/455
for Hyades. Once Alpine has updated, remove this direct dependency.
-->
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>6.0.3</version>
</dependency>
<!-- CVSS Calculator -->
<dependency>
<groupId>us.springett</groupId>
Expand Down Expand Up @@ -220,12 +208,6 @@
<artifactId>json</artifactId>
<version>20230227</version>
</dependency>
<!-- MicroProfile Health -->
<dependency>
<groupId>org.eclipse.microprofile.health</groupId>
<artifactId>microprofile-health-api</artifactId>
<version>${lib.microprofile-health-api.version}</version>
</dependency>
<!-- Package URL -->
<dependency>
<groupId>com.github.package-url</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CMD java ${JAVA_OPTIONS} ${EXTRA_JAVA_OPTIONS} --add-opens java.base/java.util.c
EXPOSE 8080

# Add a healthcheck using the Dependency-Track version API
HEALTHCHECK --interval=5m --timeout=3s CMD wget --no-proxy -q -O /dev/null http://127.0.0.1:8080${CONTEXT}api/version || exit 1
HEALTHCHECK --interval=30s --timeout=3s CMD wget --no-proxy -q -O /dev/null http://127.0.0.1:8080${CONTEXT}health || exit 1

# metadata labels
LABEL \
Expand Down
66 changes: 0 additions & 66 deletions src/main/java/org/dependencytrack/health/DatabaseHealthCheck.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Steve Springett. All Rights Reserved.
*/
package org.dependencytrack.health;

import alpine.common.logging.Logger;
import alpine.server.health.HealthCheckRegistry;
import alpine.server.health.checks.DatabaseHealthCheck;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class HealthCheckInitializer implements ServletContextListener {

private static final Logger LOGGER = Logger.getLogger(HealthCheckInitializer.class);

@Override
public void contextInitialized(final ServletContextEvent event) {
LOGGER.info("Registering health checks");
HealthCheckRegistry.getInstance().register("database", new DatabaseHealthCheck());
HealthCheckRegistry.getInstance().register("kafka-streams", new KafkaStreamsHealthCheck());
}

}

This file was deleted.

This file was deleted.

67 changes: 0 additions & 67 deletions src/main/java/org/dependencytrack/health/HealthCheckServlet.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.dependencytrack.event.kafka.KafkaStreamsInitializer;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;

/**
* A {@link HealthCheck} for Kafka Streams.
Expand All @@ -12,6 +13,7 @@
*
* @see <a href="https://github.com/quarkusio/quarkus/blob/2.16.5.Final/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/health/KafkaStreamsStateHealthCheck.java">Quarkus Kafka Streams Health Check</a>
*/
@Liveness
class KafkaStreamsHealthCheck implements HealthCheck {

@Override
Expand Down

This file was deleted.

Loading