-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: [Bugfix] - Sticky KV Sessions (#6166)
Initialize session value to `null` to prevent stickiness from a session the previous KV
- Loading branch information
Showing
6 changed files
with
123 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,77 @@ | ||
{{#app-view class="kv edit" loading=isLoading}} | ||
{{#block-slot 'notification' as |status type|}} | ||
{{partial 'dc/kv/notifications'}} | ||
{{/block-slot}} | ||
{{#block-slot 'breadcrumbs'}} | ||
<ol> | ||
<li><a data-test-back href={{href-to 'dc.kv.index'}}>Key / Values</a></li> | ||
{{#if (not-eq parent.Key '/') }} | ||
{{#each (slice 0 -1 (split parent.Key '/')) as |breadcrumb index|}} | ||
<li><a href={{href-to 'dc.kv.folder' (join '/' (append (slice 0 (add index 1) (split parent.Key '/')) ''))}}>{{breadcrumb}}</a></li> | ||
{{/each}} | ||
{{#block-slot 'notification' as |status type|}} | ||
{{partial 'dc/kv/notifications'}} | ||
{{/block-slot}} | ||
{{#block-slot 'breadcrumbs'}} | ||
<ol> | ||
<li><a data-test-back href={{href-to 'dc.kv.index'}}>Key / Values</a></li> | ||
{{#if (not-eq parent.Key '/')}} | ||
{{#each (slice 0 -1 (split parent.Key '/')) as |breadcrumb index|}} | ||
<li><a href={{href-to 'dc.kv.folder' (join '/' (append (slice 0 (add index 1) (split parent.Key '/')) ''))}}>{{breadcrumb}}</a></li> | ||
{{/each}} | ||
{{/if}} | ||
</ol> | ||
{{/block-slot}} | ||
{{#block-slot 'header'}} | ||
<h1> | ||
{{#if item.Key }} | ||
{{left-trim item.Key parent.Key }} | ||
</ol> | ||
{{/block-slot}} | ||
{{#block-slot 'header'}} | ||
<h1> | ||
{{#if item.Key}} | ||
{{left-trim item.Key parent.Key}} | ||
{{else}} | ||
New Key / Value | ||
New Key / Value | ||
{{/if}} | ||
</h1> | ||
{{/block-slot}} | ||
{{#block-slot 'content'}} | ||
{{#if session}} | ||
<p class="notice warning"><strong>Warning.</strong> This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see <a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html" target="_blank" rel="noopener noreferrer">our documentation</a> for more information.</p> | ||
{{/if}} | ||
{{partial 'dc/kv/form'}} | ||
{{#if session}} | ||
<div data-test-session> | ||
<h2><a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html#session-design" rel="help noopener noreferrer" target="_blank">Lock Session</a></h2> | ||
<dl> | ||
<dt>Name</dt> | ||
<dd>{{session.Name}}</dd> | ||
<dt>Agent</dt> | ||
<dd> | ||
<a href={{href-to 'dc.nodes.show' session.Node }}>{{session.Node}}</a> | ||
</dd> | ||
<dt>ID</dt> | ||
<dd>{{session.ID}}</dd> | ||
<dt>Behavior</dt> | ||
<dd>{{session.Behavior}}</dd> | ||
</h1> | ||
{{/block-slot}} | ||
{{#block-slot 'content'}} | ||
{{#if session}} | ||
<p class="notice warning"> | ||
<strong>Warning.</strong> This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see <a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html" target="_blank" rel="noopener noreferrer">our documentation</a> for more information. | ||
</p> | ||
{{/if}} | ||
{{partial 'dc/kv/form'}} | ||
{{#if session}} | ||
<div data-test-session={{session.ID}}> | ||
<h2> | ||
<a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html#session-design" rel="help noopener noreferrer" target="_blank">Lock Session</a> | ||
</h2> | ||
<dl> | ||
<dt>Name</dt> | ||
<dd>{{session.Name}}</dd> | ||
<dt>Agent</dt> | ||
<dd> | ||
<a href={{href-to 'dc.nodes.show' session.Node}}>{{session.Node}}</a> | ||
</dd> | ||
<dt>ID</dt> | ||
<dd>{{session.ID}}</dd> | ||
<dt>Behavior</dt> | ||
<dd>{{session.Behavior}}</dd> | ||
{{#if session.Delay }} | ||
<dt>Delay</dt> | ||
<dd>{{session.LockDelay}}</dd> | ||
<dt>Delay</dt> | ||
<dd>{{session.LockDelay}}</dd> | ||
{{/if}} | ||
{{#if session.TTL }} | ||
<dt>TTL</dt> | ||
<dd>{{session.TTL}}</dd> | ||
<dt>TTL</dt> | ||
<dd>{{session.TTL}}</dd> | ||
{{/if}} | ||
{{#if (gt session.Checks.length 0)}} | ||
<dt>Health Checks</dt> | ||
<dd> | ||
{{ join ', ' session.Checks}} | ||
</dd> | ||
<dt>Health Checks</dt> | ||
<dd> | ||
{{ join ', ' session.Checks}} | ||
</dd> | ||
{{/if}} | ||
</dl> | ||
{{#confirmation-dialog message='Are you sure you want to invalidate this session?'}} | ||
{{#block-slot 'action' as |confirm|}} | ||
<button type="button" data-test-delete class="type-delete" {{ action confirm "invalidateSession" session }}>Invalidate Session</button> | ||
{{/block-slot}} | ||
{{#block-slot 'dialog' as |execute cancel message|}} | ||
<p> | ||
{{message}} | ||
</p> | ||
<button type="button" class="type-delete" {{action execute}}>Confirm Invalidation</button> | ||
<button type="button" class="type-cancel" {{action cancel}}>Cancel</button> | ||
{{/block-slot}} | ||
{{/confirmation-dialog}} | ||
</div> | ||
{{/if}} | ||
{{/block-slot}} | ||
</dl> | ||
{{#confirmation-dialog message='Are you sure you want to invalidate this session?'}} | ||
{{#block-slot 'action' as |confirm|}} | ||
<button type="button" data-test-delete class="type-delete" {{action confirm "invalidateSession" session}}>Invalidate Session</button> | ||
{{/block-slot}} | ||
{{#block-slot 'dialog' as |execute cancel message|}} | ||
<p> | ||
{{message}} | ||
</p> | ||
<button type="button" class="type-delete" {{action execute}}>Confirm Invalidation</button> | ||
<button type="button" class="type-cancel" {{action cancel}}>Cancel</button> | ||
{{/block-slot}} | ||
{{/confirmation-dialog}} | ||
</div> | ||
{{/if}} | ||
{{/block-slot}} | ||
{{/app-view}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@setupApplicationTest | ||
Feature: dc / kvs / edit: KV Viewing | ||
Scenario: | ||
Given 1 datacenter model with the value "datacenter" | ||
And 1 kv model from yaml | ||
--- | ||
Key: key | ||
Session: session-id | ||
--- | ||
When I visit the kv page for yaml | ||
--- | ||
dc: datacenter | ||
kv: key | ||
--- | ||
Then the url should be /datacenter/kv/key/edit | ||
And I see ID on the session like "session-id" | ||
Given 1 kv model from yaml | ||
--- | ||
Key: another-key | ||
Session: ~ | ||
--- | ||
When I visit the kv page for yaml | ||
--- | ||
dc: datacenter | ||
kv: another-key | ||
--- | ||
Then I don't see ID on the session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import steps from '../../steps'; | ||
|
||
// step definitions that are shared between features should be moved to the | ||
// tests/acceptance/steps/steps.js file | ||
|
||
export default function(assert) { | ||
return steps(assert).then('I should find a file', function() { | ||
assert.ok(true, this.step); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
export default function(visitable, submitable, deletable, cancelable) { | ||
return submitable( | ||
cancelable( | ||
deletable({ | ||
visit: visitable(['/:dc/kv/:kv/edit', '/:dc/kv/create'], function(str) { | ||
// this will encode the parts of the key path but means you can no longer | ||
// visit with path parts containing slashes | ||
return str | ||
.split('/') | ||
.map(encodeURIComponent) | ||
.join('/'); | ||
}), | ||
session: deletable({}, '[data-test-session]'), | ||
}) | ||
) | ||
); | ||
export default function(visitable, attribute, submitable, deletable, cancelable) { | ||
return { | ||
visit: visitable(['/:dc/kv/:kv/edit', '/:dc/kv/create'], function(str) { | ||
// this will encode the parts of the key path but means you can no longer | ||
// visit with path parts containing slashes | ||
return str | ||
.split('/') | ||
.map(encodeURIComponent) | ||
.join('/'); | ||
}), | ||
...submitable(), | ||
...cancelable(), | ||
...deletable(), | ||
session: { | ||
ID: attribute('data-test-session', '[data-test-session]'), | ||
...deletable({}, '[data-test-session]'), | ||
}, | ||
}; | ||
} |