Skip to content

Automated cherry pick of #114680: k8s.io/component-base/logs: fix usage through Go flag#115229

Merged
k8s-ci-robot merged 4 commits intokubernetes:release-1.26from
pohly:automated-cherry-pick-of-#114680-origin-release-1.26
Feb 10, 2023
Merged

Automated cherry pick of #114680: k8s.io/component-base/logs: fix usage through Go flag#115229
k8s-ci-robot merged 4 commits intokubernetes:release-1.26from
pohly:automated-cherry-pick-of-#114680-origin-release-1.26

Conversation

@pohly
Copy link
Copy Markdown
Contributor

@pohly pohly commented Jan 20, 2023

Cherry pick of #114680 on release-1.26.

#114680: k8s.io/component-base/logs: fix usage through Go flag

For details on the cherry pick process, see the cherry pick requests page.


pohly added 3 commits January 20, 2023 15:30
api/v1.AddFlags only supports a pflag.FlagSet. The assumption was that code
which wants to use flag.FlagSet can use VisitAll to copy the flags. That works,
with one caveat: the flag.FlagSet help implementation will call String for the
zero value to determine whether the flag has a non-default value. This
currently leads to additional warnings at the end of the -help output:

     panic calling String method on zero v1.verbosityLevelPflag for flag v: runtime error: invalid memory address or nil pointer dereference
     panic calling String method on zero v1.vmoduleConfigurationPFlag for flag vmodule: runtime error: invalid memory address or nil pointer dereference

Supporting usage of methods with the zero value is good practice anyway and
thus gets added. This then avoids these panics.
Both pflag and standard FlagSet are covered.
A full string comparison might fail when the underlying libraries change how
they format the help text. A regex match is less strict, but still makes some
assumptions about the implementation.
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Jan 20, 2023
@k8s-ci-robot k8s-ci-robot added do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 20, 2023
The test was meant to fail when there are unexpected additional lines like the
"panic calling String method" messages. But `assert.Regexp` does a search for
the regexp, not a full string match, and thus succeeded even if those lines are
present. A full match needs to be requested explicitly with ^ and $.
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jan 20, 2023
@pohly
Copy link
Copy Markdown
Contributor Author

pohly commented Jan 20, 2023

I manually added #115195.

@pohly
Copy link
Copy Markdown
Contributor Author

pohly commented Jan 20, 2023

/sig instrumentation

@k8s-ci-robot k8s-ci-robot added sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 20, 2023
@pohly
Copy link
Copy Markdown
Contributor Author

pohly commented Jan 20, 2023

/assign @liggitt

This is the backport of the two PRs that you reviewed.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Jan 20, 2023

/lgtm
/approve
/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 20, 2023
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 4dc381a8ed3739917f6294db38de69f1cd078de2

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, pohly

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

The pull request process is described here

Details 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 20, 2023
@pohly
Copy link
Copy Markdown
Contributor Author

pohly commented Jan 20, 2023

/cc kubernetes/release-managers

@k8s-ci-robot k8s-ci-robot requested a review from a team January 20, 2023 19:52
@logicalhan
Copy link
Copy Markdown

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 9, 2023
@Verolop
Copy link
Copy Markdown

Verolop commented Feb 10, 2023

/lgtm

@Verolop Verolop added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Feb 10, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Feb 10, 2023
@saschagrunert
Copy link
Copy Markdown
Member

/retest

@k8s-ci-robot k8s-ci-robot merged commit 76cdf44 into kubernetes:release-1.26 Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants