nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
15.99k stars 1.41k forks source link

$JS requests when JetStream is disabled for any reason should provide better info #2556

Open aricart opened 3 years ago

aricart commented 3 years ago

Enhancement Request

Here's an example of a client that connected to a server and because of memory/disk limits is unable to be serviced by JetStream. The only error returned to the client is 503.

> INFO {"server_id":"NA6TWYSDFFU2325DNJOSMEMBECO5GL5FYKUENVDJVLIBV3WGBJN5NR5Q","server_name":"nats-server-a","version":"2.5.1-beta.5","proto":1,"go":"go1.16.5","host":"0.0.0.0","port":4222,"headers":true,"auth_required":true,"max_payload":1048576,"jetstream":true,"client_id":312,"client_ip":"172.22.0.1","nonce":"7n7QATdRAID-waY"} ␍␊
< CONNECT {"no_responders":true,"protocol":1,"verbose":false,"pedantic":false,"jwt":"eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJuYW1lIjoiVSIsInN1YiI6IlVDTUIyTlRBUU9OMk9MVlk3WTJPMzVHVUxPWUJKRU9FTEJORlJQS0RDRU9ZRUNTTkc0R0tOTVpFIiwibmF0cyI6eyJkYXRhIjotMSwicGF5bG9hZCI6LTEsInN1YnMiOi0xLCJ0eXBlIjoidXNlciIsInZlcnNpb24iOjJ9LCJhdWQiOiJOQVRTIiwiaXNzIjoiQUFEMzZUWVg1RExJTDZENEpXSDdZTFlZUldSVVNKWVpTSVQ0SkZFMllJTUNFRllGRVhZNEhXRkgiLCJpYXQiOjE2MzIyNjIyODUsImp0aSI6ImZBR09ZalhGZFZtN09zU3psT2h6RVloRHV4RGQ5ZlZmT0w5aUZlRzRJU3hvTUlKKzR6K0JTMWZGNTlUSHN1dmthU1JzVkRFL2NUWE5FSStOT1A4VnhnPT0ifQ.q6PNztGYXiCeVwqjSlYAbGt3lKO5-0HeDYezMLhao34mVxToS-Nv-iFh8nd0CdkQu5-bRaCxXA4CHuWZC7ahCQ","nkey":"UCMB2NTAQON2OLVY7Y2O35GULOYBJEOELBNFRPKDCEOYECSNG4GKNMZE","sig":"gS0H/mrh8iiKimcnZp88jp7sOAy612aaXklfZLB4LeRtANgesvxZ8IZ6poDTPVsrfN+8Ct85rhCEFVFVGic0CQ==","name":"dashboard_test","lang":"nats.deno","version":"1.0.6","headers":true}␍␊
< PING␍␊
> PONG␍␊
< SUB _dashboard.test.07JGYAD4T3V2XTBQOLQ91S.* 1␍␊PUB $JS.API.INFO _dashboard.test.07JGYAD4T3V2XTBQOLQ91S.07JGYAD4T3V2XTBQOLQ8X8 0␍␊␍␊
> HMSG _dashboard.test.07JGYAD4T3V2XTBQOLQ91S.07JGYAD4T3V2XTBQOLQ8X8 1 16 16␍␊NATS/1.0 503␍␊␍␊␍␊
< PUB $JS.API.INFO _dashboard.test.07JGYAD4T3V2XTBQOLQ91S.07JGYAD4T3V2XTBQOLQ96C 0␍␊␍␊
> HMSG _dashboard.test.07JGYAD4T3V2XTBQOLQ91S.07JGYAD4T3V2XTBQOLQ96C 1 16 16␍␊NATS/1.0 503␍␊␍␊␍␊

Instead, it would be more useful to have the server subscribe to $JS.> for that client and return a helpful message like:

{
  error: {
     code: 503,
     description: "server is not able to allocate storage requirements for the account"
  }
}
aricart commented 3 years ago

Another hint, seems to be if the client account has -1 limits there's different behaviour. Though I saw this, thus mentioning it.