mirror of https://github.com/status-im/consul.git
ui: Gracefully cope with 500 errors from the disco-chain API endpoint (#7291)
When connect is disabled the discovery-chain endpoint returns a 500 error status, which we previoulsy did not gracefully cope with. This commit gracefully copes with any errors from the disco-chain endpoint by supressing the error and hiding the Routing tab from the Service detail page. Acceptance test included
This commit is contained in:
parent
58a3e51721
commit
65dd14daf3
|
@ -24,7 +24,23 @@ export default Route.extend({
|
||||||
return hash({
|
return hash({
|
||||||
chain: ['connect-proxy', 'mesh-gateway'].includes(get(model, 'item.Service.Kind'))
|
chain: ['connect-proxy', 'mesh-gateway'].includes(get(model, 'item.Service.Kind'))
|
||||||
? null
|
? null
|
||||||
: this.chainRepo.findBySlug(params.name, dc, nspace),
|
: this.chainRepo.findBySlug(params.name, dc, nspace).catch(function(e) {
|
||||||
|
const code = get(e, 'errors.firstObject.status');
|
||||||
|
// Currently we are specifically catching a 500, but we return null
|
||||||
|
// by default, so null for all errors.
|
||||||
|
// The extra code here is mainly for documentation purposes
|
||||||
|
// and for if we need to perform different actions based on the error code
|
||||||
|
// in the future
|
||||||
|
switch (code) {
|
||||||
|
case '500':
|
||||||
|
// connect is likely to be disabled
|
||||||
|
// we just return a null to hide the tab
|
||||||
|
// `Connect must be enabled in order to use this endpoint`
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}),
|
||||||
...model,
|
...model,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,37 +1,60 @@
|
||||||
@setupApplicationTest
|
@setupApplicationTest
|
||||||
Feature: dc / services / Show Routing for Serivce
|
Feature: dc / services / Show Routing for Service
|
||||||
Scenario: Given a service, the Routing tab should display
|
Scenario: Given a service, the Routing tab should display
|
||||||
Given 1 datacenter model with the value "dc1"
|
Given 1 datacenter model with the value "dc1"
|
||||||
And 1 node models
|
And 1 node models
|
||||||
And 1 service model from yaml
|
And 1 service model from yaml
|
||||||
---
|
---
|
||||||
- Service:
|
- Service:
|
||||||
Kind: consul
|
Kind: consul
|
||||||
Name: service-0
|
Name: service-0
|
||||||
ID: service-0-with-id
|
ID: service-0-with-id
|
||||||
---
|
---
|
||||||
When I visit the service page for yaml
|
When I visit the service page for yaml
|
||||||
---
|
---
|
||||||
dc: dc1
|
dc: dc1
|
||||||
service: service-0
|
service: service-0
|
||||||
---
|
---
|
||||||
And the title should be "service-0 - Consul"
|
And the title should be "service-0 - Consul"
|
||||||
And I see routing on the tabs
|
And I see routing on the tabs
|
||||||
Scenario: Given a service proxy, the Routing tab should not display
|
Scenario: Given a service proxy, the Routing tab should not display
|
||||||
Given 1 datacenter model with the value "dc1"
|
Given 1 datacenter model with the value "dc1"
|
||||||
And 1 node models
|
And 1 node models
|
||||||
And 1 service model from yaml
|
And 1 service model from yaml
|
||||||
---
|
---
|
||||||
- Service:
|
- Service:
|
||||||
Kind: connect-proxy
|
Kind: connect-proxy
|
||||||
Name: service-0-proxy
|
Name: service-0-proxy
|
||||||
ID: service-0-proxy-with-id
|
ID: service-0-proxy-with-id
|
||||||
---
|
---
|
||||||
When I visit the service page for yaml
|
When I visit the service page for yaml
|
||||||
---
|
---
|
||||||
dc: dc1
|
dc: dc1
|
||||||
service: service-0-proxy
|
service: service-0-proxy
|
||||||
---
|
---
|
||||||
And the title should be "service-0-proxy - Consul"
|
And the title should be "service-0-proxy - Consul"
|
||||||
And I don't see routing on the tabs
|
And I don't see routing on the tabs
|
||||||
|
|
||||||
|
Scenario: Given connect is disabled, the Routing tab should not display or error
|
||||||
|
Given 1 datacenter model with the value "dc1"
|
||||||
|
And 1 node models
|
||||||
|
And 1 service model from yaml
|
||||||
|
---
|
||||||
|
- Service:
|
||||||
|
Kind: consul
|
||||||
|
Name: service-0
|
||||||
|
ID: service-0-with-id
|
||||||
|
---
|
||||||
|
And the url "/v1/discovery-chain/service-0?dc=dc1&ns=@namespace" responds with from yaml
|
||||||
|
---
|
||||||
|
status: 500
|
||||||
|
body: "Connect must be enabled in order to use this endpoint"
|
||||||
|
---
|
||||||
|
When I visit the service page for yaml
|
||||||
|
---
|
||||||
|
dc: dc1
|
||||||
|
service: service-0
|
||||||
|
---
|
||||||
|
And I don't see routing on the tabs
|
||||||
|
And I don't see the "[data-test-error]" element
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue