Skip to content

Commit

Permalink
Merge pull request #111 from DataONEorg/develop
Browse files Browse the repository at this point in the history
3.0.1 release
  • Loading branch information
artntek authored Jul 9, 2024
2 parents 1ad4183 + 64253d4 commit dc31999
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 51 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# DataONE Indexer

Also see [RELEASE-NOTES.md](./RELEASE-NOTES.md)

The DataONE Indexer is a system that processes index tasks created by other components. The DataONE
Indexer comprises three main subsystems, each defined by its own helm subsystem chart:

Expand Down
19 changes: 19 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# dataone-indexer Release Notes

## dataone-indexer version 3.0.1 & helm chart version 1.0.1

* Release date: 2024-07-08
* helm chart version 1.0.1
* Change `.Values.idxworker.cn_url` to `.Values.global.d1ClientCnUrl`
* Get `fullname` from metacat chart or provide in values.yaml
* Add simple 'exec' liveness probe. Remove readiness probe
* dataone-indexer version 3.0.1
* Bump rmq amqp client to 5.21.0
* Add healthcheck code
* Exit app if unrecoverable exception occurs when started from `main()` method

## dataone-indexer version 3.0.0 & helm chart version 1.0.0

* Release date: 2024-04-25
* helm chart version 1.0.0 -- first release of helm chart
* dataone-indexer version 3.0.0 -- first release of dataone-indexer
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ RUN apt update && apt -y install \
nano

#Add a user & group with id=1001 and name=d1indexer
RUN groupadd -g 1000 d1indexer && useradd -u 1000 -g 1000 d1indexer
RUN groupadd -g 1000 d1indexer && useradd -u 1000 -g 1000 d1indexer \
&& touch ./livenessprobe

# The most recently built jar file is copied from the maven build directory to this dir by maven, so that
# it can be copied to the image.
Expand All @@ -28,6 +29,7 @@ COPY ./docker/entrypoint.sh .
# Change the ownership of the jar and sh files
RUN chown d1indexer dataone-index-worker-${TAG}-shaded.jar
RUN chown d1indexer entrypoint.sh
RUN chown d1indexer livenessprobe

#Run Container as d1indexer
USER 1000
Expand Down
2 changes: 1 addition & 1 deletion helm/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ dependencies:
repository: https://charts.bitnami.com/bitnami
version: 6.2.3
digest: sha256:8a0c7f616956207f7a5161ec1f5f3b58c432b8c8051ad4ef927dacee81c52be9
generated: "2022-10-26T16:58:14.484158-08:00"
generated: "2024-05-27T16:09:36.080811-07:00"
8 changes: 4 additions & 4 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0
version: 1.0.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "3.0.0"
appVersion: "3.0.1"

# Chart dependencies
dependencies:
- name: rabbitmq # rabbitmq version 3.10.5 is deployed by chart version 10.1.14
- name: rabbitmq
repository: https://charts.bitnami.com/bitnami
version: 10.1.14
version: 10.1.14 # rabbitmq version 3.10.5 is deployed by chart version 10.1.14
condition: rabbitmq.enabled, global.rabbitmq.enabled
- name: solr
repository: https://charts.bitnami.com/bitnami
Expand Down
2 changes: 1 addition & 1 deletion helm/config/dataone-indexer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ index.thread.number={{ .Values.idxworker.pool_size }}

dataone.indexing.performance.logging.enabled=false

D1Client.CN_URL={{ .Values.idxworker.cn_url }}
D1Client.CN_URL={{ .Values.global.d1ClientCnUrl }}

index.resourcemap.namespace=http://www.w3.org/TR/rdf-syntax-grammar;
{{- print "" }}http://www.openarchives.org/ore/terms
Expand Down
27 changes: 24 additions & 3 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ Create the name of the service account to use
{{- end }}
{{- end }}

