Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace refactoring #12082

Merged
merged 24 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1a3bb32
temp: namespace model refact
ChaiWithJai Jan 14, 2022
898cda0
temp: csi refactor
ChaiWithJai Jan 19, 2022
793f9c2
temp: bug in region selector causing failing test
ChaiWithJai Feb 10, 2022
498187b
feat: add `idWithNamespace`-getter job model
LevelbossMike Feb 16, 2022
87e4955
refact: render jobs.index template again
LevelbossMike Feb 16, 2022
12339d7
refact: use `idWithNamespace` in job-row links
LevelbossMike Feb 16, 2022
134fdf9
feat: improve namespace handling job-route
LevelbossMike Feb 16, 2022
6b142f8
fix: job-dispatch tests after namespace changes
LevelbossMike Feb 16, 2022
5db6da4
fix: job-versions-test
LevelbossMike Feb 16, 2022
4c38757
refact: use `idWithNamespace` in serialize hook jobs.job
LevelbossMike Feb 16, 2022
70f855e
refact: don't pass namespace as query-param in job-subnav
LevelbossMike Feb 16, 2022
a4244e6
fix: some test fixes module-for-job
LevelbossMike Feb 16, 2022
efbf42b
fix: allocations page tests regarding job links
LevelbossMike Feb 17, 2022
51775a0
fix: client-detail-test no default namespace param
LevelbossMike Feb 17, 2022
31cbd77
fix: less cleverness™ when checking currentURL job-details
LevelbossMike Feb 17, 2022
dadbb0e
fix: anonymous policy test job-details
LevelbossMike Feb 17, 2022
221311d
fix: pack-detail test
LevelbossMike Feb 17, 2022
550a5c0
fix: use `@<namespace>` with remaining `JobDetail.visit`s
LevelbossMike Feb 17, 2022
23f1cb5
fix: breadcrumbs allocations due to recent namespace changes
LevelbossMike Feb 17, 2022
6dae23b
fix: task-group-detail tests due to namespace changes
LevelbossMike Feb 17, 2022
c475e37
fix: prettier related test-failutre task-group-detail
LevelbossMike Feb 17, 2022
af6da28
fix: prettier related volume-list - test
LevelbossMike Feb 17, 2022
a1b2013
fix: reflect namespace change volume-detail-test
LevelbossMike Feb 17, 2022
02218c6
fix: linting issues and remove remainidn pauseTest
LevelbossMike Feb 17, 2022
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: 2 additions & 4 deletions ui/app/components/breadcrumbs/job.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<li>
<LinkTo
@route="jobs.job.index"
@model={{trigger.data.result.plainId}}
@query={{hash namespace=(or trigger.data.result.namespace.name "default")}}
@model={{trigger.data.result}}
data-test-breadcrumb={{"jobs.job.index"}}
>
<dl>
Expand All @@ -30,8 +29,7 @@
<li>
<LinkTo
@route="jobs.job.index"
@model={{this.job.plainId}}
@query={{hash namespace=(or this.job.namespace.name "default")}}
@model={{this.job}}
data-test-breadcrumb={{"jobs.job.index"}}
data-test-job-breadcrumb
>
Expand Down
9 changes: 6 additions & 3 deletions ui/app/components/job-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ export default class JobDispatch extends Component {
const dispatch = yield this.args.job.dispatch(paramValues, this.payload);

// Navigate to the newly created instance.
this.router.transitionTo('jobs.job', dispatch.DispatchedJobID, {
queryParams: { namespace: this.args.job.get('namespace.name') },
});
const namespaceId = this.args.job.belongsTo('namespace').id();
const jobId = namespaceId
? `${dispatch.DispatchedJobID}@${namespaceId}`
: dispatch.DispatchedJobID;

this.router.transitionTo('jobs.job', jobId);
} catch (err) {
const error = messageFromAdapterError(err) || 'Could not dispatch job';
this.errors.pushObject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default class JobClientStatusSummary extends Component {
this.router.transitionTo('jobs.job.clients', this.job, {
queryParams: {
status: JSON.stringify(statusFilter),
namespace: this.job.get('namespace.name'),
},
});
}
Expand Down
4 changes: 1 addition & 3 deletions ui/app/components/job-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export default class JobRow extends Component {
@action
gotoJob() {
const { job } = this;
this.router.transitionTo('jobs.job', job.plainId, {
queryParams: { namespace: job.get('namespace.name') },
});
this.router.transitionTo('jobs.job.index', job.idWithNamespace);
}
}
3 changes: 1 addition & 2 deletions ui/app/controllers/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ export default class AllocationsAllocationController extends Controller {
label: allocation.taskGroupName,
args: [
'jobs.job.task-group',
job.plainId,
job.idWithNamespace,
allocation.taskGroupName,
jobQueryParams,
],
},
{
Expand Down
7 changes: 4 additions & 3 deletions ui/app/controllers/csi/volumes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ export default class IndexController extends Controller.extend(
gotoVolume(volume, event) {
lazyClick([
() =>
this.transitionToRoute('csi.volumes.volume', volume.get('plainId'), {
queryParams: { volumeNamespace: volume.get('namespace.name') },
}),
this.transitionToRoute(
'csi.volumes.volume',
volume.get('idWithNamespace')
),
event,
]);
}
Expand Down
8 changes: 1 addition & 7 deletions ui/app/controllers/jobs/job/task-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Controller from '@ember/controller';
import { action, computed, get } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';
import intersection from 'lodash.intersection';
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
import Sortable from 'nomad-ui/mixins/sortable';
import Searchable from 'nomad-ui/mixins/searchable';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
Expand Down Expand Up @@ -174,12 +173,7 @@ export default class TaskGroupController extends Controller.extend(
return {
title: 'Task Group',
label: name,
args: [
'jobs.job.task-group',
job,
name,
qpBuilder({ jobNamespace: job.get('namespace.name') || 'default' }),
],
args: ['jobs.job.task-group', job, name],
};
}
}
11 changes: 11 additions & 0 deletions ui/app/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ export default class Job extends Model {
@attr() periodicDetails;
@attr() parameterizedDetails;

@computed('plainId')
get idWithNamespace() {
const namespaceId = this.belongsTo('namespace').id();

if (!namespaceId || namespaceId === 'default') {
return this.plainId;
} else {
return `${this.plainId}@${namespaceId}`;
}
}

@computed('periodic', 'parameterized', 'dispatched')
get hasChildren() {
return this.periodic || (this.parameterized && !this.dispatched);
Expand Down
7 changes: 7 additions & 0 deletions ui/app/models/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export default class Volume extends Model {
@attr('number') controllersHealthy;
@attr('number') controllersExpected;

@computed('plainId')
get idWithNamespace() {
// does this handle default namespace -- I think the backend handles this for us
// but the client would always need to recreate that logic
return `${this.plainId}@${this.belongsTo('namespace').id()}`;
}

@computed('controllersHealthy', 'controllersExpected')
get controllersHealthyProportion() {
return this.controllersHealthy / this.controllersExpected;
Expand Down
12 changes: 8 additions & 4 deletions ui/app/routes/csi/volumes/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ export default class VolumeRoute extends Route.extend(WithWatchers) {
}

serialize(model) {
return { volume_name: model.get('plainId') };
return { volume_name: JSON.parse(model.get('id')).join('@') };
}

model(params, transition) {
const namespace = transition.to.queryParams.namespace;
const name = params.volume_name;
model(params) {
// Issue with naming collissions
const url = params.volume_name.split('@');
const namespace = url.pop();
const name = url.join('');

const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']);

return RSVP.hash({
volume: this.store.findRecord('volume', fullId, { reload: true }),
namespaces: this.store.findAll('namespace'),
Expand Down
8 changes: 4 additions & 4 deletions ui/app/routes/jobs/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default class JobRoute extends Route {
@service token;

serialize(model) {
return { job_name: model.get('plainId') };
return { job_name: model.get('idWithNamespace') };
}

model(params, transition) {
const namespace = transition.to.queryParams.namespace || 'default';
const name = params.job_name;
model(params) {
const [name, namespace = 'default'] = params.job_name.split('@');

const fullId = JSON.stringify([name, namespace]);

return this.store
Expand Down
Loading