UI: Fix Connect proxy tag (#6343)

This fixes a race condition in the pseudo-relationship between a
TaskState and a Task that was causing the Consul Connect proxy tag
to sometimes show on the wrong task. There’s no direct Ember Data-style
relationship between a TaskState and its Task; instead, it’s determined
by searching for a Task with the matching name. The related Task was
sometimes stored before everything was ready and not recalculated when
the name became known. This ensures the relationship is accurate if the
TaskState’s name property changes.
This commit is contained in:
Buck Doyle 2019-09-19 08:09:49 -05:00 committed by GitHub
parent 128b74ba12
commit d707038429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export default Fragment.extend({
return (this.get('task.kind') || '').startsWith('connect-proxy:');
}),
task: computed('allocation.taskGroup.tasks.[]', function() {
task: computed('name', 'allocation.taskGroup.tasks.[]', function() {
const tasks = this.get('allocation.taskGroup.tasks');
return tasks && tasks.findBy('name', this.name);
}),

View File

@ -1,7 +1,7 @@
import { run } from '@ember/runloop';
import { currentURL } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
import { module, skip, test } from 'qunit';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import Allocation from 'nomad-ui/tests/pages/allocations/detail';
@ -140,7 +140,7 @@ module('Acceptance | allocation detail', function(hooks) {
assert.ok(Allocation.firstUnhealthyTask().hasUnhealthyDriver, 'Warning is shown');
});
skip('proxy task has a proxy tag', async function(assert) {
test('proxy task has a proxy tag', async function(assert) {
// Must create a new job as existing one has loaded and it contains the tasks
job = server.create('job', {
groupsCount: 1,

View File

@ -1,5 +1,5 @@
import { currentURL } from '@ember/test-helpers';
import { module, skip, test } from 'qunit';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import Task from 'nomad-ui/tests/pages/allocations/task/detail';
@ -326,7 +326,7 @@ module('Acceptance | proxy task detail', function(hooks) {
await Task.visit({ id: allocation.id, name: taskState.name });
});
skip('a proxy tag is shown', async function(assert) {
test('a proxy tag is shown', async function(assert) {
assert.ok(Task.title.proxyTag.isPresent);
});
});