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

Use better flags-docs creator #7811

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

omerap12
Copy link
Member

@omerap12 omerap12 commented Feb 6, 2025

What type of PR is this?

/kind documentation
/kind cleanup

What this PR does / why we need it:

Better generation of flags docs.

Which issue(s) this PR fixes:

Fixes #7779

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

Signed-off-by: Omer Aplatony <[email protected]>
@k8s-ci-robot k8s-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 6, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: omerap12
Once this PR has been reviewed and has the lgtm label, please assign voelzmo for approval. For more information see the Code Review Process.

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

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 6, 2025
@omerap12
Copy link
Member Author

omerap12 commented Feb 6, 2025

cc @adrianmoisey @voelzmo

Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Copy link
Contributor

@voelzmo voelzmo left a comment

Choose a reason for hiding this comment

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

Thanks for taking another shot at this! I think the parsing doesn't work reliably on all occasions, though:

  • Some occurrences of type: If
  • Some descriptions repeat the parameter name, like with --add-header-dir

If the additional type column makes our lives harder (because not all parameters seem to have it, not sure why?), then I guess it is also ok to just drop it.

Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
@omerap12
Copy link
Member Author

omerap12 commented Feb 7, 2025

Thanks for taking another shot at this! I think the parsing doesn't work reliably on all occasions, though:

  • Some occurrences of type: If
  • Some descriptions repeat the parameter name, like with --add-header-dir

If the additional type column makes our lives harder (because not all parameters seem to have it, not sure why?), then I guess it is also ok to just drop it.

I saw that CA also doesn't use type so I removed it

@adrianmoisey
Copy link
Member

This link needs to be updated, if the filename changes:

For detailed information about configuration parameters for each component, see the [flags documentation](flags.md).

@omerap12
Copy link
Member Author

omerap12 commented Feb 7, 2025

This link needs to be updated, if the filename changes:

For detailed information about configuration parameters for each component, see the [flags documentation](flags.md).

Yeah I forgot 😄
Thanks!

Signed-off-by: Omer Aplatony <[email protected]>
@adrianmoisey
Copy link
Member

This may be a bit of a nit, but in the rendered view some of the long flags are wrapped:
image

May be if they were code snippets it would help not wrapping them?

Signed-off-by: Omer Aplatony <[email protected]>
@omerap12
Copy link
Member Author

omerap12 commented Feb 9, 2025

This may be a bit of a nit, but in the rendered view some of the long flags are wrapped: image

May be if they were code snippets it would help not wrapping them?

done

@adrianmoisey
Copy link
Member

Damn, that didn't fix it:
image

| `--tls-cert-file` | "/etc/tls-certs/serverCert.pem" | Path to server certificate PEM file. |
| `--tls-ciphers` | | A comma-separated or colon-separated list of ciphers to accept. Only works when min-tls-version is set to tls1_2. |
| `--tls-private-key` | "/etc/tls-certs/serverKey.pem" | Path to server certificate key PEM file. |
| `--v,` | 4 | Level set the log level verbosity |
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, there's a comma here

Copy link
Member Author

Choose a reason for hiding this comment

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

Damn, not sure how it's got there

Copy link
Member Author

Choose a reason for hiding this comment

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

I came up with a workaround for this (I know it's ugly). Let me know what you think

echo "|------|---------|-------------|"

$binary --help 2>&1 | grep -E '^\s*-' | while read -r line; do
flags=$(echo "$line" | awk '{print $1, $2}' | grep -oP '(?<=-)([^ ]+(?:, --[^ ]+)?)')
Copy link
Member

Choose a reason for hiding this comment

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

The -P flag doesn't work for macOS, which I assume developers running this may use, so I guess that needs to be replaced with something else

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I'm using Linux (you know why lol), so I'll try to find a suitable replacement for this flag that works on both OSs.

Signed-off-by: Omer Aplatony <[email protected]>

echo "# What are the parameters to VPA ${component}?"
echo "This document is auto-generated from the flag definitions in the VPA ${component} code."
echo "Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
Copy link
Contributor

Choose a reason for hiding this comment

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

While I appreciate having the option to see right away how up-to-date this document is, I think we shouldn't include a mechanism which creates a diff in every run. So let's remove the timestamp and instead rely on the change history for this file?
This way, we could use running ./hack/generate-flags.sh as a way to see if the flags are up-to-date or if there is a diff. We could also include this e.g. in a PR check, asking people to run this and keep the docs in sync with the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, I'll adjust. Once this is merged, I'll open an issue to address it.

@voelzmo
Copy link
Contributor

voelzmo commented Feb 12, 2025

With this PR, do we still need hack/create-flags-doc-vpa.sh, or can we remove it?

@omerap12
Copy link
Member Author

With this PR, do we still need hack/create-flags-doc-vpa.sh, or can we remove it?

Yes, I think we can remove it

omerap12 and others added 3 commits February 12, 2025 17:02
Co-authored-by: Marco Voelz <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
@omerap12 omerap12 requested a review from voelzmo February 12, 2025 15:08
@adrianmoisey
Copy link
Member

Any idea if adding a table of contents will be possible?

@omerap12
Copy link
Member Author

Any idea if adding a table of contents will be possible?

Hmm, do you really think that's a good idea? In my opinion, the document is quite small, but I can add something if you think it would be an improvement.

@omerap12
Copy link
Member Author

btw, unit tests are failing.. @voelzmo @adrianmoisey

@adrianmoisey
Copy link
Member

Hmm, do you really think that's a good idea? In my opinion, the document is quite small, but I can add something if you think it would be an improvement.

Yeah, I'm not strongly opinionated on it. It might be nice as the doc only contains 3 sections, and each one requires a bit of scrolling.
GitHub does have a button to show the headings on the right, so may be it isn't needed?

@adrianmoisey
Copy link
Member

btw, unit tests are failing.. @voelzmo @adrianmoisey

I wonder if we have a flake, can you re-run then? (I can't click retry)

Signed-off-by: Omer Aplatony <[email protected]>
@omerap12
Copy link
Member Author

Passed now lol @adrianmoisey

fi

echo "# What are the parameters to VPA ${component}?"
echo "This document is auto-generated from the flag definitions in the VPA ${component} code."
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it makes sense to mention that it's autogenerated from the default branch?

I could see someone reading the docs in master, assuming that a newly added flag will work for them in their release.

This makes me think that we should also consider how we're showing versioned docs when we release new versions of the VPA. But that's a discussion for a different thread.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I can add this to the script. But a follow-up question - how can a user check if some feature is available in their current VPA version?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I can add this to the script. But a follow-up question - how can a user check if some feature is available in their current VPA version?

Yeah, that's tough.
At the moment they can (in theory) browse the repo at the release branch for their current version. But that's something they need to figure out themselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood.

@adrianmoisey
Copy link
Member

/lgtm

Overall I think this is a good improvement. The markdown table is a little strange, but there's not much we can do about that.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 13, 2025
@omerap12
Copy link
Member Author

/lgtm

Overall I think this is a good improvement. The markdown table is a little strange, but there's not much we can do about that.

Thanks, I guess we can have more people tweaking it to improve it (since I'm not great at this kind of thing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/documentation Categorizes issue or PR as related to documentation. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VPA Improving Flags Documentation Generation Process
4 participants