{{/*
Check to see if '.Values.global "dataone-indexer.enabled' is set to true in the top-level metacat
chart. If so, we know we're running as a subchart, and can infer the 'metacat.fullname'.
If we're not running as a sub-chart, then we need to read the user-provided value from
.Values.idxworker.metacatK8sFullName
*/}}
{{- define "get.metacat.fullname" -}}
{{- if (index .Values.global "dataone-indexer.enabled") }}
{{- if contains "metacat" (lower .Release.Name) }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-metacat" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- else }}
{{- default "MISSING-idxworker.metacatK8sFullName-MISSING" .Values.idxworker.metacatK8sFullName }}
{{- end }}
{{- end }}

{{/*
set MN url
If we're running as a subchart, can use direct access without needing to go through ingress/https;
Expand All @@ -71,20 +89,23 @@ If connecting to an instance outside the cluster, should use https;
{{- define "idxworker.mn.url" -}}
{{- $mn_url := .Values.idxworker.mn_url }}
{{- if not $mn_url }}
{{- $mn_url = printf "http://%s-hl:8080/%s/d1/mn" .Release.Name .Values.global.metacatAppContext }}
{{- $fullname := (include "get.metacat.fullname" .) }}
{{- $mn_url = printf "http://%s-hl:8080/%s/d1/mn" $fullname .Values.global.metacatAppContext }}
{{- end }}
{{- $mn_url }}
{{- end }}
{{/*
set Claim Name of existing PVC to use (typically the volume that is shared with metacat)
Either use the value set in .Values.persistence.claimName, or if blank, autopopulate with
{podname}-metacat-{releaseName}-0 (e.g. metacatbrooke-metacat-metacatbrooke-0)
{podname}-metacat-{fullName}-0 (e.g. metacatbrooke-metacat-metacatbrooke-metacat-0)
(see 'idxworker.fullname' for logic behind how a 'fullname' is defined)
*/}}
{{- define "idxworker.shared.claimName" -}}
{{- $claimName := .Values.persistence.claimName }}
{{- if not $claimName }}
{{- $claimName = printf "%s-metacat-%s-0" .Release.Name .Release.Name }}
{{- $fullname := (include "get.metacat.fullname" .) }}
{{- $claimName = printf "%s-metacat-%s-0" .Release.Name $fullname }}
{{- end }}
{{- $claimName }}
{{- end }}
Expand Down
32 changes: 9 additions & 23 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.affinity "context"
$) | nindent 8 }}
affinity: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
Expand All @@ -52,15 +51,14 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
# livenessProbe:
# httpGet:
# path: /
# port: http
# readinessProbe:
# httpGet:
# path: /
# port: http
# initialDelaySeconds:
livenessProbe:
exec:
command:
- /bin/sh
- -c
- test $(($(date +%s) - $(stat -c %Y /var/lib/dataone-indexer/livenessprobe))) -lt 20
initialDelaySeconds: 20
periodSeconds: 15
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand Down Expand Up @@ -130,18 +128,6 @@ spec:
| grep -c "<schema name=\"dataone") == 1 ]]; do
echo waiting for Solr Schema to be accessible at http://{{ $solrHost }}:
{{- $solrPort }}$URI; sleep 1; done;
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: {{ .Release.Name }}-config-volume
configMap:
Expand Down
20 changes: 16 additions & 4 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

global:
solrPort: &global-solr-port 8983

## @param global.metacatAppContext The application context used by the metacat installation
##
metacatAppContext: metacat

## @param global.storageClass default name of the storageClass to use for PVs
Expand All @@ -21,6 +24,10 @@ global:
##
ephemeralVolumeStorageClass: csi-cephfs-sc-ephemeral

## @param global.d1ClientCnUrl URL of the CN
##
d1ClientCnUrl: "https://cn.dataone.org/cn"


## @section Dataone-Indexer Application-Specific Properties

Expand Down Expand Up @@ -109,15 +116,20 @@ persistence:
idxworker:
debug: "FALSE"

