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

Tes 290 include helpers scripts #20

Closed
wants to merge 9 commits into from

Conversation

cristiantolev
Copy link

@cristiantolev cristiantolev commented Oct 24, 2023

Description

The steps of creating a volume, attaching the instance to route 53, and creating a cron job for backup are moved into sub-scripts in order to simplify the main start_graphdb.sh script. Also, there is a fix related to the issue: IO volumes cannot be created due to the default value for throughput.

Related Issues

https://ontotext.atlassian.net/browse/TES-290
https://ontotext.atlassian.net/browse/TES-212
https://ontotext.atlassian.net/browse/TES-270

Changes

Added three new files: create_backup.sh, ebs_volume.sh, and register_route53.
Added an IF statement to check the volume type.

Screenshots (if applicable)

Checklist

  • I have tested these changes thoroughly.
  • My code follows the project's coding style.
  • I have added appropriate comments to my code, especially in complex areas.
  • All new and existing tests passed locally.

@viktor-ribchev
Copy link
Contributor

Weren't those scripts meant to be baked in the AMI?

moved files

Edited comments

edited start graphdb

edited ebs_volume.sh

Fix variables and IF statement
@cristiantolev cristiantolev force-pushed the TES-290-Include-helpers-scripts branch from 7cac120 to 59a7ad1 Compare October 30, 2023 08:58
@cristiantolev cristiantolev marked this pull request as ready for review October 30, 2023 11:15
@yaskoo
Copy link
Contributor

yaskoo commented Oct 31, 2023

Weren't those scripts meant to be baked in the AMI?

yes, they should be. @cristiantolev there's another PR in the packer repository containing these scripts Ontotext-AD/packer-aws-graphdb#11 - are they the same?

This repository should contain only the user data script (start_graphdb.sh). Let's remove the other and update (if needed) the scripts in the packer PR.

@cristiantolev
Copy link
Author

Weren't those scripts meant to be baked in the AMI?

yes, they should be. @cristiantolev there's another PR in the packer repository containing these scripts Ontotext-AD/packer-aws-graphdb#11 - are they the same?

This repository should contain only the user data script (start_graphdb.sh). Let's remove the other and update (if needed) the scripts in the packer PR.

Yes, those scripts exist in the packer-aws-graphdb repo, and they are the same as those here. I will remove them from this repo.

@yaskoo yaskoo removed the request for review from karagyozovd November 24, 2023 14:18

# Register the instance in Route 53, using the volume id for the sub-domain
source /opt/helper-scripts/register_route53.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of sourcing these scripts we should pass arguments to them, see the packer PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

chown -R graphdb:graphdb $disk_mount_point
# Search for an available EBS volume to attach to the instance. If no volume is found - create new one, attach, format and mount the volume.
#source /opt/helper-scripts/ebs_volume.sh
./opt/helper-scripts/ebs_volume.sh --name ${nam e} --ebs_volume_type ${ebs_volume_type} --ebs_volume_throughput ${ebs_volume_throughput} --ebs_kms_key_arn ${ebs_kms_key_arn} --ebs_volume_size ${ebs_volume_size} --ebs_volume_iops ${ebs_volume_iops} --device_name ${device_name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${nam e} > ${name}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -16,126 +16,41 @@ instance_id=$( curl -Ss -H "X-aws-ec2-metadata-token: $imds_token" 169.254.169.2
availability_zone=$( curl -Ss -H "X-aws-ec2-metadata-token: $imds_token" 169.254.169.254/latest/meta-data/placement/availability-zone )
volume_id=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think volume_id="" is used anywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

chown -R graphdb:graphdb $disk_mount_point
# Search for an available EBS volume to attach to the instance. If no volume is found - create new one, attach, format and mount the volume.
#source /opt/helper-scripts/ebs_volume.sh
./opt/helper-scripts/ebs_volume.sh --name ${nam e} --ebs_volume_type ${ebs_volume_type} --ebs_volume_throughput ${ebs_volume_throughput} --ebs_kms_key_arn ${ebs_kms_key_arn} --ebs_volume_size ${ebs_volume_size} --ebs_volume_iops ${ebs_volume_iops} --device_name ${device_name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make each property go on a new line e.g.,

./opt/helper-scripts/ebs_volume.sh --name ${name} \
--ebs_volume_type ${ebs_volume_type} \
....... \
....... \
.......

Would be easier to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

subdomain="$( echo -n "$volume_id" | sed 's/^vol-//' )"
node_dns="$subdomain.${zone_dns_name}"
# Register the instance in Route 53, using the volume id for the sub-domain. Capturing the node_dns variable to be used in the rest of the script.
node_dns=$(./opt/helper-scripts/register_route53.sh \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end of this script there's this:

echo "Instance registered in Route 53 with DNS name:"
echo "$node_dns"

so, you'll have a lot more than just the DNS name.
Since, you have the zone name and the volume id, you can construct the FQDN. Otherwise, the script should echo just the FQDN.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@yaskoo
Copy link
Contributor

yaskoo commented Mar 6, 2024

user data script will broken down to individual parts - this will not be needed for now.

@yaskoo yaskoo closed this Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants