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 <Route @name={{routeName}} as |route|>
@name={{routeName}}
as |route|>
<DataSource @src={{ <DataSource
uri '/${partition}/${nspace}/${dc}/leader' @src={{uri
(hash '/${partition}/${nspace}/${dc}/leader'
partition=route.params.partition (hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
nspace=route.params.nspace }}
dc=route.params.dc as |leader|
) >
}} as |leader|>
<DataLoader <DataLoader
@src={{uri '/${partition}/${nspace}/${dc}/nodes' @src={{uri
(hash '/${partition}/${nspace}/${dc}/nodes'
partition=route.params.partition (hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
nspace=route.params.nspace
dc=route.params.dc
)
}} }}
as |api|> as |api|
>
<BlockSlot @name="error"> <BlockSlot @name='error'>
<AppError <AppError @error={{api.error}} @login={{route.model.app.login.open}} />
@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> </BlockSlot>
<BlockSlot @name="toolbar">
{{#if (gt items.length 0) }}
<Consul::Node::SearchBar
@search={{search}}
@onsearch={{action (mut search) value="target.value"}}
@sort={{sort}} <BlockSlot @name='loaded'>
{{#let
@filter={{filters}} (hash value=(or sortBy 'Status:asc') change=(action (mut sortBy) value='target.selected'))
/> (hash
{{/if}} 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>
<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> </DataLoader>
</DataSource> </DataSource>
</Route> </Route>

View File

@ -54,7 +54,7 @@
"TaggedAddresses":{"lan":"${ip}","wan":"${ip}"}, "TaggedAddresses":{"lan":"${ip}","wan":"${ip}"},
"Meta":{ "Meta":{
"${service}-network-segment":"", "${service}-network-segment":"",
"synthetic-node":${externalSource === 'kubernetes' ? "true" : "false"} "synthetic-node":${externalSource === 'kubernetes' ? true : false}
}, },
${typeof location.search.peer !== 'undefined' ? ` ${typeof location.search.peer !== 'undefined' ? `
"PeerName": "${location.search.peer}", "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 - ID: id-1
Node: name-1 Node: name-1
Meta:
synthetic-node: false
Checks: Checks:
- Status: passing - Status: passing
- ID: "" - ID: ""
Node: name-2 Node: name-2
Meta:
synthetic-node: false
Checks: Checks:
- Status: passing - Status: passing
- ID: "" - ID: ""
Node: name-3 Node: name-3
Meta:
synthetic-node: false
Checks: Checks:
- Status: passing - Status: passing
- ID: "" - ID: ""
Node: name-4 Node: name-4
Meta:
synthetic-node: false
Checks: Checks:
- Status: passing - Status: passing
- ID: "" - ID: ""
Node: name-5 Node: name-5
Meta:
synthetic-node: false
Checks: Checks:
- Status: passing - Status: passing
--- ---

View File

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

View File

@ -2,7 +2,27 @@
Feature: dc / nodes / navigation Feature: dc / nodes / navigation
Scenario: Clicking a node in the listing and back again Scenario: Clicking a node in the listing and back again
Given 1 datacenter model with the value "dc-1" 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 When I visit the nodes page for yaml
--- ---
dc: dc-1 dc: dc-1

View File

@ -2,7 +2,27 @@
Feature: dc / nodes / no-leader Feature: dc / nodes / no-leader
Scenario: Leader hasn't been elected Scenario: Leader hasn't been elected
Given 1 datacenter model with the value "dc-1" 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 And the url "/v1/status/leader" responds with from yaml
--- ---
body: | body: |

View File

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