[ui, deployments] Fix a bug where watchers on a parent (periodic) job would continue on a child route #17214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On a parent/child Nomad job (periodic, parameterized), the Nomad UI shows a page at
jobs/:job
that aggregates information about its child jobs. For example, a periodic job that runs hourly, etc. would have all its hourly runs included in a "Child Jobs" table.That parent job, though, does not have any allocations (or evaluations, or services) of its own. Despite this, we do consider it a job, if only of a different type (we might otherwise have considered it a "folder" or some other similar concept)
Because we consider it a job, we give it all the bells and whistles that nomad jobs have at the top level (we're pulling some of these back, though; see the removal of unnecessary subnav in #17190 for example).
While this is pretty innocuous most of the time (an empty list of allocations is always returned for a parent periodic job, causing no real harm), there is a problem with how these watchers interact with our concept of routes: because moving from a parent job to its child has the same Ember route location, not everything is torn down and brought back up again. Our relationship watchers need to be cancelled and restarted with the child job's model. This PR cancels existing watchers when doing a transition between two pages at the same route.
In plain terms, before this PR, the content of the "Task Groups" bar would update, but the content of the "Allocations" table never would — only when clicking into the child job from its parent. When loaded directly by URL, things would work fine. This is fixed with the exact-name check here.
Resolves #17193