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

Cpu and memory sparklines #387

Merged
merged 1 commit into from
Feb 29, 2016

Conversation

joeatwork
Copy link

The changes proposed here depend on the new API information in #386 - comment on this pull request can probably wait until those changes are revised and accepted or declined.

This pull request proposes adding a sparkline-like visualization of the resource usage history for individual pods in a replication controller detail screen, fixing #366

kubernetes dashboard - google chrome_053

Review on Reviewable

@joeatwork
Copy link
Author

There are a few product questions associated with this feature, in addition to issues with the implementation -

  • Right now, the scale of each chart is independent of the others - the maximum point in history will always be at the top of the chart, and even if the chart is showing only one data point the line will cross the whole chart. It's possible that these charts should all share a common scale, either on a single page or in general - if so, please comment here.
  • As proposed here, the charts are always rendered, no matter how wide or narrow the window is, and are never wrapped below the text measures. Should they disappear or wrap at some point?

@bryk
Copy link
Contributor

bryk commented Feb 17, 2016

Just tested. The UI always shows graphs in the same shape. Did you have this problem? Tested on gulp serve and in-cluster heapster.
selection_031

@bryk
Copy link
Contributor

bryk commented Feb 17, 2016

selection_032

@bryk
Copy link
Contributor

bryk commented Feb 17, 2016

I'll investigate this tomorrow.

@joeatwork
Copy link
Author

I see those shapes for very young processes - it looks like your CPU only has two data points, and your memory history only has three. I'd love to see what you're getting back from the API. It's possible that our Heapsters are configured differently (and if so, I should probably account for that before showing the charts)

@bryk
Copy link
Contributor

bryk commented Feb 18, 2016

@floreks Can you help with review?

@@ -0,0 +1,8 @@
<svg viewBox="0,0 1,1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please add the Copyright ... boilerplate to html files. See how it is done in others.

No worries, it is stripped and minified during build process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3062264

@bryk
Copy link
Contributor

bryk commented Feb 18, 2016

This is awesome @joeatwork :) I'm really happy with the shape of this PR. A few comments, PTAL

@joeatwork joeatwork force-pushed the cpu-and-memory-sparklines branch from 585c090 to d94f58c Compare February 18, 2016 18:29
@joeatwork
Copy link
Author

Thanks for all of your help! I believe I've addressed your comments - please take another look when you get the time.

@floreks
Copy link
Member

floreks commented Feb 19, 2016

@floreks Can you help with review?

I wanted to this today morning but I see you've done it all :) I'll take a look anyway.

<span ng-if="::ctrl.hasCpuUsage(pod)">
{{::(pod.metrics.cpuUsage | kdCores)}}
</span>
<span ng-if="::!ctrl.hasCpuUsage(pod)">
-
</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without that when there are no metrics to display columns are empty.

zrzut ekranu z 2016-02-19 10-01-10
zrzut ekranu z 2016-02-19 10-00-10

This doesn't look very good. Sometimes we have to wait a bit for metrics to appear so i guess this is needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 3074c8f and 937893d

@bryk
Copy link
Contributor

bryk commented Feb 19, 2016

Reviewed 7 of 12 files at r1, 5 of 5 files at r2.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 29 [r2] (raw file):
You dont need this input param anymore.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Is timeseries optional? What will happen if this is not defined? I think the Javascript will fail. Mark this as non-optional?


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
Hmm... How about we put this in the same column as current usage? So that the sparkline wraps as needed. The reason is that the table is already pretty wide and forcing it to be even wider worries me.

@floreks ?


Comments from the review on Reviewable.io

@bryk
Copy link
Contributor

bryk commented Feb 19, 2016

