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

Feature/add disk-usage command #13112

Closed
wants to merge 5 commits into from
Closed

Feature/add disk-usage command #13112

wants to merge 5 commits into from

Conversation

mpuckett159
Copy link
Contributor

@mpuckett159 mpuckett159 commented Dec 7, 2021

fixes #12967

This PR implements a subcommand to minikube called disk-usage that will, by default, output a list of the child directories of the user's minikube directory in a human readable format. It has additional flags for printing the full, unrounded bytes of the directory sizes, and for only displaying the size of the root directory. The flags can be used serially. See below for what the new output looks like.

Example output:

❯ ./out/minikube disk-usage -h
Shows current disk usage of minikube

Options:
  -l, --long=false: Whether to return a human readable formatted number, e.g. 1GB
  -r, --root-only=false: Only show total of root minikube file instead of breaking out all sub directories

Usage:
  minikube disk-usage [flags] [options]

Use "minikube options" for a list of global command-line options (applies to all commands).
❯ ./out/minikube disk-usage              
    ▪ .minikube - 23.65GB
    ▪ addons - 0B
    ▪ bin - 11.43MB
    ▪ cache - 3.276GB
    ▪ certs - 8.272kB
    ▪ config - 2B
    ▪ files - 3.416kB
    ▪ logs - 175.9kB
    ▪ machines - 20.37GB
    ▪ profiles - 72.45kB
❯ ./out/minikube disk-usage -l
    ▪ .minikube - 23654741962
    ▪ addons - 0
    ▪ bin - 11428724
    ▪ cache - 3276493928
    ▪ certs - 8272
    ▪ config - 2
    ▪ files - 3416
    ▪ logs - 176318
    ▪ machines - 20366530406
    ▪ profiles - 72453
❯ ./out/minikube disk-usage -r
    ▪ .minikube - 23.65GB
❯ ./out/minikube disk-usage -r -l
    ▪ .minikube - 23654742710

This commit adds the disk-usage command to minikube, which can be used to calculate and display the disk usage of a users default minikube directory and immediate child directories.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 7, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @mpuckett159. Thanks for your PR.

I'm waiting for a kubernetes 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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 7, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mpuckett159
To complete the pull request process, please assign spowelljr after the PR has been reviewed.
You can assign the PR to them by writing /assign @spowelljr in a comment when ready.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@medyagh
Copy link
Member

medyagh commented Dec 7, 2021

I find the flags a bit confusing and also it is showing the disk usage outside minikube which what I first thought, ( I thought would show disk usage inside minikube node)

@mpuckett159
Copy link
Contributor Author

I find the flags a bit confusing

Yeah I'm not super happy with the flags either. I wanted to mimic du more exactly but it wouldn't let me (or I couldn't figure out how to at least) override the -h flag for help to be the "human readable" flag.

@afbjorklund
Copy link
Collaborator

afbjorklund commented Dec 7, 2021

Note that "du" uses M to mean 1048576 bytes, which makes some people angry. (minikube does the same)

https://en.wikipedia.org/wiki/Megabyte#Definitions

Substantially easier/cleaner, thanks for the pointer.
Sorry something killed my pre-commit hooks.
@mpuckett159
Copy link
Contributor Author

Updated the original PR comment to reflect the usage of the github.com/docker/go-units function HumanSize for formatting the size output for human readable formatting.

@mpuckett159
Copy link
Contributor Author

"also it is showing the disk usage outside minikube which what I first thought, ( I thought would show disk usage inside minikube node)"

@medyagh Could you explain this a little more for me? I seem to have misunderstood the ask some but I'm not exactly sure what part of it I missed. You can DM me in the K8S Slack as well if you want, username there is @Marcus Puckett

@medyagh
Copy link
Member

medyagh commented Dec 13, 2021

@mpuckett159
by inside minikube I meant the inside minikube cluster the diskusage of the Pods,

minikube ssh
du 

I think minikube has many commands and I would love to have a feature that shows the disk usage but I would like that to be part of a bigger picture that could also be inline to what most users are used to in simmilar tools

like docker

I would perfer a MEP on this before a PR sine this adds a new command, I would like more disscusssion on this

@medyagh
Copy link
Member

medyagh commented Dec 13, 2021

here I recommend adding a MEP for. this so we could discuss what is best way to go forward
https://github.com/kubernetes/minikube/tree/master/enhancements

@mpuckett159
Copy link
Contributor Author

Hah, MEP are my initials.

Ok I'll fill that out. Sorry got confused because the Issue linked said it was good for a PR but I guess given the obvious confusion here this route is best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a minikube disk-usage command so users can see how much space minikube is using
5 participants