Skip to content

Display oc and kube server versions as part of oc version #9785

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 Jul 11, 2016

Upstream: kubernetes/kubernetes#29236

Before

oc version

oc v3.2.1.4-1-g1864c8f
kubernetes v1.2.0-36-g4a3f9c5
After

oc version

CLIENTS
oc v1.3.0-alpha.0+005dbbb-dirty
kubernetes v1.3.0+57fb9ac
features: Basic-Auth

SERVERS
OpenShift Master v1.3.0-alpha.0+005dbbb-dirty (https://10.13.137.149:8443)
Kubernetes Master v1.3.0+57fb9ac (https://10.13.137.149:8443)
On Error Connecting to Server

oc version

CLIENTS
oc v1.3.0-alpha.0+005dbbb-dirty
kubernetes v1.3.0+57fb9ac
features: Basic-Auth

SERVERS
error: server took too long to respond with version information.

@juanvallejo
Copy link
Contributor Author

[test]

@juanvallejo
Copy link
Contributor Author

@fabianofranz Could you please take a look?

@liggitt
Copy link
Contributor

liggitt commented Jul 11, 2016

that is a surprisingly large number of completions changes for this

@liggitt
Copy link
Contributor

liggitt commented Jul 11, 2016

newline between client a server versions

@deads2k
Copy link
Contributor

deads2k commented Jul 11, 2016

any idea what happened to the generation?

@liggitt
Copy link
Contributor

liggitt commented Jul 11, 2016

add a header or something indicating the version information is switching to server info, and maybe include the host that is being shown? (e.g. server version (https://localhost:8443):

for i := 0; i < 2; i++ {
select {
case ocVersion := <-ocServerVersionChan:
fmt.Fprintf(o.Out, "OpenShift Master %v\n", ocVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

random order of output is going to bother me, make the output order consistent.

@juanvallejo
Copy link
Contributor Author

@deads2k

You'll need to interpret this error to provide reasonable output for when this run against a kube server.

This could be a function setting values and closing a channel to indicate, "done", right? You wait for "done" then, inspect the values to limit the number of channels you have.

Thanks for the feedback! e85107a

var maxRequestDuration int32 = 10

// start goroutine to fetch openshift / kubernetes server version
go func(f *clientcmd.Factory, timeout int32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

done := make(chan struct{})
var serverVersionErr error
oVersion := ""
kVersion := ""

go func{
    defer close(done)

    oversion, err := oclient.Get().AbsPath("/version/openshift").Do().Raw()
    if err != nil{
        serverVersionErr = err
        return
    }
    //parse

    //repeat for kube version
}

select {
    case <- done:
    case <- time.After(timeout):
        return fmt.Errorf("error getting server version)
}

fmt.Fprintf("server vesrion stuf")

looks a little tighter I think

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch 2 times, most recently from 4efb92b to bec40dd Compare July 12, 2016 21:49
@juanvallejo
Copy link
Contributor Author

re[test]

@deads2k
Copy link
Contributor

deads2k commented Jul 13, 2016

@juanvallejo what is going on with your completions?

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from bec40dd to 005dbbb Compare July 13, 2016 15:07
@juanvallejo
Copy link
Contributor Author

juanvallejo commented Jul 13, 2016

@deads2k

what is going on with your completions?

I was passing root.PersistentFlags() to NewCmdVersion in openshift.go here: 5e7f3be#diff-1e4f76227f916f9f1ce10a35f8f756a6R120

It should be fixed: 5e7f3be


const (
versionLong = `
Display client and server versions for Kubernetes and OpenShift.`
Copy link
Contributor

Choose a reason for hiding this comment

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

I would drop the product names

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from 005dbbb to ea02ef2 Compare July 13, 2016 17:26
@juanvallejo
Copy link
Contributor Author

@liggitt

you lost the version.Options struct

Thanks for your feedback, fixed! e33053b

@juanvallejo
Copy link
Contributor Author

flake? re[test]

@liggitt
Copy link
Contributor

liggitt commented Jul 13, 2016

I would leave the existing client version output alone (no header)

@liggitt
Copy link
Contributor

liggitt commented Jul 13, 2016

I would include the server host in the header, something like:

Server https://...
openshift v1.3.0-alpha.0+005dbbb-dirty
kubernetes v1.3.0+57fb9ac


type VersionOptions struct {
BaseName string
Config clientcmdapi.Config
Copy link
Contributor

Choose a reason for hiding this comment

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

dead?

@deads2k
Copy link
Contributor

deads2k commented Jul 14, 2016

Otherwise looking good, @deads2k do you have anything else?

final comments in.

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from c01ec83 to d268f24 Compare July 14, 2016 22:10
@juanvallejo
Copy link
Contributor Author

re[test]

@@ -339,6 +339,10 @@ os::cmd::expect_success "oadm completion zsh"
os::cmd::expect_failure_and_text "oadm completion test_shell" 'Unsupported shell type "test_shell"'
echo "oc completion: ok"

# test oc version output
os::cmd::expect_success_and_text "oc version" "Server"
Copy link
Contributor

Choose a reason for hiding this comment

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

Better content test. Check both server down and server up.

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from d268f24 to 9e415fc Compare July 15, 2016 20:23

select {
case err, closed := <-done:
if strings.HasSuffix(fmt.Sprintf("%v", err), "connection refused") || clientcmd.IsConfigurationMissing(err) || kclientcmd.IsConfigurationInvalid(err) {
Copy link
Contributor Author

@juanvallejo juanvallejo Jul 15, 2016

Choose a reason for hiding this comment

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

@deads2k
It turns out that the IsConfigurationInvalid function in https://github.com/openshift/origin/blob/master/vendor/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/validation.go#L95 does not take into account config files that are completely missing, just ones with invalid values. I also tried using the method IsEmptyConfig instead but that one doesn't take into account a config location that is missing altogether. Since the error for a missing config file is located in our clientcmd package, I went ahead and placed the method IsConfigurationMissing there.

@deads2k
Copy link
Contributor

deads2k commented Jul 18, 2016

lgtm, squash for merge.

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch 2 times, most recently from 0aeeaaa to 658de10 Compare July 18, 2016 16:03
@juanvallejo
Copy link
Contributor Author

re[test]

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from 658de10 to 7ea6811 Compare July 19, 2016 22:35
@juanvallejo
Copy link
Contributor Author

juanvallejo commented Jul 19, 2016

@fabianofranz @liggitt @deads2k While working on PR #9944, I ended up needing to add an error type for missing config file (like I did with this one) upstream. I have updated this PR so that it implements the new error type upstream as well, instead of in pkg/cmd/util/clientcmd/factory.go

EDIT: PR #9944 did not end up needing the new type of error, reverted changes to use clientcmd.IsConfigurationMissing error type check

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from 7ea6811 to fac96a8 Compare July 20, 2016 19:57
@juanvallejo
Copy link
Contributor Author

re[test]

@juanvallejo
Copy link
Contributor Author

flake re[test]

@juanvallejo
Copy link
Contributor Author

re[test]

2 similar comments
@juanvallejo
Copy link
Contributor Author

re[test]

@juanvallejo
Copy link
Contributor Author

re[test]

@juanvallejo juanvallejo force-pushed the jvallejo_display-server-version-oc-version branch from fac96a8 to 131728a Compare July 27, 2016 16:42
@juanvallejo
Copy link
Contributor Author

re[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 131728a

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/7003/)

@fabianofranz
Copy link
Member

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 131728a

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 27, 2016

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

@openshift-bot openshift-bot merged commit 5030b88 into openshift:master Jul 27, 2016
@juanvallejo juanvallejo deleted the jvallejo_display-server-version-oc-version branch July 29, 2016 13:13
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.

5 participants