kubeshop / vscode-monokle

An extension for Visual Studio Code to validate your Kubernetes configuration
https://marketplace.visualstudio.com/items?itemName=kubeshop.monokle
MIT License
6 stars 0 forks source link

Improve error handling #61

Closed f1ames closed 9 months ago

f1ames commented 9 months ago

This PR fixes some errors in error handling. I found it when testing other changes and in fact we have 3 fixes here:

  1. For retrying, disposables where not disposed on errors others than activated check and next initialization would failed due to trying to register same commands (as they need to be disposed). I moved disposable logic to onFailedAttempt which is run every after failed attempt.
  2. Also pRetry does not retry after TypeErrors so I rethrow any activation errors as generic ones (and why it is important see next point).
  3. The initial issue was that during extension initialization (when validation is run) there was TypeError: Cannot read properties of undefined (reading 'addSchema'). When retried, it worked fine (that's way previous point). But more interestingly, this issue is a bit puzzling, it was caused by the fact that when validation was run, it tried to load prometheus schema (K8s schema plugin) via ajv but ajv instance was not initialized yet (thus Cannot read properties of undefined (reading 'addSchema') for this.ajv.addSchema... erro) from here https://github.com/kubeshop/monokle-core/blob/f1c616d6dec28f74d9ca6005be1a8fdade4fc2b3/packages/validation/src/validators/kubernetes-schema/validator.ts#L118). My assumption was that it should load automatically on first validation run (should it?), if yes it seems there might be an issue in core somewhere (will report a task there then) 🤔

Changes

Fixes

Checklist