Skip to content

fix(dashmate): status command fails with errors - #1059

Merged
shumkov merged 31 commits into
masterfrom
feat/dashmate-status-no-error
May 15, 2023
Merged

shumkov merged 31 commits into
masterfrom
feat/dashmate-status-no-error

Conversation

@pshenmic

@pshenmic pshenmic commented May 10, 2023 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

dashmate status command issue requests to different services and have a lot of places where error can be possibly thrown, but it must not crash or return error to user. Instead, the field should be nulled or hide from the end user. Add tests emulating error case scenarios.

What was done?

  • Refactored status scopes (added plenty of try catch handlers)
  • Refactored tests and added new test cases

How Has This Been Tested?

Locally + devnet

Breaking Changes

No

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@pshenmic
pshenmic requested review from antouhou and shumkov as code owners May 10, 2023 05:32
@pshenmic
pshenmic marked this pull request as draft May 10, 2023 05:32
@shumkov
shumkov changed the base branch from v0.24-dev to master May 10, 2023 07:02
@shumkov shumkov added this to the v0.24.x milestone May 10, 2023
@shumkov shumkov changed the title feat(dashmate): hide errors for status command fix(dashmate): status command fails with errors May 11, 2023
@pshenmic

Copy link
Copy Markdown
Contributor Author

I've been testing this one locally against local setup and in the devnet. I am not sure yet about logging the errors, so I just put console.error everywhere

Test results

Locally, I set up fresh dashmate local network, and used dashmate --config=local_1 to test the command. It shows the errors on each request and then return the final output. If PLAIN format is chosen, it will hide unavailable fields from the user, if JSON format is chosen, then corresponding fields will be set to null.

On the devnet, I picked up one HPMN, and logged into it. Then I made a reset, forcing L2 into unavailable state.
Then I tried to check status with master branch, and ECONNREFUSED error appeared, crashing the command:

dashmate@hp-masternode-8:~/platform$ yarn dashmate status
    DockerComposeError: Docker Compose error: Error: connect ECONNREFUSED 127.0.0.1:26658
        at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
      errno: -111,
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '127.0.0.1',
      port: 26658
    }

Then I switched to the PR branch, and executed the same command, now it works well:

dashmate@hp-masternode-8:~/platform$ git checkout feat/dashmate-status-no-error
Branch 'feat/dashmate-status-no-error' set up to track remote branch 'feat/dashmate-status-no-error' from 'origin'.
Switched to a new branch 'feat/dashmate-status-no-error'
dashmate@hp-masternode-8:~/platform$ yarn dashmate status
FetchError: request to http://127.0.0.1:36657/status failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (/home/dashmate/platform/.yarn/__virtual__/node-fetch-virtual-a3f0ba2944/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:513:28)
    at Socket.socketErrorListener (node:_http_client:494:9)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}
DockerComposeError: Docker Compose error: Error: connect ECONNREFUSED 127.0.0.1:26658
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 26658
}

    at DockerCompose.execCommand (/home/dashmate/platform/packages/dashmate/src/docker/DockerCompose.js:226:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getDriveInfo (/home/dashmate/platform/packages/dashmate/src/status/scopes/platform.js:112:29) {
  dockerComposeExecutionResult: {
    exitCode: 1,
    err: 'Error: connect ECONNREFUSED 127.0.0.1:26658\n' +
      '    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {\n' +
      '  errno: -111,\n' +
      "  code: 'ECONNREFUSED',\n" +
      "  syscall: 'connect',\n" +
      "  address: '127.0.0.1',\n" +
      '  port: 26658\n' +
      '}\n',
    out: ''
  }
}
╔════════════════════════╤══════════════════════════════════════════════════════════════════╗
║ Network                │ devnet                                                           ║
║ Core Version           │ 19.0.0                                                           ║
║ Core Status            │ running                                                          ║
║ Core Service Status    │ up                                                               ║
║ Core Size              │ 0.01 GB                                                          ║
║ Core Height            │ 4574                                                             ║
║ Masternode Enabled     │ true                                                             ║
║ Masternode State       │ READY                                                            ║
║ Masternode ProTX       │ 51692defaa5ce20c9a23de9f33663fbb7da32cb4bfeb899cf46427589c95be68 ║
║ PoSe Penalty           │ 0                                                                ║
║ Last paid block        │ 4571                                                             ║
║ Last paid time         │ 7.88 minutes                                                     ║
║ Payment queue position │ 0.8125                                                           ║
║ Next payment time      │ 2.13 minutes                                                     ║
║ Sentinel Version       │ 1.7.3                                                            ║
║ Sentinel Status        │ ok                                                               ║
║ Platform Enabled       │ true                                                             ║
║ Platform Status        │ error                                                            ║
╚════════════════════════╧══════════════════════════════════════════════════════════════════╝

dashmate@hp-masternode-8:~/platform$ yarn dashmate status --format=json
FetchError: request to http://127.0.0.1:36657/status failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (/home/dashmate/platform/.yarn/__virtual__/node-fetch-virtual-a3f0ba2944/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:513:28)
    at Socket.socketErrorListener (node:_http_client:494:9)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}
