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

dm,cluster: display with uptime returned #1231

Merged
merged 22 commits into from
Mar 29, 2021

Conversation

9547
Copy link
Contributor

@9547 9547 commented Mar 21, 2021

What problem does this PR solve?

implement #1223

What is changed and how it works?

display the uptime of the instance,

if this instance is up, then uptime means the alive time, else is the inactive time.

see #1223 for more detail

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code
    image

image

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 21, 2021
@codecov-io
Copy link

codecov-io commented Mar 21, 2021

Codecov Report

Merging #1231 (2248366) into master (37487dc) will increase coverage by 0.43%.
The diff coverage is 82.06%.

❗ Current head 2248366 differs from pull request most recent head 80ee2e0. Consider uploading reports for the commit 80ee2e0 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1231      +/-   ##
==========================================
+ Coverage   53.42%   53.85%   +0.43%     
==========================================
  Files         289      277      -12     
  Lines       20687    20355     -332     
==========================================
- Hits        11051    10963      -88     
+ Misses       7903     7668     -235     
+ Partials     1733     1724       -9     
Flag Coverage Δ
cluster 45.11% <81.15%> (+0.16%) ⬆️
dm 26.61% <47.22%> (+0.12%) ⬆️
integrate 50.85% <82.06%> (+2.96%) ⬆️
playground ?
tiup 16.34% <0.00%> (-0.06%) ⬇️
unittest 22.68% <1.37%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cluster/operation/operation.go 78.26% <ø> (ø)
pkg/cluster/spec/spec.go 88.92% <ø> (ø)
pkg/cluster/manager/display.go 79.74% <70.00%> (-2.78%) ⬇️
pkg/cluster/spec/util.go 77.77% <70.37%> (-4.45%) ⬇️
components/cluster/command/display.go 29.41% <100.00%> (+1.05%) ⬆️
components/dm/command/display.go 63.63% <100.00%> (+1.73%) ⬆️
components/dm/spec/logic.go 78.65% <100.00%> (ø)
pkg/cluster/spec/alertmanager.go 66.12% <100.00%> (+1.72%) ⬆️
pkg/cluster/spec/cdc.go 82.75% <100.00%> (ø)
pkg/cluster/spec/drainer.go 58.76% <100.00%> (ø)
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37487dc...80ee2e0. Read the comment docs.

components/dm/spec/logic.go Show resolved Hide resolved
pkg/cluster/manager/display.go Outdated Show resolved Hide resolved
pkg/cluster/spec/instance.go Show resolved Hide resolved
@AstroProfundis AstroProfundis added category/usability Categorizes issue or PR as a usability enhancement. type/new-feature Categorizes pr as related to a new feature. labels Mar 22, 2021
@AstroProfundis AstroProfundis added this to the v1.5.0 milestone Mar 22, 2021
@9547
Copy link
Contributor Author

9547 commented Mar 24, 2021

@AstroProfundis @lucklove PTAL

if status == "-" {
since := "-"
if !opt.ShowUptime {
since = formatInstanceSince(ins.Uptime(tlsCfg))
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused, why call ins.Uptime even if the user didn't specify --show-uptime?

Copy link
Contributor Author

@9547 9547 Mar 25, 2021

Choose a reason for hiding this comment

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

Looks like the opposite logical ...

}

// Query the service status and uptime
if status == "-" || (opt.ShowUptime && since == "-") {
Copy link
Member

Choose a reason for hiding this comment

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

It seems this check is not necessary since we checked if status == "-" and if opt.ShowUptime && since == "-" latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, the previous check is reversed, so the check here is necessary, if user specifies opt.ShowUptime but since is empty(not implemented or server was down), we try to fetch it via ssh-systemctl-status)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the check is necessary.

The previous check is A or B,
because they all need to invoke operator.GetServiceStatus,
and later for condition A I'm trying to get the status(if not this condition, don't need to rewrite status), and for B to get the since.

@9547 9547 force-pushed the feature/display-uptime branch 2 times, most recently from 1d9b083 to 9257678 Compare March 25, 2021 15:53
@lucklove
Copy link
Member

It's better to hide Since column when the user doesn't specify --uptime
屏幕快照 2021-03-26 下午4 06 22

@lucklove
Copy link
Member

lucklove commented Mar 26, 2021

It seems the format is not consistent when the data source different from metric and systemd.
屏幕快照 2021-03-26 下午4 06 33

It's better to make it consistent:

  • Maybe we can parse the string returned by systemd to int and format it again
  • Or we can use the same format with systemd

@9547 @AndreMouche What do you think about it?

@9547
Copy link
Contributor Author

9547 commented Mar 27, 2021

It seems the format is not consistent when the data source different from metric and systemd.
屏幕快照 2021-03-26 下午4 06 33

It's better to make it consistent:

  • Maybe we can parse the string returned by systemd to int and format it again
  • Or we can use the same format with systemd

@9547 @AndreMouche What do you think about it?

Agree with it, keep the format consistent, I'll try to parse the output of systemd's output.

+1 to hide Since column if --uptime not specified.

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 27, 2021
@lucklove
Copy link
Member

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lucklove

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 29, 2021
@lucklove
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 055bb80

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 29, 2021
@ti-chi-bot
Copy link
Member

@9547: Your PR was out of date, I have automatically updated it for you.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit da012e4 into pingcap:master Mar 29, 2021
@9547 9547 deleted the feature/display-uptime branch April 5, 2021 22:41
@9547 9547 mentioned this pull request Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/usability Categorizes issue or PR as a usability enhancement. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/new-feature Categorizes pr as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants