[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

(feat) Add validation for Unsupported Loggings Flags for component-base #92394

Merged
merged 2 commits into from
Jul 1, 2020

Conversation

rahulchheda
Copy link
@rahulchheda rahulchheda commented Jun 22, 2020

Signed-off-by: Rahul M Chheda rchheda@infracloud.io

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes ##92393

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.:


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 22, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @rahulchheda. 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 sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 22, 2020
@rahulchheda rahulchheda changed the title (feat) Add validation for Unsopprted Loggings Flags fro component-base [WIP] (feat) Add validation for Unsupported Loggings Flags for component-base Jun 22, 2020
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 22, 2020
@rahulchheda
Copy link
Author

cc: @serathius
This is a WIP PR, please take a look, and provide reviews

@fedebongio
Copy link
Contributor

/cc @logicalhan

@k8s-ci-robot k8s-ci-robot requested a review from logicalhan June 23, 2020 20:12
formats := fmt.Sprintf(`"%s"`, strings.Join(logRegistry.List(), `", "`))
fs.StringVar(&o.LogFormat, logFormatFlagName, defaultLogFormat, fmt.Sprintf("Sets the log format. Permitted formats: %s.\nNon-default formats don't honor these flags: %s.\nNon-default choices are currently alpha and subject to change without warning.", formats, unsupportedFlags))
func (o *Options) AddFlags(fs *pflag.FlagSet) error {
if unsupportedFlagsSet, unsupportedFlags := unsupportedLoggingFlags(); unsupportedFlagsSet != false {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be checked in Validate and only if logging-format is non default

@serathius
Copy link
Contributor
serathius commented Jun 23, 2020

Approach to validate if unsupported flag was set looks ok, did you manage to test it?

}
//unsupportedFlags := fmt.Sprintf("--%s", strings.Join(unsupportedLoggingFlags(), ", --"))
//formats := fmt.Sprintf(`"%s"`, strings.Join(logRegistry.List(), `", "`))
//fs.StringVar(&o.LogFormat, logFormatFlagName, defaultLogFormat, fmt.Sprintf("Sets the log format. Permitted formats: %s.\nNon-default formats don't honor these flags: %s.\nNon-default choices are currently alpha and subject to change without warning.", formats, unsupportedFlags))
Copy link
Contributor

Choose a reason for hiding this comment

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

We will still need to list all possible unsupported options using VisitAll

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we will need 2 functions one returning all unsupported flags and second one returning unsupported flags that were set.
You could also 1 function with argument set, that if true would return only set flags instead of all.

// unsupportedLoggingFlags validates all the flags provided
// if any unsupported falg is provided
// returns true, with list of all unsupported flags
func unsupportedLoggingFlags() (bool, []string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not return bool here, maybe just check if slice is empty on caller side?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 23, 2020
func (o *Options) Validate() []error {
// and gets the list of all unsupported flags
// with all the unsupported flags that are set
func (o *Options) Validate(fs *pflag.FlagSet) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change prototype of Validate() []error

unsupportedFlags := fmt.Sprintf("--%s", strings.Join(unsupportedLoggingFlags(), ", --"))
formats := fmt.Sprintf(`"%s"`, strings.Join(logRegistry.List(), `", "`))
fs.StringVar(&o.LogFormat, logFormatFlagName, defaultLogFormat, fmt.Sprintf("Sets the log format. Permitted formats: %s.\nNon-default formats don't honor these flags: %s.\nNon-default choices are currently alpha and subject to change without warning.", formats, unsupportedFlags))
func (o *Options) AddFlags(fs *pflag.FlagSet) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change prototype of AddFlags(fs *pflag.FlagSet)

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 29, 2020
@serathius
Copy link
Contributor

Please remove "[WIP]" prefix if ready
/priority important-soon
/ok-to-test

PTAL @liggitt

@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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 29, 2020
@rahulchheda rahulchheda changed the title [WIP] (feat) Add validation for Unsupported Loggings Flags for component-base (feat) Add validation for Unsupported Loggings Flags for component-base Jun 29, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 29, 2020
@rahulchheda
Copy link
Author

/retest

@serathius
Copy link
Contributor

Golint error:

staging/src/k8s.io/component-base/logs/options.go:61:36: error strings should not be capitalized or end with punctuation or a newline

Signed-off-by: Rahul M Chheda <rchheda@infracloud.io>
@serathius
Copy link
Contributor

/retest

3 similar comments
@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rahulchheda, serathius

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2020
@serathius
Copy link
Contributor

/retest

4 similar comments
@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/retest

@rahulchheda
Copy link
Author

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants