-
Notifications
You must be signed in to change notification settings - Fork 2k
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
UI: Scaling observability #8551
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2f5cbbf
Data modeling for job scale and scale events
DingoEatingFuzz 5f2dee8
Model job scaling and events in Mirage
DingoEatingFuzz 5f2cdd1
Refactor job summary adapter to use the namespace ID base class
DingoEatingFuzz 87a6702
New fluid height modifier for the json viewer
DingoEatingFuzz 9d43e66
Finish modeling behaviors within job scale events
DingoEatingFuzz 4e01b2c
Load and watch the job scale endpoint on the task group page
DingoEatingFuzz 9c5a2b5
Present scaling events on the job task group page
DingoEatingFuzz 9008694
Make scale event properties more conditional and serialized correctly
DingoEatingFuzz cc44bc4
Acceptance tests for scaling events
DingoEatingFuzz 193dc7a
Refactor scale events into their own component
DingoEatingFuzz b0830f5
Integration tests for the scale-events-accordion component
DingoEatingFuzz a503191
Assert that the scale up/down indicator is not shown when the count i…
DingoEatingFuzz f041e08
Fix scale and summary adapters to correct live reloading
DingoEatingFuzz a45f316
Add a tooltip to explain the count change icons
DingoEatingFuzz 75aa9ce
Add scaling observability feature to the changelog
DingoEatingFuzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import WatchableNamespaceIDs from './watchable-namespace-ids'; | ||
|
||
export default class JobScaleAdapter extends WatchableNamespaceIDs { | ||
urlForFindRecord(id, type, hash) { | ||
return super.urlForFindRecord(id, 'job', hash, 'scale'); | ||
} | ||
} |
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,12 +1,7 @@ | ||
import Watchable from './watchable'; | ||
import WatchableNamespaceIDs from './watchable-namespace-ids'; | ||
|
||
export default class JobSummaryAdapter extends Watchable { | ||
export default class JobSummaryAdapter extends WatchableNamespaceIDs { | ||
urlForFindRecord(id, type, hash) { | ||
const [name, namespace] = JSON.parse(id); | ||
let url = super.urlForFindRecord(name, 'job', hash) + '/summary'; | ||
if (namespace && namespace !== 'default') { | ||
url += `?namespace=${namespace}`; | ||
} | ||
return url; | ||
return super.urlForFindRecord(id, 'job', hash, 'summary'); | ||
} | ||
} |
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
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,7 +1,7 @@ | ||
import { inject as service } from '@ember/service'; | ||
import { alias, readOnly } from '@ember/object/computed'; | ||
import Controller from '@ember/controller'; | ||
import { action, computed } from '@ember/object'; | ||
import { action, computed, get } from '@ember/object'; | ||
import Sortable from 'nomad-ui/mixins/sortable'; | ||
import Searchable from 'nomad-ui/mixins/searchable'; | ||
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting'; | ||
|
@@ -51,6 +51,15 @@ export default class TaskGroupController extends Controller.extend( | |
@alias('listSorted') listToSearch; | ||
@alias('listSearched') sortedAllocations; | ||
|
||
@computed('[email protected]', function() { | ||
const events = get(this, 'model.scaleState.events'); | ||
if (events) { | ||
return events.sortBy('time').reverse(); | ||
} | ||
return []; | ||
}) | ||
sortedScaleEvents; | ||
|
||
@computed('model.job.runningDeployment') | ||
get tooltipText() { | ||
if (this.can.cannot('scale job')) return "You aren't allowed to scale task groups"; | ||
|
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,11 @@ | ||
import Model from 'ember-data/model'; | ||
import { belongsTo } from 'ember-data/relationships'; | ||
import { fragmentArray } from 'ember-data-model-fragments/attributes'; | ||
import classic from 'ember-classic-decorator'; | ||
|
||
@classic | ||
export default class JobSummary extends Model { | ||
@belongsTo('job') job; | ||
|
||
@fragmentArray('task-group-scale') taskGroupScales; | ||
} |
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 |
---|---|---|
|
@@ -119,6 +119,7 @@ export default class Job extends Model { | |
@hasMany('deployments') deployments; | ||
@hasMany('evaluations') evaluations; | ||
@belongsTo('namespace') namespace; | ||
@belongsTo('job-scale') scaleState; | ||
|
||
@computed('[email protected]') | ||
get drivers() { | ||
|
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,34 @@ | ||
import { computed } from '@ember/object'; | ||
import Fragment from 'ember-data-model-fragments/fragment'; | ||
import attr from 'ember-data/attr'; | ||
import { fragmentOwner } from 'ember-data-model-fragments/attributes'; | ||
|
||
export default class ScaleEvent extends Fragment { | ||
@fragmentOwner() taskGroupScale; | ||
|
||
@attr('number') count; | ||
@attr('number') previousCount; | ||
@attr('boolean') error; | ||
@attr('string') evalId; | ||
|
||
@computed('count', function() { | ||
return this.count != null; | ||
}) | ||
hasCount; | ||
|
||
@computed('count', 'previousCount', function() { | ||
return this.count > this.previousCount; | ||
}) | ||
increased; | ||
|
||
@attr('date') time; | ||
@attr('number') timeNanos; | ||
|
||
@attr('string') message; | ||
@attr() meta; | ||
|
||
@computed('meta', function() { | ||
return Object.keys(this.meta).length > 0; | ||
}) | ||
hasMeta; | ||
} |
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,23 @@ | ||
import { computed } from '@ember/object'; | ||
import Fragment from 'ember-data-model-fragments/fragment'; | ||
import attr from 'ember-data/attr'; | ||
import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes'; | ||
|
||
export default class TaskGroupScale extends Fragment { | ||
@fragmentOwner() jobScale; | ||
|
||
@attr('string') name; | ||
|
||
@attr('number') desired; | ||
@attr('number') placed; | ||
@attr('number') running; | ||
@attr('number') healthy; | ||
@attr('number') unhealthy; | ||
|
||
@fragmentArray('scale-event') events; | ||
|
||
@computed('events.length', function() { | ||
return this.events.length; | ||
}) | ||
isVisible; | ||
} |
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
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,19 @@ | ||
import { assign } from '@ember/polyfills'; | ||
import ApplicationSerializer from './application'; | ||
|
||
export default class JobScale extends ApplicationSerializer { | ||
normalize(modelClass, hash) { | ||
// Transform the map-based TaskGroups object into an array-based | ||
// TaskGroupScale fragment list | ||
hash.PlainJobId = hash.JobID; | ||
hash.ID = JSON.stringify([hash.JobID, hash.Namespace || 'default']); | ||
hash.JobID = hash.ID; | ||
|
||
const taskGroups = hash.TaskGroups || {}; | ||
hash.TaskGroupScales = Object.keys(taskGroups).map(key => { | ||
return assign(taskGroups[key], { Name: key }); | ||
}); | ||
|
||
return super.normalize(modelClass, hash); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import ApplicationSerializer from './application'; | ||
|
||
export default class ScaleEventSerializer extends ApplicationSerializer { | ||
normalize(typeHash, hash) { | ||
hash.TimeNanos = hash.Time % 1000000; | ||
hash.Time = Math.floor(hash.Time / 1000000); | ||
|
||
return super.normalize(typeHash, hash); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.json-viewer { | ||
&.has-fluid-height .CodeMirror-scroll { | ||
min-height: 0; | ||
} | ||
} |
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,4 +1,5 @@ | ||
<IvyCodemirror | ||
data-test-json-viewer | ||
@value={{this.jsonStr}} | ||
@options={{hash | ||
mode="javascript" | ||
|
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,5 +1,5 @@ | ||
{{#if this.isOpen}} | ||
<div data-test-accordion-body class="accordion-body"> | ||
<div data-test-accordion-body class="accordion-body {{if this.fullBleed "is-full-bleed"}}"> | ||
{{yield}} | ||
</div> | ||
{{/if}} |
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,35 @@ | ||
<ListAccordion data-test-scale-events @source={{@events}} @key="time" as |a|> | ||
<a.head @buttonLabel="details" @isExpandable={{a.item.hasMeta}} class="with-columns"> | ||
<div class="columns inline-definitions"> | ||
<div class="column is-3"> | ||
<span class="icon-field"> | ||
<span class="icon-container" title="{{if a.item.error "Error event"}}" data-test-error={{a.item.error}}> | ||
{{#if a.item.error}}{{x-icon "cancel-circle-fill" class="is-danger"}}{{/if}} | ||
</span> | ||
<span data-test-time title="{{format-ts a.item.time}}">{{format-month-ts a.item.time}}</span> | ||
</span> | ||
</div> | ||
<div class="column is-2"> | ||
{{#if a.item.hasCount}} | ||
<span data-test-count-icon | ||
class="tooltip" | ||
aria-label="Count {{if a.item.increased "increased" "decreased"}} to {{a.item.count}}" | ||
> | ||
{{#if a.item.increased}} | ||
{{x-icon "arrow-up" class="is-danger"}} | ||
{{else}} | ||
{{x-icon "arrow-down" class="is-primary"}} | ||
{{/if}} | ||
</span> | ||
<span data-test-count>{{a.item.count}}</span> | ||
{{/if}} | ||
</div> | ||
<div class="column" data-test-message> | ||
{{a.item.message}} | ||
</div> | ||
</div> | ||
</a.head> | ||
<a.body @fullBleed={{true}}> | ||
<JsonViewer @json={{a.item.meta}} @fluidHeight={{true}} /> | ||
</a.body> | ||
</ListAccordion> |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it’s overkill but I hovered over this just to see, a tooltip/title like “Scaled up/down to X” could be nice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that could be nice. The autoscaler folks are also looking into improving the messages they emit, so that should help too.