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

feat: add ansible run to the deploy command #3

Merged
merged 11 commits into from Aug 17, 2023

Conversation

jacderida
Copy link
Contributor

@jacderida jacderida commented Aug 5, 2023

  • 8cede34 feat: add ansible run to the deploy command

    Right now this only provisions the genesis node. We need to implement the retrieval of the genesis
    IP and peer ID before we can run against the remaining nodes.

    It uses a very similar pattern to Terraform, with an interface, so that we can do behaviour-based
    unit testing.

  • 7d86f8b tests: reorganise unit tests

    There were over 700 lines of tests and setup code inside a single test module, which was becoming
    unwieldy to work were.

    This splits the setup code into one module, then a module for each function on TestnetDeploy that
    is under test. With the use of modules, the function name was removed from the test case names.

  • 8741d35 refactor: split deploy into smaller functions

    The smaller functions are easier to test and don't require as much mocking setup.

  • f9ff92c feat: run ansible against remaining nodes

    The multiaddr of the genesis node is composed by running ansible-inventory to get its IP address,
    by running the rpc client to get its peer ID.

    After we have that, we can then run against the remaining nodes.

    Those two functions were separated for easier test setup and admin.

  • 81dd653 feat: ssh availability check

    It's possible that before we run Ansible, the SSH service is not yet running on the genesis node.
    This is something we seen happen occasionally, so we added in a little loop to sit and wait for it
    to become available.

    We only check this for the genesis run because the remaining nodes are provisioned after genesis, by
    which point the SSH service should be available.

  • f2fe39e feat: provide --node-count arg for deploy cmd

    This will control how many node processes run on each VM. The default is 20.

  • 18b26be feat: run deploy with custom binary

    If the --branch and --repo-owner arguments are used, the build machine will be spun up to build
    a custom binary, which will then be uploaded to S3. Then when the nodes are being provisioned, this
    binary will be pulled in.

  • ce8129d feat: provide setup command

    This creates the .env file by gathering input from the user, trying to assist them with which
    values should be provided.

    We are leaving it to the user to setup Terraform and Ansible on their OS.

  • 36106c5 docs: provide setup and usage instructions

    This still needs to be extended with some information on how to obtain the IP addresses of each
    VM.

  • 58ce76d feat: provide inventory command

    This will produce a list of all the VMs participating in the testnet, along with the SSH user for
    the cloud provider.

  • a31ee5b chore: respond to feedback

    Addresses two issues that were noted during review:

    • Provide more helpful error message when inventory list is empty
    • Set other environment variables for Digital Ocean based on the DO_PAT variable

    For the first issue, there are a few different ways in which it might be possible for the
    environment to be non-existent. These were documented with comments in the code, which you can see
    in the diff.

Right now this only provisions the genesis node. We need to implement the retrieval of the genesis
IP and peer ID before we can run against the remaining nodes.

It uses a very similar pattern to Terraform, with an interface, so that we can do behaviour-based
unit testing.
There were over 700 lines of tests and setup code inside a single `test` module, which was becoming
unwieldy to work were.

This splits the setup code into one module, then a module for each function on `TestnetDeploy` that
is under test. With the use of modules, the function name was removed from the test case names.
The smaller functions are easier to test and don't require as much mocking setup.
The multiaddr of the genesis node is composed by running `ansible-inventory` to get its IP address,
by running the rpc client to get its peer ID.

After we have that, we can then run against the remaining nodes.

Those two functions were separated for easier test setup and admin.
It's possible that before we run Ansible, the SSH service is not yet running on the genesis node.
This is something we seen happen occasionally, so we added in a little loop to sit and wait for it
to become available.

We only check this for the genesis run because the remaining nodes are provisioned after genesis, by
which point the SSH service should be available.
This will control how many node processes run on each VM. The default is 20.
If the `--branch` and `--repo-owner` arguments are used, the build machine will be spun up to build
a custom binary, which will then be uploaded to S3. Then when the nodes are being provisioned, this
binary will be pulled in.
This creates the `.env` file by gathering input from the user, trying to assist them with which
values should be provided.

We are leaving it to the user to setup Terraform and Ansible on their OS.
This still needs to be extended with some information on how to obtain the IP addresses of each
VM.
This will produce a list of all the VMs participating in the testnet, along with the SSH user for
the cloud provider.
Addresses two issues that were noted during review:

* Provide more helpful error message when inventory list is empty
* Set other environment variables for Digital Ocean based on the `DO_PAT` variable

For the first issue, there are a few different ways in which it might be possible for the
environment to be non-existent. These were documented with comments in the code, which you can see
in the diff.

In addition, license headers were applied where they were missing.
@jacderida jacderida merged commit 03e0722 into maidsafe:main Aug 17, 2023
7 checks passed
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.

None yet

2 participants