09 30 feat sparkles adds avalanche service#121
Conversation
|
The following installer script has some gems of things we should also implement or check during this installation. https://raw.githubusercontent.com/ava-labs/avalanche-docs/master/scripts/avalanchego-installer.sh |
| @@ -0,0 +1,7 @@ | |||
| # defaults/main.yml | |||
|
|
|||
| avalanche_metrics_port: 33006 | |||
There was a problem hiding this comment.
With the newest code update I did, I moved this to the depin.core.metrics role to ensure that we have a centralized location allowing code review and adding new services to be easier.
bedrock/depin/core/roles/metrics/defaults/main.yml
Lines 6 to 10 in a1f63bf
| avalanche_cmd: "{{ depin_cmd | default('install') }}" | ||
|
|
||
| avalanche_version: "1.10.0" | ||
| avalanche_download_url: "https://github.com/ava-labs/avalanchego/releases/download/v{{ avalanche_version }}/avalanchego-linux-amd64-v{{ avalanche_version }}.tar.gz" |
There was a problem hiding this comment.
With the addition of the depin.core.installer role - this was modified to a list and the name changed to avalanche_download_urls. Wanted to make sure that we didn't need to update how we installed services in more than one location.
There was a problem hiding this comment.
Checked. Probably should involve qa engineer to test it from scratch.
| - name: Create program folder | ||
| become: true | ||
| ansible.builtin.file: | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: '0755' | ||
| dest: /opt/avalanche/{{ avalanche_version }} | ||
|
|
||
| - name: Verify that the program folder was created | ||
| ansible.builtin.stat: | ||
| path: /opt/avalanche/{{ avalanche_version }} | ||
| register: avalanche_program_folder | ||
|
|
||
| - name: Assert that the program folder exists | ||
| ansible.builtin.assert: | ||
| that: | ||
| - avalanche_program_folder.stat.exists | ||
| - avalanche_program_folder.stat.isdir | ||
|
|
||
| - name: Download AvalancheGo | ||
| become: true | ||
| ansible.builtin.get_url: | ||
| url: "{{ avalanche_download_url }}" | ||
| dest: /tmp/avalanchego.tar.gz | ||
| mode: '0644' | ||
|
|
||
| - name: Extract AvalancheGo | ||
| become: true | ||
| ansible.builtin.unarchive: | ||
| src: /tmp/avalanchego.tar.gz | ||
| dest: /opt/avalanche/{{ avalanche_version }} | ||
| remote_src: yes | ||
| extra_opts: | ||
| - --strip-components=1 | ||
|
|
||
| - name: Ensure avalanchego binary is executable | ||
| become: true | ||
| ansible.builtin.file: | ||
| path: /opt/avalanche/{{ avalanche_version }}/avalanchego | ||
| mode: '0755' | ||
|
|
||
| - name: Verify that the AvalancheGo binary exists | ||
| ansible.builtin.stat: | ||
| path: /opt/avalanche/{{ avalanche_version }}/avalanchego | ||
| register: avalanchego_binary | ||
|
|
||
| - name: Assert that the AvalancheGo binary exists | ||
| ansible.builtin.assert: | ||
| that: | ||
| - avalanchego_binary.stat.exists | ||
| - avalanchego_binary.stat.mode | int == 755 | ||
|
|
||
| - name: Symlink avalanchego binary | ||
| become: true | ||
| ansible.builtin.file: | ||
| src: /opt/avalanche/{{ avalanche_version }}/avalanchego | ||
| dest: /usr/local/bin/avalanchego | ||
| state: link | ||
| force: true |
There was a problem hiding this comment.
This could be replaced with depin.core.installer. I'm also down to add those asserts to the new role as well if it makes sense. One concern of having too many asserts though is the time it takes to perform and if it hangs/crashes is that the way it should react.
Also should there be asserts that happen during tests or everytime it runs?
There was a problem hiding this comment.
This was implemented for Xai, however we would like to hear your comments on that before we apply the same logic across other PRs with related comments.
Waiting approve on xai with those changes
There was a problem hiding this comment.
This is removed with the addition of depin.core.metrics
There was a problem hiding this comment.
This is removed with the addition of depin.core.metrics
| import socket | ||
| import time | ||
| import os | ||
| import time |
There was a problem hiding this comment.
Should remove the duplicate import os and import time
| {% endif %} | ||
|
|
||
| hostname = socket.gethostname() | ||
| service = '{{ _name }}' |
There was a problem hiding this comment.
Instead of relying on ansible templating here, I opted to us Path.stem based on the file name.
| REGISTRY.unregister(PROCESS_COLLECTOR) | ||
| REGISTRY.register(MetricsCollector()) | ||
| role_name='role_name' | ||
| start_http_server({{ vars[role_name + '_metrics_port'] | int }}) |
There was a problem hiding this comment.
This was updated with the depin.core.metrics change
There was a problem hiding this comment.
This was implemented for Xai, however we would like to hear your comments on that before we apply the same logic across other PRs with related comments.
Waiting approve on xai with those changes
There was a problem hiding this comment.
If this empty we can remove it
There was a problem hiding this comment.
This can be removed since the default molecule scenario is meant for services while the libs scenario is meant for depin.libs.roles
| - name: Start Avalanche node | ||
| ansible.builtin.include_tasks: | ||
| file: commands/start.yml | ||
|
|
There was a problem hiding this comment.
The relative path in include_tasks needs to be adjusted to ../metrics.yml since the task is being included from within the commands/ subdirectory. The current path tasks/metrics.yml will fail to locate the metrics file.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
|
|
||
| [Service] | ||
| Type=simple | ||
| User=nerdnode |
There was a problem hiding this comment.
The User directive is hardcoded to nerdnode but should use {{ avalanche_user }} to maintain consistency with the role's parameterization pattern. This allows the service to run under the same user as configured in the role's defaults.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
0f56e67 to
8f5689c
Compare
No description provided.