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

Fixed issues with backup and monitoring #57

Merged
2 commits merged into from
Jul 11, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# GraphDB AWS Terraform Module Changelog

# 1.2.2

* Fixed issues with variables in the backup user data script
* Added ability to choose http port for Route53 availability check
* Added ability to specify custom FQDN for the Route53 availability URL

# 1.2.1

* Fixed issue where the backup script was not configured
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Before you begin using this Terraform module, ensure you meet the following prer
| monitoring\_endpoint\_auto\_confirms | Enable or disable endpoint auto confirm subscription to the sns topic | `bool` | `false` | no |
| monitoring\_log\_group\_retention\_in\_days | Log group retention in days | `number` | `30` | no |
| monitoring\_route53\_health\_check\_aws\_region | Define the region in which you want the monitoring to be deployed. It is used to define where the Route53 Availability Check will be deployed, since if it is not specified it will deploy the check in us-east-1 and if you deploy in different region it will not find the dimensions. | `string` | `"us-east-1"` | no |
| monitoring\_route53\_healtcheck\_fqdn\_url | Define custom domain name for the Route53 Health check | `string` | `""` | no |
| graphdb\_properties\_path | Path to a local file containing GraphDB properties (graphdb.properties) that would be appended to the default in the VM. | `string` | `null` | no |
| graphdb\_java\_options | GraphDB options to pass to GraphDB with GRAPHDB\_JAVA\_OPTS environment variable. | `string` | `null` | no |
| deploy\_logging\_module | Enable or disable logging module | `bool` | `false` | no |
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ locals {
var.sns_default_kms_key)) :
var.sns_default_kms_key
)
route53_availability_request_url = var.monitoring_route53_healtcheck_fqdn_url != "" ? var.monitoring_route53_healtcheck_fqdn_url: module.load_balancer.lb_dns_name
route53_availability_port = var.lb_tls_certificate_arn != "" ? 443 : 80
}

locals {
Expand Down Expand Up @@ -221,12 +223,12 @@ module "monitoring" {
cmk_key_alias = var.sns_cmk_key_alias
parameter_store_kms_key_arn = local.calculated_parameter_store_kms_key_arn
cloudwatch_log_group_retention_in_days = var.monitoring_log_group_retention_in_days
route53_availability_request_url = module.load_balancer.lb_dns_name
route53_availability_request_url = local.route53_availability_request_url
route53_availability_measure_latency = var.monitoring_route53_measure_latency
sns_kms_key_arn = local.calculated_sns_kms_key_arn
graphdb_node_count = var.graphdb_node_count
route53_availability_http_string_type = local.calculated_http_string_type

route53_availability_port = local.route53_availability_port
}

module "graphdb" {
Expand Down
14 changes: 8 additions & 6 deletions modules/graphdb/templates/05_gdb_backup_conf.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ NODE_STATE="\$(curl --silent -u "admin:\$GRAPHDB_ADMIN_PASSWORD" http://localhos

function trigger_backup {
local backup_name="\$(date +'%Y-%m-%d_%H-%M-%S').tar"
current_time=$(date +"%T %Y-%m-%d")
start_time=$(date +%s)
current_time=\$(date +"%T %Y-%m-%d")
start_time=\$(date +%s)
echo "Creating backup \$backup_name at \$start_time"

curl \
Expand Down Expand Up @@ -62,17 +62,19 @@ IS_CLUSTER=\$(
curl -s -o /dev/null \
-u "admin:\$GRAPHDB_ADMIN_PASSWORD" \
-w "%%{http_code}" \
http://localhost:7200/rest/monitor/cluster
http://localhost:7201/rest/monitor/cluster
)

if [ "\$IS_CLUSTER" == 200 ]; then
if [ "\$IS_CLUSTER" -eq 200 ]; then
echo "GraphDB is running in a cluster."
# Checks if the current GraphDB instance is Leader, otherwise exits.
if [ "\$NODE_STATE" != "LEADER" ]; then
echo "current node is not a leader, but \$NODE_STATE"
echo "Current node is not a leader, but \$NODE_STATE"
exit 0
fi
(trigger_backup && echo "") | tee -a /var/opt/graphdb/node/graphdb_backup.log
elif [ "\$IS_CLUSTER" == 503 ]; then
elif [ "\$IS_CLUSTER" -ne 200 ]; then
echo "GraphDB is not running in a cluster."
(trigger_backup && echo "") | tee -a /var/opt/graphdb/node/graphdb_backup.log
fi

Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ variable "monitoring_route53_health_check_aws_region" {
default = "us-east-1"
}

variable "monitoring_route53_healtcheck_fqdn_url" {
description = "Define custom domain name for the Route53 Health check"
type = string
default = ""
}

# GraphDB overrides

variable "graphdb_properties_path" {
Expand Down Expand Up @@ -740,3 +746,4 @@ variable "sns_rotation_enabled" {
type = bool
default = true
}