## @param idxworker.metacatK8sFullName ignored if deployed as subchart, else use metacat.fullname
## If deployed as a subchart, metacatK8sFullName will be ignored, and metacat.fullname will be
## retrieved automatically from the top-level metacat chart. If this not a subchart, set
## metacatK8sFullName to reflect the k8s "fullname" of the metacat installation being indexed.
## Note there is some tricky logic involved in deciding what the fullname should be - see
## "idxworker.fullname" in templates/_helpers.tpl, as an example.
##
metacatK8sFullName: ""

## @param idxworker.mn_url URL of the metacat instance that depends upon this indexer
## Leave this value unset (mn_url: "") to have it automatically populated
##
mn_url: ""

## @param idxworker.cn_url URL of the CN
##
cn_url: "https://cn.dataone.org/cn"

## @param idxworker.solrHostname hostname of the solr service to use
## Leave unset (solrHostname: "") to automatically populate when using solr bitnami subchart
##
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dataone</groupId>
<artifactId>dataone-index-worker</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<packaging>jar</packaging>
<name>dataone-index-worker</name>
<url>http://maven.apache.org</url>
Expand Down Expand Up @@ -249,7 +249,7 @@
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.14.2</version>
<version>5.21.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
46 changes: 34 additions & 12 deletions src/main/java/org/dataone/cn/indexer/IndexWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.ScheduledExecutorService;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
Expand Down Expand Up @@ -93,21 +99,23 @@ public class IndexWorker {
private String specifiedThreadNumberStr = null;
private int specifiedThreadNumber = 0;
private ExecutorService executor = null;



/**
* Commandline main for the IndexWorker to be started.
* @param args
* @throws TimeoutException
* @throws IOException
* @throws ServiceFailure
* @param args (not used -- command line args)
*/
public static void main(String[] args) throws IOException, TimeoutException, ServiceFailure {
public static void main(String[] args) {
logger.info("IndexWorker.main - Starting index worker...");
String propertyFile = null;
loadExternalPropertiesFile(propertyFile);
IndexWorker worker = new IndexWorker();
worker.start();
try {
IndexWorker worker = new IndexWorker();
worker.start();
} catch (Exception e) {
logger.fatal("IndexWorker.main() exiting due to fatal error: " + e.getMessage(), e);
System.exit(1);
}
startLivenessProbe();
}

/**
Expand Down Expand Up @@ -224,7 +232,7 @@ public IndexWorker(Boolean initialize) throws IOException, TimeoutException, Ser
OntologyModelService.getInstance();
}
}

/**
* Initialize the RabbitMQ service
* @throws IOException
Expand Down Expand Up @@ -357,7 +365,7 @@ public void run() {
};
boolean autoAck = false;
rabbitMQchannel.basicConsume(INDEX_QUEUE_NAME, autoAck, consumer);
logger.info("IndexWorker.start - Calling basicConsume and waiting for the comming messages");
logger.info("IndexWorker.start - Calling basicConsume and waiting for the coming messages");
}

/**
Expand Down Expand Up @@ -474,6 +482,20 @@ private void indexOjbect(IndexQueueMessageParser parser, long deliveryTag, boole
public void stop() throws IOException, TimeoutException {
rabbitMQchannel.close();
rabbitMQconnection.close();
logger.info("IndexWorker.stop - stop the index queue conection.");
logger.info("IndexWorker.stop - stop the index queue connection.");
}

private static void startLivenessProbe() {
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
Path path = Paths.get("./livenessprobe");
Runnable task = () -> {
try {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis()));
} catch (IOException e) {
logger.error("IndexWorker.startLivenessProbe - failed to update file: " + path, e);
}
};
scheduler.scheduleAtFixedRate(task, 0, 10, TimeUnit.SECONDS);
logger.info("IndexWorker.startLivenessProbe - livenessProbe started");
}
}

0 comments on commit dc31999

Please sign in to comment.