Merge pull request #14970 from hashicorp/ui/feature/filter-synthetic-nodes

ui: Filter synthetic nodes on nodes list page
This commit is contained in:
Tyler Wendlandt 2022-10-13 09:12:03 -06:00 committed by GitHub
commit a6b9219808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 236 additions and 125 deletions

3
.changelog/14970.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:feature
ui: Filter agentless (synthetic) nodes from the nodes list page.
```

View File

@ -1,131 +1,121 @@
<Route
@name={{routeName}}
as |route|>
<Route @name={{routeName}} as |route|>
<DataSource @src={{
uri '/${partition}/${nspace}/${dc}/leader'
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
)
}} as |leader|>
<DataSource
@src={{uri
'/${partition}/${nspace}/${dc}/leader'
(hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
}}
as |leader|
>
<DataLoader
@src={{uri '/${partition}/${nspace}/${dc}/nodes'
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
)
@src={{uri
'/${partition}/${nspace}/${dc}/nodes'
(hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
}}
as |api|>
as |api|
>
<BlockSlot @name="error">
<AppError
@error={{api.error}}
@login={{route.model.app.login.open}}
/>
</BlockSlot>
<BlockSlot @name="loaded">
{{#let
(hash
value=(or sortBy "Status:asc")
change=(action (mut sortBy) value="target.selected")
)
(hash
status=(hash
value=(if status (split status ',') undefined)
change=(action (mut status) value="target.selectedItems")
)
searchproperty=(hash
value=(if (not-eq searchproperty undefined)
(split searchproperty ',')
this._searchProperties
)
change=(action (mut searchproperty) value="target.selectedItems")
default=this._searchProperties
)
)
api.data
leader.data
as |sort filters items leader|}}
<AppView>
<BlockSlot @name="header">
<h1>
<route.Title @title="Nodes" /> <em>{{format-number items.length}} total</em>
</h1>
<label for="toolbar-toggle"></label>
<BlockSlot @name='error'>
<AppError @error={{api.error}} @login={{route.model.app.login.open}} />
</BlockSlot>
<BlockSlot @name="toolbar">
{{#if (gt items.length 0) }}
<Consul::Node::SearchBar
@search={{search}}
@onsearch={{action (mut search) value="target.value"}}
@sort={{sort}}
@filter={{filters}}
/>
{{/if}}
<BlockSlot @name='loaded'>
{{#let
(hash value=(or sortBy 'Status:asc') change=(action (mut sortBy) value='target.selected'))
(hash
status=(hash
value=(if status (split status ',') undefined)
change=(action (mut status) value='target.selectedItems')
)
searchproperty=(hash
value=(if
(not-eq searchproperty undefined) (split searchproperty ',') this._searchProperties
)
change=(action (mut searchproperty) value='target.selectedItems')
default=this._searchProperties
)
)
api.data
leader.data
as |sort filters items leader|
}}
{{#let (reject-by 'Meta.synthetic-node' items) as |filtered|}}
<AppView>
<BlockSlot @name='header'>
<h1>
<route.Title @title='Nodes' />
<em>{{format-number items.length}} total</em>
</h1>
<label for='toolbar-toggle'></label>
</BlockSlot>
<BlockSlot @name='toolbar'>
{{#if (gt filtered.length 0)}}
<Consul::Node::SearchBar
@search={{search}}
@onsearch={{action (mut search) value='target.value'}}
@sort={{sort}}
@filter={{filters}}
/>
{{/if}}
</BlockSlot>
<BlockSlot @name='content'>
<DataCollection
@type='node'
@sort={{sort.value}}
@filters={{filters}}
@search={{search}}
@items={{filtered}}
as |collection|
>
<collection.Collection>
<Consul::Node::List @items={{collection.items}} @leader={{leader}} />
</collection.Collection>
<collection.Empty>
<EmptyState @login={{route.model.app.login.open}}>
<BlockSlot @name='header'>
<h2>
{{t 'routes.dc.nodes.index.empty.header' items=items.length}}
</h2>
</BlockSlot>
<BlockSlot @name='body'>
{{t
'routes.dc.nodes.index.empty.body'
items=items.length
canUseACLs=(can 'use acls')
htmlSafe=true
}}
</BlockSlot>
<BlockSlot @name='actions'>
<li class='docs-link'>
<a
href='{{env "CONSUL_DOCS_DEVELOPER_URL"}}/agent'
rel='noopener noreferrer'
target='_blank'
>
{{t 'routes.dc.nodes.index.empty.documentation'}}
</a>
</li>
<li class='learn-link'>
<a
href='{{env
"CONSUL_DOCS_LEARN_URL"
}}/tutorials/consul/deployment-guide?in=consul/production-deploy#configure-consul-agents'
rel='noopener noreferrer'
target='_blank'
>
{{t 'routes.dc.nodes.index.empty.learn'}}
</a>
</li>
</BlockSlot>
</EmptyState>
</collection.Empty>
</DataCollection>
</BlockSlot>
</AppView>
{{/let}}
{{/let}}
</BlockSlot>
<BlockSlot @name="content">
<DataCollection
@type="node"
@sort={{sort.value}}
@filters={{filters}}
@search={{search}}
@items={{items}}
as |collection|>
<collection.Collection>
<Consul::Node::List
@items={{collection.items}}
@leader={{leader}}
/>
</collection.Collection>
<collection.Empty>
<EmptyState
@login={{route.model.app.login.open}}
>
<BlockSlot @name="header">
<h2>
{{t 'routes.dc.nodes.index.empty.header'
items=items.length
}}
</h2>
</BlockSlot>
<BlockSlot @name="body">
{{t 'routes.dc.nodes.index.empty.body'
items=items.length
canUseACLs=(can 'use acls')
htmlSafe=true
}}
</BlockSlot>
<BlockSlot @name="actions">
<li class="docs-link">
<a href="{{env 'CONSUL_DOCS_DEVELOPER_URL'}}/agent" rel="noopener noreferrer" target="_blank">
{{t 'routes.dc.nodes.index.empty.documentation'}}
</a>
</li>
<li class="learn-link">
<a href="{{env "CONSUL_DOCS_LEARN_URL"}}/tutorials/consul/deployment-guide?in=consul/production-deploy#configure-consul-agents" rel="noopener noreferrer" target="_blank">
{{t 'routes.dc.nodes.index.empty.learn'}}
</a>
</li>
</BlockSlot>
</EmptyState>
</collection.Empty>
</DataCollection>
</BlockSlot>
</AppView>
{{/let}}
</BlockSlot>
</DataLoader>
</DataSource>
</Route>
</Route>

View File

@ -54,7 +54,7 @@
"TaggedAddresses":{"lan":"${ip}","wan":"${ip}"},
"Meta":{
"${service}-network-segment":"",
"synthetic-node":${externalSource === 'kubernetes' ? "true" : "false"}
"synthetic-node":${externalSource === 'kubernetes' ? true : false}
},
${typeof location.search.peer !== 'undefined' ? `
"PeerName": "${location.search.peer}",