(bear in mind that I'm testing reviewable.io, so might miss something)

@floreks
Copy link
Member

floreks commented Feb 19, 2016

Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Do we actually need 2 way binding here? Is '@' not sufficient?


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
I agree. I'm also worried how introducing additional column would affect row to table mapping on smaller screens. Same column for both sounds good.


Comments from the review on Reviewable.io

@bryk
Copy link
Contributor

bryk commented Feb 19, 2016

Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Timeseries is an object. You usually dont want to bind objects with @ which converts everything to a string.


Comments from the review on Reviewable.io

@bryk
Copy link
Contributor

bryk commented Feb 19, 2016

Btw, there's also a gulp format-javascript task.

@joeatwork joeatwork force-pushed the cpu-and-memory-sparklines branch from 0ae5a0a to 205a215 Compare February 19, 2016 18:10
@joeatwork
Copy link
Author

Review status: 4 of 9 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 29 [r2] (raw file):
Fixed in 0ae5a0a


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
I've made timeseries non-optional in 205a215 - for now, I'm leaving the '=' binding, if that's ok.


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
We should probably explicitly wrap the column at certain widths with media-queries. Otherwise it will be really tough to get a column that looks like the mock - the mock right now is right justified, but the cell shrinks to so that the left edge of the longest cell in the column lines up with the header (I've included an image with what I think is the desired behavior - the content of the widest cell lines up on the left with the header, but all of the other cells are right-aligned, so their charts line up)

Selection_059.png

Getting this effect requires that the cells be as narrow as they can be, or the left edge of the longest content will wander off and leave the header looking strange.

Selection_060.png

A fix (and the only one I can think of) is to make the sparkline cells as narrow as possible. Unfortunately, this means they'll always wrap, since a wrapped cell is narrower than an unwrapped cell. We could change this to prevent the wrap, but this will (in the absence of media queries) prevent wrapping in all cases, which doesn't get us anywhere.

Selection_061.png

Is there an example of media-querying, or responding in layout to size, elsewhere in the code? It seems like the natural thing to do might be to explicitly hide or wrap the charts when the viewport is narrower than some threshold, rather than trying to get the natural text wrapping to work. Alternately, we could just left-justify the content, or compromise on the mock, if that seems appropriate. Do you guys have any thoughts about this?


Comments from the review on Reviewable.io

@floreks
Copy link
Member

floreks commented Feb 22, 2016

Review status: 4 of 9 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
Display of CPU usage units should be changed soon to more user friendly format (2.5 CPU). This way there won't be so big numbers used and we can style it better. For memory I think we can also round it to 1 decimal place.

Still for display we can use 1 table column but wrap it in 2 divs or something and align text to the left. I'd love to help with styling that but for now I've problem with heapster on my local cluster and can't make him produce any metrics.


Comments from the review on Reviewable.io

@bryk
Copy link
Contributor

bryk commented Feb 22, 2016

Reviewed 4 of 5 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Nice, thanks!


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
We have media queries examples in the code, e.g., ./app/frontend/chrome/chrome.scss:89:@media only screen and (max-width: $layout-breakpoint-xs) {. There's even media queries in JS code using $mdMedia service. See _variables.scss file for breakpoints or take a breakpoint from https://github.com/angular/material/blob/HEAD/src/core/style/variables.scss.

I say: go for media queries. Display underneath and next to depending on the size. Please verify that this works from 1920px width to phone size :)


Comments from the review on Reviewable.io

@bryk
Copy link
Contributor

bryk commented Feb 22, 2016

Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


a discussion (no related file):
Btw, this PR needs rebase.


Comments from the review on Reviewable.io

@joeatwork joeatwork force-pushed the cpu-and-memory-sparklines branch from 205a215 to 4844eca Compare February 24, 2016 22:16
.kd-sparkline {
background-color: $body;
height: 2.5 * $baseline-grid;
vertical-align: -$baseline-grid / 2; // 20% below baseline, to flow with text
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryk - I've added the vertical-align back in. Without it, the graph visually looks too high, like it's a step up from the label text. If I change the enclosing line-height to zero, it moves the graph but also the label text, so the graph still looks higher than the mock. (I might not understand your line-height suggestion) - please let me know if this is ok.

@joeatwork
Copy link
Author

I've changed the look of empty fields (That is, when you are expecting metrics from the server but get an empty list of metrics) to match the other fields, displaying a left-aligned dash in that case:

Selection_074.png


Review status: 5 of 9 files reviewed at latest revision, 7 unresolved discussions.


src/app/frontend/common/components/sparkline/sparkline_controller.js, line 23 [r2] (raw file):
Done.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 29 [r2] (raw file):
Done.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Done.


src/app/frontend/common/components/sparkline/sparkline_directive.js, line 30 [r2] (raw file):
Done.


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 158 [r2] (raw file):
I've added media queries - I've also moved the breaking point that hides the sidebar from gt-sm to gt-md, since the new columns expand the width of the table. I've made some choices about the padding, spacing of the sparkline that are probably worth taking a look at- here are some screenshots of the different sized layouts after the proposed patch:

"Natural" XL width:

Selection_070.png

Middle width - no sidebar, wrapping sparkline. I've padded the top and bottom of the cell in this case by $baseline-grid

Selection_071.png

Standard "phone" width - there is enough room for the sparkline to display next to the label for the most part

Selection_072.png

Most narrow - the sparkline wraps naturally (the sparkline will also wrap if the label is very long, which seems reasonable)

Selection_073.png


Comments from the review on Reviewable.io

@joeatwork
Copy link
Author

@floreks, @bryk I think I've addressed your concerns with wrapping and single-table-cell layouts in the recent commits - I haven't changed the formats or metrics for the CPU or Memory, but those can be changed globally whenever you'd like since I'm using the same filters to format the values that are used elsewhere. Please take another look and let me know if these changes work for you! The biggest things to consider (and maybe ask me to change) are

  • I've changed the breakpoint that makes the left column disappear from sm to md, since the new columns were breaking out of the viewport much earlier
  • I've added a baseline adjustment back to the sparkline (this time in terms of $baseline-grid) because otherwise the baseline of the text and the bottom of the chart want to line up in a funny looking way
  • I've added some padding and spacing at various viewport widths that isn't in any mock, which means I may be doing goofy un-designerly things. You can see the results in the screenshots attached to the PRQ.

Thanks again for all of your help with this!

@codecov-io
Copy link

Current coverage is 80.28%

Merging #387 into master will decrease coverage by -1.24% as of 4071cc6

@@            master    #387   diff @@
======================================
  Files           76      78     +2
  Stmts          617     629    +12
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit            503     505     +2
  Partial          0       0       
- Missed         114     124    +10

Review entire Coverage Diff as of 4071cc6

Powered by Codecov. Updated on successful CI builds.

@bryk
Copy link
Contributor

bryk commented Feb 25, 2016

Nice! My last comments about style and some tests and let's merge. I cant wait to have this on HEAD


Reviewed 2 of 4 files at r5.
Review status: 7 of 9 files reviewed at latest revision, 5 unresolved discussions.


src/app/frontend/common/components/sparkline/sparkline_controller.js, line 18 [r5] (raw file):
Btw, classes start should with Capital Letter.


src/app/frontend/common/components/sparkline/sparkline_controller.js, line 23 [r5] (raw file):
Can you test this class?


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 156 [r5] (raw file):
Can you move this and the other {{(ctrl.mdMedia('gt-xs') || undefined) && 1}} to a controller's method? We don't want to be putting logic into templates, just method calls and field reads. In controller, we'll be able also to test this.


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.scss, line 129 [r5] (raw file):
Sounds good.


Comments from the review on Reviewable.io

@joeatwork
Copy link
Author

Review status: 5 of 10 files reviewed at latest revision, 6 unresolved discussions.


a discussion (no related file):
Rebased against current master. Thanks!


src/app/frontend/common/components/sparkline/sparkline_controller.js, line 18 [r5] (raw file):
Fixed in 7ed2a98


src/app/frontend/common/components/sparkline/sparkline_controller.js, line 23 [r5] (raw file):
Added tests in 1427bef


src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html, line 156 [r5] (raw file):
Fixed in 9d99690


Comments from the review on Reviewable.io

@joeatwork
Copy link
Author

Thanks for your continuing help with this! I think your last comments have been addressed.

@cheld
Copy link
Contributor

cheld commented Feb 29, 2016

@joeatwork

  1. The code seems to have some formatting issues. You must run gulp format-javascript before committing.
  2. Normally we squash our commits

@bryk I also see only three data points when using local cluster

@bryk
Copy link
Contributor

bryk commented Feb 29, 2016

@cheld Update your heapster. 0.18.x version does not quite work.

@joeatwork squash and gulp format-javascript and we're ready to merge :) :lgtm:


Reviewed 1 of 4 files at r5, 4 of 4 files at r6.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from the review on Reviewable.io

@joeatwork joeatwork force-pushed the cpu-and-memory-sparklines branch from 9d99690 to 7ef80f3 Compare February 29, 2016 16:55
@joeatwork
Copy link
Author

Linted and squashed!

@bryk
Copy link
Contributor

bryk commented Feb 29, 2016

Awesome! Merging. If you need any help from us, just ping.


Reviewed 2 of 2 files at r7.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

bryk added a commit that referenced this pull request Feb 29, 2016
@bryk bryk merged commit 13e88ce into kubernetes:master Feb 29, 2016
@joeatwork
Copy link
Author

Thanks, folks!

@joeatwork joeatwork deleted the cpu-and-memory-sparklines branch February 29, 2016 23:44
@cheld
Copy link
Contributor

cheld commented Mar 1, 2016

I played around with heapster 0.19.0 and the parameters -stats_resolution -model_resolution -model_frequency.

I experimented a lot, but I was not able to create pretty charts. Can you suggest proper settings?

@bryk
Copy link
Contributor

bryk commented Mar 1, 2016

@joeatwork What is your heapster setup?

@cheld
Copy link
Contributor

cheld commented Mar 1, 2016

ok, I tried 2.0-alpha. This seems to work much better. Unfortunately, it crashes if one changes the default flags. However, even with the default values, this version produce something that is acceptable.

@bryk
Copy link
Contributor

bryk commented Mar 1, 2016

ok, I tried [heapster] 2.0-alpha. This seems to work much better. Unfortunately, it crashes if one changes the default flags. However, even with the default values, this version produce something that is acceptable.

CC @mwielgus

@cheld
Copy link
Contributor

cheld commented Mar 1, 2016

@mwielgus

Unfortunately, the crashes are not only related to flags. The version also crashes randomly. I created an issue.

@joeatwork
Copy link
Author

I've been running with gcr.io/google_containers/heapster:v0.20.0-alpha5 - here's my heapster replication controller in detail:

apiVersion: v1
kind: ReplicationController
metadata: 
  labels: 
    k8s-app: heapster
    kubernetes.io/cluster-service: "true"
    version: v10
  name: heapster-v10
  namespace: kube-system
spec: 
  replicas: 1
  selector: 
    k8s-app: heapster
    version: v10
  template: 
    metadata: 
      creationTimestamp: null
      labels: 
        k8s-app: heapster
        kubernetes.io/cluster-service: "true"
        version: v10
    spec: 
      containers: 
        - command: 
            - /heapster
            - "--source=kubernetes:https://kubernetes.default"
            - "--sink=influxdb:http://monitoring-influxdb:8086"
          image: gcr.io/google_containers/heapster:v0.20.0-alpha5
          imagePullPolicy: IfNotPresent
          name: heapster
          resources: 
            limits: 
              cpu: 100m
              memory: 224Mi
            requests: 
              cpu: 100m
              memory: 224Mi
          terminationMessagePath: /dev/termination-log
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      terminationGracePeriodSeconds: 30

anvithks added a commit to anvithks/k8s-dashboard that referenced this pull request Mar 27, 2023
Bumps [tree-kill](https://github.com/pkrumins/node-tree-kill) from 1.2.0 to 1.2.2.
- [Release notes](https://github.com/pkrumins/node-tree-kill/releases)
- [Commits](pkrumins/node-tree-kill@v1.2.0...v1.2.2)

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Anvith KS <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants