-
Notifications
You must be signed in to change notification settings - Fork 244
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
Fix preference not taken into account for odo version
#6415
Fix preference not taken into account for odo version
#6415
Conversation
✅ Deploy Preview for odo-docusaurus-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - thanks!
I'm wondering in this case if we shouldn't make the preference client a mandatory dependency, and explicitly fail if this is not the case.
I can see that preferenceInfo#GetTimeout()
already falls back to DefaultTimeout
if there is no timeout setting defined. So we could be more strict by expecting the Preference client dependency to be there in VersionOptions#Complete
.
To be clear, I am just thinking of the following diff:
diff --git a/pkg/odo/cli/version/version.go b/pkg/odo/cli/version/version.go
index 180c8b58a..e31226808 100644
--- a/pkg/odo/cli/version/version.go
+++ b/pkg/odo/cli/version/version.go
@@ -5,13 +5,11 @@ import (
"fmt"
"os"
"strings"
- "time"
"github.com/redhat-developer/odo/pkg/kclient"
"github.com/redhat-developer/odo/pkg/odo/cmdline"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
- "github.com/redhat-developer/odo/pkg/preference"
odoversion "github.com/redhat-developer/odo/pkg/version"
"github.com/spf13/cobra"
@@ -63,16 +61,7 @@ func (o *VersionOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline,
client, err := kclient.New()
if err == nil {
- // checking the value of timeout in preference
- var timeout time.Duration
- if o.clientset.PreferenceClient != nil {
- timeout = o.clientset.PreferenceClient.GetTimeout()
- } else {
- // the default timeout will be used
- // when the value is not readable from preference
- timeout = preference.DefaultTimeout
- }
- o.serverInfo, err = client.GetServerVersion(timeout)
+ o.serverInfo, err = client.GetServerVersion(o.clientset.PreferenceClient.GetTimeout())
if err != nil {
klog.V(4).Info("unable to fetch the server version: ", err)
}
At least, this would explicitly panic if the Preference Client is not there and allow to catch this issue if it occurs again, IMO.
What do you think?
You are right, I'm also annoyed by this test on the client, which was hiding the error. I'll apply your patch. |
Co-authored-by: Armel Soro <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
` | ||
) | ||
|
||
func TestOdoHelp(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this test 😍 💯
/override windows-integration-test/Windows-test
|
@feloy: Overrode contexts on behalf of feloy: windows-integration-test/Windows-test In response to this:
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. |
/override OpenShift-Integration-tests/OpenShift-Integration-tests
|
@feloy: Overrode contexts on behalf of feloy: OpenShift-Integration-tests/OpenShift-Integration-tests In response to this:
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. |
What type of PR is this:
/kind bug
What does this PR do / why we need it:
This PR adds the PREFERNECE dependency to
odo version
, and creates a CommandGroup abstraction to avoid this error occurs again.Which issue(s) this PR fixes:
odo version
can use the Timeout value defined in the odo preferences, but this value were never taken into account, because the PREFERENCE dependency were overwritten when setting the command group.Fixes #6417
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: