-
Notifications
You must be signed in to change notification settings - Fork 21
feat: poll testnet status and open infra recovery issues #742
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1379542
ansible: codify dashmon status monitoring access
dashinfraclaw 8a8e864
Merge branch 'pr-741-status-monitoring' into vivek/poll-testnet-status
vivekgsharma 97afc97
feat: poll testnet status and open infra recovery issues
vivekgsharma 4bdd09a
fix: shorten dashmon authorized key ansible line
vivekgsharma 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Poll Testnet Status | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: '0 */2 * * *' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| jobs: | ||
| poll-testnet-status: | ||
| name: Poll testnet status and open recovery issues | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 10 | ||
| concurrency: | ||
| group: poll-testnet-status | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| GH_TOKEN: ${{ secrets.INFRA_ISSUES_TOKEN }} | ||
| TESTNET_RECOVERY_ASSIGNEE: dashinfraclaw | ||
| TESTNET_RECOVERY_ISSUE_REPOSITORY: dashpay/infra | ||
|
|
||
| steps: | ||
| - name: Check out repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Validate cross-repo issue token | ||
| run: | | ||
| if [[ -z "${GH_TOKEN}" ]]; then | ||
| echo "INFRA_ISSUES_TOKEN secret is required to create issues in dashpay/infra" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Poll status API and open recovery issues | ||
| run: node bin/poll-testnet-status.js |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
|
|
||
| status_monitoring_user: dashmon | ||
| status_monitoring_home: "/home/{{ status_monitoring_user }}" | ||
| status_monitoring_forced_command: /usr/local/bin/dashmon-check |
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,10 @@ | ||
| # /etc/sudoers.d/dashmon | ||
| # Allow dashmon user to run read-only monitoring commands only. | ||
| # Both rule sets present on all nodes; unused rules are harmless. | ||
|
|
||
| # HP masternodes: dashmate status as dashmate user | ||
| dashmon ALL=(dashmate) NOPASSWD: /usr/bin/dashmate status | ||
|
|
||
| # Regular masternodes: dash-cli commands as ubuntu user | ||
| dashmon ALL=(ubuntu) NOPASSWD: /usr/local/bin/dash-cli getblockchaininfo | ||
| dashmon ALL=(ubuntu) NOPASSWD: /usr/local/bin/dash-cli masternode status | ||
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 @@ | ||
| ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOZRnc5hqc+WjCLt9PHiVVfFPfkWSlWNscOwSZrUnRAu dashmon-readonly@testnet-dashboard |
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 |
|---|---|---|
| @@ -1,9 +1,50 @@ | ||
| --- | ||
|
|
||
| - name: Create dashmon monitoring user | ||
| ansible.builtin.user: | ||
| name: "{{ status_monitoring_user }}" | ||
| shell: /bin/bash | ||
| password: "!" | ||
| create_home: true | ||
|
|
||
| - name: Create dashmon SSH directory | ||
| ansible.builtin.file: | ||
| path: "{{ status_monitoring_home }}/.ssh" | ||
| state: directory | ||
| owner: "{{ status_monitoring_user }}" | ||
| group: "{{ status_monitoring_user }}" | ||
| mode: "0700" | ||
|
|
||
| - name: Install dashmon authorized key with forced command | ||
| ansible.builtin.copy: | ||
| dest: "{{ status_monitoring_home }}/.ssh/authorized_keys" | ||
| content: >- | ||
| {{ status_monitoring_authorized_key_options | join(',') }} | ||
| {{ lookup('file', role_path + '/files/dashmon-testnet.pub') | trim }} | ||
| owner: "{{ status_monitoring_user }}" | ||
| group: "{{ status_monitoring_user }}" | ||
| mode: "0600" | ||
| vars: | ||
| status_monitoring_authorized_key_options: | ||
| - 'command="{{ status_monitoring_forced_command }}"' | ||
| - no-port-forwarding | ||
| - no-X11-forwarding | ||
| - no-agent-forwarding | ||
| - no-pty | ||
|
|
||
| - name: Copy dashmon-check monitoring script | ||
| ansible.builtin.copy: | ||
| src: dashmon-check.sh | ||
| dest: /usr/local/bin/dashmon-check | ||
| dest: "{{ status_monitoring_forced_command }}" | ||
| mode: "0755" | ||
| owner: root | ||
| group: root | ||
|
|
||
| - name: Install dashmon sudoers rules | ||
| ansible.builtin.copy: | ||
| src: dashmon-sudoers | ||
| dest: /etc/sudoers.d/dashmon | ||
| mode: "0440" | ||
| owner: root | ||
| group: root | ||
| validate: /usr/sbin/visudo -cf %s |
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,32 @@ | ||
| /* eslint-disable no-console */ | ||
|
|
||
| const { | ||
| pollTestnetStatus, | ||
| } = require('../lib/testnetStatus/pollTestnetStatus'); | ||
|
|
||
| async function main() { | ||
| const result = await pollTestnetStatus(); | ||
|
|
||
| console.log(`Checked ${result.expectedNodeCount} expected testnet masternodes.`); | ||
| console.log(`Detected ${result.incidentCount} active incidents.`); | ||
|
|
||
| for (const incident of result.skippedIncidents) { | ||
| console.log(`Skipped existing issue for ${incident.nodeName} (${incident.observedState}).`); | ||
| } | ||
|
|
||
| for (const createdIssue of result.createdIssues) { | ||
| if (createdIssue.dryRun) { | ||
| console.log(`Would create issue for ${createdIssue.nodeName} (${createdIssue.observedState}).`); | ||
| } else { | ||
| console.log( | ||
| `Created recovery issue for ${createdIssue.nodeName} ` | ||
| + `(${createdIssue.observedState}): ${createdIssue.issueUrl}`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| main().catch((error) => { | ||
| console.error(error.message); | ||
| process.exit(1); | ||
| }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,102 @@ | ||
| { | ||
| description = "FHS development environment for dash-network-deploy"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
| }; | ||
|
|
||
| outputs = { self, nixpkgs }: | ||
| let | ||
| system = "x86_64-linux"; | ||
| pkgs = nixpkgs.legacyPackages.${system}; | ||
|
|
||
| fhsEnv = pkgs.buildFHSEnv { | ||
| name = "dash-network-deploy-env"; | ||
| targetPkgs = pkgs: with pkgs; [ | ||
| # Node.js | ||
| nodejs_22 | ||
| corepack_22 | ||
|
|
||
| # Infrastructure | ||
| terraform | ||
| ansible | ||
| docker-client | ||
|
|
||
| # Python 3 (Ansible interpreter at /usr/bin/python3) | ||
| python3 | ||
|
|
||
| # AWS | ||
| awscli2 | ||
|
|
||
| # Network / VPN | ||
| openssh | ||
| openvpn | ||
| curl | ||
| wget | ||
|
|
||
| # Utilities | ||
| git | ||
| jq | ||
| bash | ||
| coreutils | ||
| gnugrep | ||
| gnused | ||
| gawk | ||
| findutils | ||
| gnutar | ||
| gzip | ||
| which | ||
|
|
||
| # Libraries for native node modules | ||
| stdenv.cc.cc.lib | ||
| openssl | ||
| zlib | ||
| cacert | ||
| ]; | ||
| profile = '' | ||
| # Ensure Python 3 is at /usr/bin/python3 for Ansible | ||
| if [ ! -e /usr/bin/python3 ]; then | ||
| mkdir -p /usr/bin 2>/dev/null || true | ||
| ln -sf "$(command -v python3)" /usr/bin/python3 2>/dev/null || true | ||
| fi | ||
|
|
||
| # SSL certs | ||
| export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" | ||
| export NIX_SSL_CERT_FILE="$SSL_CERT_FILE" | ||
|
|
||
| # Pass through SSH agent | ||
| export SSH_AUTH_SOCK="''${SSH_AUTH_SOCK:-}" | ||
|
|
||
| # Docker socket | ||
| export DOCKER_HOST="unix:///var/run/docker.sock" | ||
| ''; | ||
| runScript = pkgs.writeShellScript "dash-network-deploy-run" '' | ||
| cd "$HOME/code/dash-network-deploy" || exit 1 | ||
| if [ $# -eq 0 ]; then | ||
| echo "Entered dash-network-deploy FHS environment" | ||
| echo "Working directory: $(pwd)" | ||
| exec bash | ||
| else | ||
| exec "$@" | ||
| fi | ||
| ''; | ||
| }; | ||
| in | ||
| { | ||
| packages.${system}.default = fhsEnv; | ||
|
|
||
| # `nix develop` drops you into the FHS env | ||
| devShells.${system}.default = pkgs.mkShell { | ||
| buildInputs = [ fhsEnv ]; | ||
| shellHook = '' | ||
| echo "Run 'dash-network-deploy-env' to enter the FHS environment" | ||
| ''; | ||
| }; | ||
|
|
||
| # `nix run` launches the FHS env directly | ||
| apps.${system}.default = { | ||
| type = "app"; | ||
| program = "${fhsEnv}/bin/dash-network-deploy-env"; | ||
| }; | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Hardcoded sudoers username breaks
status_monitoring_useroverrides.Line 6, Line 9, and Line 10 pin permissions to
dashmon, but provisioning uses{{ status_monitoring_user }}. If that variable is overridden, the actual monitoring account won’t have required sudo access.🔧 Proposed fix (template sudoers with role variable)
🤖 Prompt for AI Agents