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

Update Terraform to automate host and server setup #13

Open
emilyllim opened this issue Nov 3, 2023 · 5 comments
Open

Update Terraform to automate host and server setup #13

emilyllim opened this issue Nov 3, 2023 · 5 comments
Assignees

Comments

@emilyllim
Copy link
Collaborator

emilyllim commented Nov 3, 2023

Existing Terraform configuration should be updated to automatically install everything the instance needs to be set up as a runner.

Resources

@emilyllim emilyllim self-assigned this Nov 3, 2023
@emilyllim
Copy link
Collaborator Author

Updates added to existing pull request #7

@emilyllim
Copy link
Collaborator Author

emilyllim commented Nov 3, 2023

Updating the Terraform configuration

Before adding the setup commands, I tested the use of the user_data attribute by creating a test script that just echoes some text to a new file. Then I applied the updated Terraform configuration:

  • terraform apply

Then I SSH'ed into the instance. At first I was confused as to why I couldn't find the new file, but it was created at the root directory level, not the user (ubuntu) level.

  • cd /
  • ls - the file should be viewable at this level

@emilyllim
Copy link
Collaborator Author

Add a self-hosted runner

First, I manually followed the instructions in the GitHub documentation to add a self-hosted runner for the cinder_bench_runner repository:

  • Settings -> Actions -> Runners -> New self-hosted runner
  • I selected the operating system and architecture of my EC2 instance (Linux and x64, respectively)
  • The commands intended for OS and architecture chosen are provided by GitHub
  • Ran into an error when running the command to create the runner:
    • ./bin/libcoreclr.so: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.7' not found (required by ./bin/libcoreclr.so) Libicu's dependencies is missing for Dotnet Core 6.0
  • Output tells me to run sudo ./bin/installdependencies.sh
  • But I ran into more errors:
    • E: Some index files failed to download. They have been ignored, or old ones used instead. 'apt-get' failed with exit code '0' Can't install dotnet core dependencies.
  • I tried sudo apt-get update, but continued running into several Failed to fetch errors

@emilyllim
Copy link
Collaborator Author

Troubleshooting "Failed to fetch" errors

  • I tried to set up a runner on another machine and it worked, so this was not an issue on my own network.
  • I tested the network of the EC2 instance by using ping www.google.com:
    • I can see packets arriving in the output, so there isn't an issue with the internet connectivity.
  • Next thing I checked was the /etc/apt/sources.list file.
    • It should have package repositories that match the Ubuntu version I am using (Precise Pangolin).
    • All of them matched, but I realized that the current AMI I am using is very old, so I decided to switch to a newer one.
  • I changed the AMI to one that is running 22.04.3 (Jammy Jellyfish).
  • I tried running sudo apt-get update and now there are no fetching errors!
  • Then I manually ran the commands to set up the runner again.

Check that the runner has been added successfully

  • In the repository, go to Settings -> Actions -> Runners. The runner should be present as "Idle", or "Offline" (if it hasn't been run yet).

Add commands to set up runner in a script

  • I copied the commands I ran manually to the script that will be run by Terraform.
  • There was one change needed to automate this process. For the runner creation command, I added arguments for the runner group, name, labels, and work:
    • --runnergroup "Default" --name "benchrunner2" --labels "self-hosted,Linux,X64" --work "_work"
    • Therefore, the command line won't ask for these values manually.
  • Provisioning the resources through Terraform runs these commands and sets up the runner as in the previous steps.

(Optional) removing the runner

  • In the repository, go to Settings -> Actions -> Runners -> Click the three dots and select "Remove" and follow the instructions.

@emilyllim
Copy link
Collaborator Author

Next step

  • Before adding these changes to the repository, I need to secure the token as a secret and update the script to use this secret instead of hardcoding it.

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

No branches or pull requests

1 participant