View File

@ -6,22 +6,32 @@ Feature: dc / nodes / empty-ids: Hedge for if nodes come in over the API with no
---
- ID: id-1
Node: name-1
Meta:
synthetic-node: false
Checks:
- Status: passing
- ID: ""
Node: name-2
Meta:
synthetic-node: false
Checks:
- Status: passing
- ID: ""
Node: name-3
Meta:
synthetic-node: false
Checks:
- Status: passing
- ID: ""
Node: name-4
Meta:
synthetic-node: false
Checks:
- Status: passing
- ID: ""
Node: name-5
Meta:
synthetic-node: false
Checks:
- Status: passing
---

View File

@ -21,6 +21,31 @@ Feature: dc / nodes / index
Then the url should be /dc-1/nodes
Then I see 1 node models
And I see status on the nodes.0 like "critical"
Scenario: Viewing nodes list page should not show synthetic nodes
Given 3 node model from yaml
---
- Meta:
synthetic-node: true
Checks:
- Status: passing
ServiceID: ""
- Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
---
When I visit the nodes page for yaml
---
dc: dc-1
---
Then the url should be /dc-1/nodes
Then I see 2 node models
Scenario: Viewing a node with an unhealthy ServiceCheck
Given 1 node model from yaml
---
@ -29,6 +54,8 @@ Feature: dc / nodes / index
ServiceID: ""
- Status: critical
ServiceID: web
Meta:
synthetic-node: false
---
When I visit the nodes page for yaml
---
@ -38,7 +65,24 @@ Feature: dc / nodes / index
Then I see 1 node models
And I see status on the nodes.0 like "passing"
Scenario: Viewing nodes in the listing
Given 3 node models
Given 3 node model from yaml
---
- Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
---
When I visit the nodes page for yaml
---
dc: dc-1
@ -54,12 +98,18 @@ Feature: dc / nodes / index
Checks:
- Status: critical
Name: Warning check
Meta:
synthetic-node: false
- Address: 10.0.0.1
Checks:
- Status: passing
Meta:
synthetic-node: false
- Address: 10.0.0.3
Checks:
- Status: passing
Meta:
synthetic-node: false
---
When I visit the nodes page for yaml
---
@ -73,10 +123,16 @@ Feature: dc / nodes / index
---
- Node: node-01
Address: 10.0.0.0
Meta:
synthetic-node: false
- Node: node-02
Address: 10.0.0.1
Meta:
synthetic-node: false
- Node: node-03
Address: 10.0.0.2
Meta:
synthetic-node: false
---
When I visit the nodes page for yaml
---

View File

@ -2,7 +2,27 @@
Feature: dc / nodes / navigation
Scenario: Clicking a node in the listing and back again
Given 1 datacenter model with the value "dc-1"
And 3 node models
And 3 node models from yaml
---
- Node: Node-A
Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
- Node: Node-B
Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Node: Node-C
Meta:
synthetic-node: false
Checks:
- Status: warning
ServiceID: ""
---
When I visit the nodes page for yaml
---
dc: dc-1

View File

@ -2,7 +2,27 @@
Feature: dc / nodes / no-leader
Scenario: Leader hasn't been elected
Given 1 datacenter model with the value "dc-1"
And 3 node models
And 3 node models from yaml
---
- Node: Node-A
Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
- Node: Node-B
Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Node: Node-C
Meta:
synthetic-node: false
Checks:
- Status: warning
ServiceID: ""
---
And the url "/v1/status/leader" responds with from yaml
---
body: |

View File

@ -5,26 +5,38 @@ Feature: dc / nodes / sorting
And 6 node models from yaml
---
- Node: Node-A
Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
- Node: Node-B
Meta:
synthetic-node: false
Checks:
- Status: passing
ServiceID: ""
- Node: Node-C
Meta:
synthetic-node: false
Checks:
- Status: warning
ServiceID: ""
- Node: Node-D
Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
- Node: Node-E
Meta:
synthetic-node: false
Checks:
- Status: critical
ServiceID: ""
- Node: Node-F
Meta:
synthetic-node: false
Checks:
- Status: warning
ServiceID: ""