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

Update printer.go for used/not-used ETCD storage percentage #17871

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Scotchman0
Copy link

based on OMC's output for etcdctl endpoint health reporting, add output that includes how much storage is used/not in use and a percentage for better visualization of data within the database. Help with analysis for defrag rates and visual output.

https://github.com/gmeghnag/omc/blob/e97cc10586cefbf0c626ef43b61597730f2b82cf/cmd/etcd/etcdctl.go#L35-L50\

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Hi @Scotchman0. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 kubernetes/test-infra repository.

@Scotchman0
Copy link
Author

Scotchman0 commented Apr 24, 2024

Example output:

$ etcdctl endpoint status

+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+--------+
|          ENDPOINT           |        ID        | VERSION | DB SIZE/IN USE | NOT USED | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+--------+
| https://xxx.xxx.xxx:2379    | 1fc63d8d0eb5fa7b | 3.5.9   | 6.7 GB/5.6 GB  | 18%      | false     | false      |      5853 | 4073918326 |         4073918326 |        |
| https://xxx.xxx.xxx:2379    | 3bd2d35c028a6a2f | 3.5.9   | 6.8 GB/5.6 GB  | 19%      | true      | false      |      5853 | 4073918327 |         4073918327 |        |
| https://xxx.xxx.xxx:2379    | 41cbbc084d60007d | 3.5.9   | 6.8 GB/5.6 GB  | 18%      | false     | false      |      5853 | 4073918330 |         4073918330 |        |
+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+--------+

@ivanvc
Copy link
Member

ivanvc commented Apr 24, 2024

Hi @Scotchman0, thanks for your contribution. While we await a maintainer to review this suggestion, would you mind signing your commit? So the developer certificate of origin (DCO) check passes, i.e:

git rebase HEAD~1 --signoff
git push --force

Ref: https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#commit-your-change

based on OMC's output for etcdctl endpoint health reporting, add output that includes how much storage is used/not in use and a percentage for better visualization of data within the database. Help with analysis for defrag rates and visual output.

Signed-off-by: Will Russell <will.russell.01@gmail.com>
@Scotchman0
Copy link
Author

Latest update:

+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+--------+
|          ENDPOINT           |        ID        | VERSION | DB SIZE | IN USE | NOT USED | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+--------+
| https://xxx.xxx.xxx:2379    | 1fc63d8d0eb5fa7b | 3.5.9   | 6.7 GB | 5.6 GB  | 18%      | ??    | false     | false      |      5853 | 4073918326 |         4073918326 |        |
| https://xxx.xxx.xxx:2379    | 3bd2d35c028a6a2f | 3.5.9   | 6.8 GB | 5.6 GB  | 19%      | ??    | true      | false      |      5853 | 4073918327 |         4073918327 |        |
| https://xxx.xxx.xxx:2379    | 41cbbc084d60007d | 3.5.9   | 6.8 GB | 5.6 GB  | 18%      | ??    | false     | false      |      5853 | 4073918330 |         4073918330 |        |
+-----------------------------+------------------+---------+----------------+----------+-----------+------------+-----------+------------+--------------------+---------

…dded possible/pending Quota field

Signed-off-by: Will Russell <will.russell.01@gmail.com>
@@ -211,7 +211,7 @@ func makeEndpointHealthTable(healthList []epHealth) (hdr []string, rows [][]stri
}

