-
Notifications
You must be signed in to change notification settings - Fork 18
fix: add clean-data playbook to prevent storage-related deployment failures #81
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
Open
KatyaRyazantseva
wants to merge
7
commits into
blockblaz:main
Choose a base branch
from
KatyaRyazantseva:clean-data-ansible
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−43
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f100371
fix: add clean-data playbook to prevent storage issues
KatyaRyazantseva 82fd7df
Merge branch 'main' into clean-data-ansible
KatyaRyazantseva 8a0129f
fix: use raw module for cleaning
KatyaRyazantseva 734e2a3
Merge remote-tracking branch 'upstream/main' into clean-data-ansible
KatyaRyazantseva 34f9d72
fix: remove cleaning from role level
KatyaRyazantseva acb5bc6
Merge remote-tracking branch 'upstream/main' into clean-data-ansible
KatyaRyazantseva 49c845e
fix: update docs, add grandine
KatyaRyazantseva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| # Clean data playbook: Clean node data directories | ||
|
|
||
| - name: Parse and validate node names | ||
| hosts: localhost | ||
| connection: local | ||
| gather_facts: no | ||
| vars: | ||
| validator_config_file: "{{ genesis_dir }}/validator-config.yaml" | ||
| tags: | ||
| - zeam | ||
| - ream | ||
| - qlean | ||
| - lantern | ||
| - lighthouse | ||
| - grandine | ||
| - deploy | ||
|
|
||
| tasks: | ||
| - name: Validate validator-config.yaml exists | ||
| stat: | ||
| path: "{{ validator_config_file }}" | ||
| register: validator_config_stat | ||
|
|
||
| - name: Fail if validator-config.yaml missing | ||
| fail: | ||
| msg: "validator-config.yaml not found at {{ validator_config_file }}" | ||
| when: not validator_config_stat.stat.exists | ||
|
|
||
| - name: Verify yq is available | ||
| command: yq --version | ||
| register: yq_version | ||
| changed_when: false | ||
| failed_when: false | ||
| ignore_errors: true | ||
|
|
||
| - name: Fail if yq is not available | ||
| fail: | ||
| msg: "yq is required but not installed. Install on macOS: brew install yq, or see https://github.com/mikefarah/yq" | ||
| when: yq_version.rc != 0 | ||
|
|
||
| - name: Extract all node names | ||
| shell: | | ||
| yq eval '.validators[].name' {{ validator_config_file }} | ||
| register: all_node_names_raw | ||
| changed_when: false | ||
|
|
||
| - name: Set all node names | ||
| set_fact: | ||
| all_node_names: "{{ all_node_names_raw.stdout_lines }}" | ||
|
|
||
| - name: Fail if node_names is not specified | ||
| fail: | ||
| msg: "node_names must be specified. Provide one or more node names (comma or space separated)." | ||
| when: node_names is not defined or node_names == "" | ||
|
|
||
| - name: Handle "all" node names - expand to all nodes | ||
| set_fact: | ||
| clean_nodes: "{{ all_node_names }}" | ||
| when: | ||
| - node_names is defined | ||
| - node_names == "all" | ||
|
|
||
| - name: Parse node names if provided as comma-separated string | ||
| set_fact: | ||
| clean_nodes: "{{ node_names.split(',') | map('trim') | list }}" | ||
| when: | ||
| - node_names is defined | ||
| - node_names is string | ||
| - node_names != "all" | ||
| - '("," in node_names)' | ||
|
|
||
| - name: Parse node names if provided as space-separated string | ||
| set_fact: | ||
| clean_nodes: "{{ node_names.split(' ') | map('trim') | select('length') | list }}" | ||
| when: | ||
| - node_names is defined | ||
| - node_names is string | ||
| - node_names != "all" | ||
| - '("," not in node_names)' | ||
| - '(" " in node_names)' | ||
|
|
||
| - name: Handle single node name | ||
| set_fact: | ||
| clean_nodes: "{{ [node_names] }}" | ||
| when: | ||
| - node_names is defined | ||
| - node_names is string | ||
| - node_names != "all" | ||
| - '"," not in node_names' | ||
| - '" " not in node_names' | ||
|
|
||
| - name: Display nodes to clean | ||
| debug: | ||
| msg: "Cleaning data directories for nodes: {{ clean_nodes | join(', ') }}" | ||
|
|
||
| - name: Add nodes to clean_targets group | ||
| add_host: | ||
| name: "{{ item }}" | ||
| groups: clean_targets | ||
| loop: "{{ clean_nodes }}" | ||
|
|
||
| - name: Clean node data directories on remote hosts | ||
| hosts: clean_targets | ||
| gather_facts: no | ||
| vars: | ||
| # Use remote paths on remote hosts | ||
| data_dir: "{{ remote_data_dir | default('/opt/lean-quickstart/data') }}" | ||
| node_name: "{{ inventory_hostname }}" | ||
| tags: | ||
| - zeam | ||
| - ream | ||
| - qlean | ||
| - lantern | ||
| - lighthouse | ||
| - grandine | ||
| - deploy | ||
|
|
||
| tasks: | ||
| - name: Clean node data directory | ||
| raw: rm -rf {{ data_dir }}/{{ node_name }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One issue i found berfore merge
- name: Stop container before cleaning
raw: docker rm -f {{ node_name }} 2>/dev/null || trueOtherwise LGTM |
||
|
|
||
| - name: Display cleaned directory | ||
| debug: | ||
| msg: "Cleaned data directory: {{ data_dir }}/{{ node_name }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nit, but can we please add a check to validate if yq is installed before using it here?