DockerComposeError: Docker Compose error: Error: connect ECONNREFUSED 127.0.0.1:26658
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 26658
}

    at DockerCompose.execCommand (/home/dashmate/platform/packages/dashmate/src/docker/DockerCompose.js:226:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getDriveInfo (/home/dashmate/platform/packages/dashmate/src/status/scopes/platform.js:112:29) {
  dockerComposeExecutionResult: {
    exitCode: 1,
    err: 'Error: connect ECONNREFUSED 127.0.0.1:26658\n' +
      '    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {\n' +
      '  errno: -111,\n' +
      "  code: 'ECONNREFUSED',\n" +
      "  syscall: 'connect',\n" +
      "  address: '127.0.0.1',\n" +
      '  port: 26658\n' +
      '}\n',
    out: ''
  }
}
{"network":"devnet","core":{"network":"devnet","version":"19.0.0","dockerStatus":"running","serviceStatus":"up","verificationProgress":0.999956936548659,"blockHeight":4575,"sizeOnDisk":5623840},"platform":{"enabled":true,"tenderdash":{"dockerStatus":"running","serviceStatus":"error","version":null,"listening":null,"catchingUp":null,"latestBlockHash":null,"latestBlockHeight":null,"latestBlockTime":null,"latestAppHash":null,"peers":null,"moniker":null,"network":null,"httpPortState":"OPEN","p2pPortState":"CLOSED"}},"masternode":{"enabled":true,"proTxHash":"51692defaa5ce20c9a23de9f33663fbb7da32cb4bfeb899cf46427589c95be68","nodeState":{"dmnState":{"service":"3.76.36.64:20001","registeredHeight":4071,"lastPaidHeight":4571,"consecutivePayments":0,"PoSePenalty":0,"PoSeRevivedHeight":-1,"PoSeBanHeight":-1,"revocationReason":0,"ownerAddress":"yZ8FWtBppDXJbUDhRm79crdRGYdPJ2cEdU","votingAddress":"yZ8FWtBppDXJbUDhRm79crdRGYdPJ2cEdU","platformNodeID":"54bb2379302a42af8b3b2829764a9dc2365e3d93","platformP2PPort":36656,"platformHTTPPort":1443,"payoutAddress":"yaaZCJjiw6Zrm22xVDqVXTBT7PKnY4cxHu","pubKeyOperator":"a019b7898206c88f5e75bd62054a286391a5e8f83aefe7e7925f316a58107c68937c52cd35b6d64007bd4d4231e83939"},"poSePenalty":0,"lastPaidHeight":4571,"lastPaidTime":"10.50 minutes","paymentQueuePosition":0.75,"nextPaymentTime":"1.97 minutes"},"state":"READY","sentinel":{"state":"ok","version":"1.7.3"}}}

@pshenmic
pshenmic marked this pull request as ready for review May 12, 2023 07:50

@shumkov shumkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shumkov shumkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shumkov
shumkov merged commit 3af57c3 into master May 15, 2023
@shumkov
shumkov deleted the feat/dashmate-status-no-error branch May 15, 2023 16:38
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.

3 participants