func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]string) {
hdr = []string{"endpoint", "ID", "version", "storage version", "db size", "db size in use", "is leader", "is learner", "raft term",
hdr = []string{"endpoint", "ID", "version", "storage version", "db size", "in use", "not used", "quota", "is leader", "is learner", "raft term",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "not in use"

Copy link
Author

Choose a reason for hiding this comment

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

changed - agreed that's clearer

@siyuanfoundation
Copy link
Contributor

/ok-to-test

@@ -221,6 +221,8 @@ func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]stri
status.Resp.StorageVersion,
humanize.Bytes(uint64(status.Resp.DbSize)),
humanize.Bytes(uint64(status.Resp.DbSizeInUse)),
fmt.Sprint(100-(status.Resp.DbSizeInUse*100/status.Resp.DBSize)) + "%",
Copy link
Contributor

Choose a reason for hiding this comment

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

it is better to keep this number format consistent with in use one. They can be both byte size, or percentage.

Copy link
Author

Choose a reason for hiding this comment

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

ack - would the following format handling also succeed here? - pushed to check it but I can also revisit how I'm calculating the percentage with more of a robust option if it doesn't like this:

humanize.Bytes(uint64(100-(status.Resp.DBsizeInUse*100/status.Resp.DBSize))) + "%",

Copy link
Author

Choose a reason for hiding this comment

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

looks like no. 🤔 I'll explore some alternatives

…d changed percent check to humanize out instead of sprint

Signed-off-by: Will Russell <will.russell.01@gmail.com>
@@ -221,6 +221,8 @@ func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]stri
status.Resp.StorageVersion,
humanize.Bytes(uint64(status.Resp.DbSize)),
humanize.Bytes(uint64(status.Resp.DbSizeInUse)),
fmt.Sprint(100-(status.Resp.DbSizeInUse*100/status.Resp.DBSize)) + "%",
humanize.Bytes(uint64(status.Resp.DbSizeQuota)),
Copy link
Author

@Scotchman0 Scotchman0 May 2, 2024

Choose a reason for hiding this comment

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

removed the quota reference for the time being to see about clearing the checks but will want to add it in before merge pending the other PR that will be setting this value - will revisit.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you run the build and test locally first?

@Scotchman0
Copy link
Author

Scotchman0 commented May 2, 2024

/retest-required

(oops wrong button)

@Scotchman0 Scotchman0 closed this May 2, 2024
@Scotchman0 Scotchman0 reopened this May 2, 2024
Scotchman0 and others added 5 commits May 2, 2024 18:19
…tion is problematic

Signed-off-by: Will Russell <will.russell.01@gmail.com>
Signed-off-by: Will Russell <will.russell.01@gmail.com>
Signed-off-by: Will Russell <will.russell.01@gmail.com>
Signed-off-by: Will Russell <will.russell.01@gmail.com>
@Scotchman0
Copy link
Author

validated local build; removed additional percent symbol; confirmed output works the way I want it to (though I don't have a build running the version with the quota to check, I'll confirm that separately) latest should be where it needs to be pending another review.

sh-4.4# ./etcdctl endpoint status -w table
+----------------------------+------------------+---------+-----------------+---------+--------+------------+-------+-----------+------------+-----------+------------+--------------------+--------+
|          ENDPOINT          |        ID        | VERSION | STORAGE VERSION | DB SIZE | IN USE | NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+----------------------------+------------------+---------+-----------------+---------+--------+------------+-------+-----------+------------+-----------+------------+--------------------+--------+
| https://xxx.xxx.xxx:2379 | 4e7c8905a7df1da4 |  3.5.12 |                   |  113 MB |  73 MB |        36% |   0 B |      true |      false |         9 |    7637412 |            7637412 |        |
| https://xxx.xxx.xxx:2379 | b58db7287ba07b76 |  3.5.12 |                   |  112 MB |  73 MB |        35% |   0 B |     false |      false |         9 |    7637412 |            7637412 |        |
| https://xxx.xxx.xxx:2379 | acfb38ff541a7d54 |  3.5.12 |                   |  115 MB |  73 MB |        37% |   0 B |     false |      false |         9 |    7637412 |            7637412 |        |
+----------------------------+------------------+---------+-----------------+---------+--------+------------+-------+-----------+------------+-----------+------------+--------------------+--------+

@siyuanfoundation
Copy link
Contributor

Is it important to have NOT IN USE in percentage? If it is not critical, it is better to keep it in MB. Otherwise, can you change the name to PERCENTAGE NOT IN USE?

@Scotchman0
Copy link
Author

Is it important to have NOT IN USE in percentage? If it is not critical, it is better to keep it in MB. Otherwise, can you change the name to PERCENTAGE NOT IN USE?

I'd be inclined to change the name; The goal is to add an easy marker for identification of unused disk space which might help to illustrate why the cluster defrags often or whether or not a defrag is expected / could benefit performance. Mostly this is for easy visibility into this logic: https://github.com/openshift/cluster-etcd-operator/blob/cbfb856ec8892687a303989b84e01c8f34c1967e/pkg/operator/defragcontroller/defragcontroller.go#L181-L224
And where the max value is set: https://github.com/openshift/cluster-etcd-operator/blob/cbfb856ec8892687a303989b84e01c8f34c1967e/pkg/operator/defragcontroller/defragcontroller.go#L31C2-L31C45 (45%).

To be consistent, I think percentage handling is preferable. I've changed the name to PERCENTAGE NOT IN USE as requested and pushed a new build.

Thanks!

Signed-off-by: Will Russell <will.russell.01@gmail.com>
@Scotchman0
Copy link
Author

Scotchman0 commented May 7, 2024

oof - I accidentally broke stuff while forcing DCO 🤦 1s I'll revert.

**fixed - not sure how I pulled 64 commits in but latest should be correct 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants