Skip to content

UPSTREAM: 34763: log warning on invalid --output-version #11239

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

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Oct 5, 2016

UPSTREAM: kubernetes/kubernetes#34763

Related Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1276564

Object versions default to the current version (v1) when a specified
--output-version is invalid. This patch logs a warning when this is
the case. Cases affected are all commands with the --output-version
option, and anywhere runtime objects are converted to versioned objects.

Example

$ oc get pod <mypod> -o json --output-version=invalid --loglevel=2
1006 14:48:34.090971   25620 result.go:239]  info: the output version
specified (invalid) is invalid, defaulting to v1
{
        "kind": "Pod",
            "apiVersion": "v1",
                "metadata": {
                            "name": "mypod",
                                    "namespace": "openshift",
...

@openshift/cli-review

validSpecifiedVersion := (result.GetObjectKind().GroupVersionKind().Version == outputVersion.Version)
outputVersionString := kcmdutil.GetFlagString(cmd, "output-version")
if !validSpecifiedVersion && len(outputVersionString) > 0 {
err = fmt.Errorf("the output version specified (%v) is invalid, defaulting to %v\n", outputVersion, clientConfig.GroupVersion)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if it would be better to glog this message instead

@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch from ab39188 to 3fc967d Compare October 6, 2016 18:42
@juanvallejo juanvallejo changed the title [WIP] oc export add warning on invalid --output-version log warning on invalid --output-version Oct 6, 2016
@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch from 3fc967d to 7ef733d Compare October 6, 2016 18:50
validSpecifiedVersion := (actualVersion.Version == version.Version)
if !validSpecifiedVersion {
msg := fmt.Sprintf(" info: the output version specified (%v) is invalid, defaulting to %v\n", version.Version, actualVersion.Version)
glog.V(2).Infof("%v", msg)
Copy link
Member

Choose a reason for hiding this comment

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

You don't need fmt.Sprintf, glog can take the string and arguments directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, done!

@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch from 7ef733d to 6ae900f Compare October 6, 2016 21:54
@fabianofranz
Copy link
Member

@juanvallejo needs upstream.

@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch from 6ae900f to 4250ada Compare October 13, 2016 21:29
@juanvallejo juanvallejo changed the title log warning on invalid --output-version UPSTREAM: 34763: log warning on invalid --output-version Oct 13, 2016
@juanvallejo
Copy link
Contributor Author

juanvallejo commented Oct 13, 2016

@fabianofranz

needs upstream

Opened PR here: kubernetes/kubernetes#34763. Also updated warning to be glog.Warningf rather than glog.V(2) for easier visibility, WDYT?

@fabianofranz
Copy link
Member

Also updated warning to be glog.Warningf rather than glog.V(2) for easier visibility, WDYT?

@juanvallejo We don't normally use non-leveled glog in the client tools oc and kubectl, mostly because of the headers it adds - we only show them if you explicitly ask for logs, but not for regular messages.

I'd suggest to either keep it as leveled glog or, if you want it to be printed regardless of --loglevel, just use fmt and print to the err output.

@juanvallejo
Copy link
Contributor Author

@fabianofranz

I'd suggest to either keep it as leveled glog or, if you want it to be printed regardless of --loglevel, just use fmt and print to the err output.

Sounds good, it now prints through fmt.Errorf

@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch 2 times, most recently from 446a387 to a01fac4 Compare October 17, 2016 18:34
@juanvallejo
Copy link
Contributor Author

[test]

Object versions default to the current version (v1) when a specified
`--output-version` is invalid. This patch adds a warning to loglevel
2 when this is the case. Cases affected are all commands with the
`--output-version` option, and anywhere runtime objects are converted
to versioned objects.

**Example**
```
$ oc get pod <mypod> -o json --output-version=invalid --loglevel=2
1006 14:48:34.090971   25620 result.go:239]  info: the output version
specified (invalid) is invalid, defaulting to v1
{
        "kind": "Pod",
            "apiVersion": "v1",
                "metadata": {
                            "name": "mypod",
                                    "namespace": "openshift",
...
```
@juanvallejo juanvallejo force-pushed the jvallejo/add-warning-on-export-invalid-output-version branch from a01fac4 to 24eca9f Compare November 2, 2016 19:45
@juanvallejo
Copy link
Contributor Author

@fabianofranz This should now be up to date with upstream!

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 24eca9f

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11023/) (Base Commit: cf6ed4b)

@fabianofranz
Copy link
Member

LGTM [merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Nov 3, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11023/) (Image: devenv-rhel7_5309)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 24eca9f

@openshift-bot openshift-bot merged commit 81a6cec into openshift:master Nov 3, 2016
@juanvallejo juanvallejo deleted the jvallejo/add-warning-on-export-invalid-output-version branch November 4, 2016 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants