Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ui/admin/app/routes/scopes/scope/targets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export default class ScopesScopeTargetsIndexRoute extends Route {
});

if (this.can.can('list model', scope, { collection: 'sessions' })) {
// Before querying sessions, unload sessions currently stored in ember data store
// so that we remove any expired sessions that still might be cached.
this.store.unloadAll('session');
const sessions = await this.store.query('session', {
scope_id,
include_terminated: true,
query: {
filters: {
scope_id: [{ equals: scope_id }],
Expand Down Expand Up @@ -147,7 +151,7 @@ export default class ScopesScopeTargetsIndexRoute extends Route {
},
},
},
{ pushToStore: true, peekDb: true },
{ peekDb: true },
);
}
return { targets, doTargetsExist, totalItems };
Expand Down
10 changes: 7 additions & 3 deletions ui/admin/tests/acceptance/targets/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ module('Acceptance | targets | list', function (hooks) {
instances.sshTarget.id,
'session is associated with correct target',
);
const emberDataSessionModel = this.owner
const emberDataSessionModelBefore = this.owner
.lookup('service:store')
.peekRecord('session', instances.session.id);
assert.strictEqual(
emberDataSessionModel.status,
emberDataSessionModelBefore.status,
STATUS_SESSION_ACTIVE,
'ember data session model is active',
);
Expand All @@ -396,14 +396,18 @@ module('Acceptance | targets | list', function (hooks) {
instances.session.status = STATUS_SESSION_TERMINATED;

await click(commonSelectors.HREF(urls.targets));

const emberDataSessionModelAfter = this.owner
.lookup('service:store')
.peekRecord('session', instances.session.id);
assert
.dom(selectors.TABLE_TARGETS_ROW(instances.sshTarget.id))
.exists('the target is still listed in the table');
assert
.dom(selectors.TABLE_ACTIVE_SESSIONS(instances.sshTarget.id))
.doesNotExist('the target does not have an active session');
assert.strictEqual(
emberDataSessionModel.status,
emberDataSessionModelAfter.status,
STATUS_SESSION_TERMINATED,
'the session ember data model status is updated',
);
Expand Down
4 changes: 2 additions & 2 deletions ui/desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ The static production assets are saved into the `dist/` folder.
The Boundary CLI is downloaded and extracted to `electron-app/cli/` folder as part of
packaging. CLI version is defined in `electron-app/config/cli.js`.

Similar to running in development, you can also use `BYPASS_CLI_SETUP=true` to
bypass the download of the CLI, which can be useful for pre-release testing. See
Similar to running in development, you can also use `SETUP_CLI=true` to
enable the download of the CLI, which can be useful for pre-release testing. See
[Developing Using Non-Release Versions of
Boundary](#developing-using-non-release-versions-of-boundary) for more details.

Expand Down
18 changes: 9 additions & 9 deletions ui/desktop/app/routes/scopes/scope/projects/targets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
filters.type.push({ equals: type });
});

// Before querying sessions, unload sessions currently stored in ember data store
// so that we remove any expired sessions that still might be cached.
this.store.unloadAll('session');

const sessions = await this.getSessions(orgScope, scopes, orgFilter);
this.addActiveSessionFilters(filters, availableSessions, sessions);

Expand Down Expand Up @@ -159,17 +163,13 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
// To correctly show targets with active sessions, the associated
// sessions need to be queried to sync all the session models in
// ember data and retrieve their updated `status` properties
const sessionsPromise = this.store.query(
'session',
{
query: {
filters: {
target_id: targets.map((target) => ({ equals: target.id })),
},
const sessionsPromise = this.store.query('session', {
query: {
filters: {
target_id: targets.map((target) => ({ equals: target.id })),
},
},
{ pushToStore: true },
);
});

// Load the sessions and aliases for the targets on the current page
try {
Expand Down
7 changes: 5 additions & 2 deletions ui/desktop/electron-app/src/models/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
spawnAsyncJSONPromise,
spawnSync,
} = require('../helpers/spawn-promise.js');
const log = require('electron-log/main');

class Session {
#id;
Expand Down Expand Up @@ -89,7 +90,6 @@ class Session {
).then((spawnedSession) => {
this.#process = spawnedSession.childProcess;
this.#proxyDetails = spawnedSession.response;
this.#process = spawnedSession.childProcess;
this.#id = this.#proxyDetails.session_id;
return this.#proxyDetails;
});
Expand All @@ -102,7 +102,10 @@ class Session {
return new Promise((resolve, reject) => {
if (this.isRunning) {
this.#process.on('close', () => resolve());
this.#process.on('error', (e) => reject(e));
this.#process.on('error', (e) => {
log.error('Process error in session stop method: ', e);
return reject(e);
});

// Cancel session before killing process
const sanitizedToken = sanitizer.base62EscapeAndValidate(this.#token);
Expand Down
15 changes: 12 additions & 3 deletions ui/desktop/tests/acceptance/projects/targets/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,14 @@ module('Acceptance | projects | targets | index', function (hooks) {

assert.strictEqual(instances.session.status, STATUS_SESSION_ACTIVE);
await visit(urls.targets);
const emberDataSessionModel = this.owner
const emberDataSessionModelBefore = this.owner
.lookup('service:store')
.peekRecord('session', instances.session.id);

assert.strictEqual(emberDataSessionModel.status, STATUS_SESSION_ACTIVE);
assert.strictEqual(
emberDataSessionModelBefore.status,
STATUS_SESSION_ACTIVE,
);

assert
.dom(activeSessionFlyoutButtonSelector(instances.session.targetId))
Expand All @@ -704,7 +707,13 @@ module('Acceptance | projects | targets | index', function (hooks) {

await click(`[href="${urls.targets}"]`);

assert.strictEqual(emberDataSessionModel.status, STATUS_SESSION_TERMINATED);
const emberDataSessionModelAfter = this.owner
.lookup('service:store')
.peekRecord('session', instances.session.id);
assert.strictEqual(
emberDataSessionModelAfter.status,
STATUS_SESSION_TERMINATED,
);
assert
.dom(activeSessionFlyoutButtonSelector(instances.session.targetId))
.doesNotExist();
Expand Down
Loading